Programmer Reference : Common Graphics : Specifying colors : Specifying colors as RGB intensities
Specifying colors as RGB intensities
To specify a color by its red, green, and blue (RGB) intensities, send the red:green:blue: message to CgRGBColor with integer arguments specifying the intensities of the red, green, and blue components of the color. The values range between 0 and 65535. Higher values add more of the color to the color mix. Lower values specify less color in the color mix. In the following example, color1 specifies 50% gray and color2 specifies bright magenta.
| color1 color2 |
color1 := CgRGBColor red: 32767 green: 32767 blue: 32767.
color2 := CgRGBColor red: 65535 green: 0 blue: 65535
The intensity: class method of CgRGBColor creates a gray-scale color, where the red, green, and blue intensities have the same value. In the following example, color1 and color2 are equivalent:
| color1 color2 |
color1 := CgRGBColor intensity: 40000.
color2 := CgRGBColor red: 40000 green: 40000 blue: 40000.
The red, green, and blue components of a CgRGBColor can be retrieved using the red, green, and blue methods.
Tip:
The black and white class methods of CgRGBColor answer preexisting instances of CgRGBColor representing black (all intensities = 0) and white (all intensities = 65535), respectively.
Last modified date: 01/29/2015