Color
Several color models (or color spaces) have been created over the years for different applications. For our purposes, they can be divided into two areas: additive color spaces (e.g., RGB) and subtractive color spaces (e.g., CMYK). Because many of the toolkits used to manipulate graphics expose the underlying color model, it pays to know your way around RGB and CMYK before you delve into graphics programming.
The RGB Color Space
The vast majority of computer graphics applications use the RGB (Red, Green, Blue) additive color space because cathode ray computer monitors generate colors using those three components. In the RGB space, the light spectra of varying fractions of the three primary colors, red, green, and blue combine to make new colors (“peach puff,” for example, or “grassy knoll”). These primaries are referred to as channels.
The actual color generated by an RGB display device never exactly matches the perfect model because of differences between devices and variations in the software that controls those devices. However, most graphics display devices are calibrated to be within an acceptable tolerance of each other.
The RGB model is generally represented as a three-dimensional cube, where each axis is one of the three primary colors. In the abstract model, we typically look at a unit color cube, where each axis has intensity values from 0 to 1. The RGB unit cube is shown on the left side of Figure 1-1.
This unit cube is scaled ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access