This static method converts a color parameter in [0.0, 1.0] to a
discrete integer in [0, MAX_PARAM]. Values
outside the range are forced back into the range; this prevents
potential unpleasantnesses such as a color parameter being
rounded to hex 100 when it must be no more than hex FF.
# - - - C o l o r M o d e l . d i s c r e t i z e
# @staticmethod
def discretize ( n ):
result = int(n*MAX_PARAM)
if result < 0:
return 0
elif result > MAX_PARAM:
return MAX_PARAM
else:
return result
discretize = staticmethod ( discretize )