The following structure is used to represent color:
public value class Color { public: unsigned Value; Color(unsigned ValueSet) : Value(ValueSet) {} Color(unsigned Red, unsigned Green, unsigned Blue) : Value(Red | Green << 8 | Blue << 16) {} Color(unsigned Red, unsigned Green, unsigned Blue, unsigned Alpha) : Value(Red | Green << 8 | Blue << 16 | Alpha << 24) {} static operator unsigned(Color This) {return This.Value;} };
A color holds the intensities of the component colors red, green and blue (RedGreenBlue). In C++, the hexadecimal form of a color is: 0x00bbggrr where each of rr, gg and bb are hexadecimal numbers ranging from 00 to ff. Specifying 00 for the intensity of a particular color component implies the absence of that component. Specifying ff (255 decimal) for a particular component implies the maximum value for that component. All spectral colors can be composed from combinations of the base colors red, green and blue.
Examples are:
0x0000ff | the maximum red value |
0x00ff00 | the maximum green value |
0xff0000 | the maximum blue value. |
All colors may be achieved by mixing the three primary colors. For example,
0xffffff | white - the even combination of the three primary colors |
0x000000 | black - the absence of all color. |
A less intense shade of a color is achieved by lowering the value; eg: 0x00007f is half intensity red.