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

6.1. Color.__init__(): Constructor

The constructor accepts each of the three color components as either a float or an integer. Floats are in the range [0.0, 1.0], but integers are in the range [0,MAX_PARAM]. The .__standardize() method translates the float form into the integer form; see Section 6.2, “Color.__standardize(): Standardize color component representation”.

huey
# - - -   C o l o r . _ _ i n i t _ _

    def __init__ ( self, red, green, blue ):
        """Constructor for Color
        """

        #-- 1 --
        # [ if red is a float in [0.0, 1.0] ->
        #     self.r  :=  red mapped onto [0, MAX_PARAM]
        #   if red is an int in [0,MAX_PARAM] ->
        #     self.r  :=  red ]
        self.r  =  self.__standardize ( red )

        #-- 2 --
        # [ simile ]
        self.g  =  self.__standardize ( green )

        #-- 3 --
        self.b  =  self.__standardize ( blue )