Next: , Previous: The dimension class, Up: Auxiliary classes



8.1.2 The colour class

The colour class is a structure which represents a colour. It is defined thus:

     struct colour { bool grey; float red, green, blue; };

The red-green-blue (RGB) colour space is used to specify colours. This is not particularly well suited to printing, where a subtractive colour model such as CMYK is more useful, but RGB is at least very widely used. Colours printed using the Ringing Class Library will probably vary quite a lot from one device to another, but your blue lines will be blue and your red lines will be red.

To specify a colour in a colour object, simply set grey to false and set the other three members to numbers between 0 and 1, inclusive. You can also specify a shade of grey by setting grey to true; then the red element specifies the shade of grey, from 0 (black) to 1 (white).