Color Pool

Summary: The color pool determines the colors of graphic elements.

Presentation graphics organizes all chart colors into a “color pool.” The color pool holds the color index values valid for the current graphics mode. (Refer to Chapter 9, “Communicating with Graphics,” for more information about the color index.) Palette structures contain color codes that refer to the color pool. A palette's color index determines the colors used to graph the data series associated with the palette. The colors of labels, titles, legends, and axes are determined by the contents of the color pool.

The first element of the color pool is always 0, which is the color index for the screen background color. The second element is always the highest color index available for the graphics mode. The remaining elements repeat the sequences of available pixel values, beginning with 1.

As shown in the example in “Manipulating Colors and Patterns”, the first member of a palette data structure is

unsigned short color;

This member defines the color index for the data series associated with the palette.

An example should make this clearer. A graphics mode of _MRES4COLOR (320-by-200 pixels) provides four colors for display. Color index values from 0 to 3 determine the possible colors—say, black, green, red, and brown, respectively.

The first eight elements of this color pool are as follows.

Color Pool Index Color Index Color

0 0 Black
1 3 Brown
2 1 Green
3 2 Red
4 3 Brown
5 1 Green
6 2 Red
7 3 Brown

Notice that the sequence of available foreground colors repeats from the third element. The first data series in this case would be plotted in brown, the second series in green, the third series in red, the fourth series again in brown, and so forth.

Video adapters such as the EGA or the Hercules InColor Card allow 16 on-screen colors. This allows presentation graphics to graph more series without duplicating colors.