Modulefpreviousupnextcontents[BIG][Normal][small]
Next: 5.2 Stereoscopy Up: 5 Graphics Prev: 5 Graphics Contents


5.1 Color

We will now see how to construct a color  on a terminal which permits it.

In the preceding subroutines, the colors were designated by integer numbers. 0 corresponds to the background color. For a terminal with N colors, the numbers lying between 1 and N-1 correspond to the different colors in the terminal's color table. This color table is, in general, initialized after the output terminal is selected. It is however possible to modify it of to set a color equal to the current color.

Let us first recall some preliminary notions regarding colors.

On a color terminal with a cathodic-ray tube, the different colors are obtained by the combination of the three basic colors: RED, GREEN and BLUE (RGB).

    RED    +  GREEN   =  YELLOW
    RED    +  BLUE    =  MAGENTA
    GREEN  +  BLUE    =  CYAN
    RED    +  GREEN   +  BLUE     =  WHITE

The intermediary colors are obtained by putting a multiplicative factor, between 0. and 1., with each of the basic colors. So, let X, Y and Z be 3 numbers between 0. and 1., then we can obtain all the possible colors and vary them by using the following equation:

We call the colors additive, as they are obtained by adding the basic colors.

 
Figure 5.1: RGB coordinate system 

The above is no longer true for a printer type color terminal. The basic colors are the following: MAGENTA, YELLOW and CYAN. The colors are no longer additive, but subtractive:

    MAGENTA  +  YELLOW  =  RED
    MAGENTA  +  CYAN    =  BLUE
    YELLOW   +  CYAN    =  GREEN
    MAGENTA  +  YELLOW  +  CYAN  =  BLACK

Here too, by combining the three basic colors linearly, all the colors can be obtained.

FORTRAN 3D functions with the RGB system.

In certain applications, it can be desirable to work in cylindrical coordinates. We change therefore to the "HSV" (Hue, Saturation and Value) coordinate system.

 
Figure 5.2: Two possible representations of the HSV coordinate system 


Modulefpreviousupnextcontents[BIG][Normal][small]
Next: 5.2 Stereoscopy Up: 5 Graphics Prev: 5 Graphics Contents