Next / Previous / Contents / TCC Help System / NM Tech homepage

7.4. ColorModel.normalize(): Normalize an integer color parameter

This static method converts a color parameter in [0,MAX_PARAM] to a normalized float in [0.0, 1.0]. Values outside the range are forced back into the range.

huey
# - - -   C o l o r M o d e l . n o r m a l i z e

#   @staticmethod
    def normalize ( n ):
        result  =  float(n)/MAX_PARAM
        if  result < 0.0:
           return 0.0
        elif result > 1.0:
           return 1.0
        else:
           return result

    normalize  =  staticmethod ( normalize )