next up previous contents
Next: Windows (window) Up: Graphics Previous: Graphics

   
Colors (color)

Definition

The data type color is the type of all colors available for drawing operations in windows (cf. Windows). Each color is defined by a triple of integers (r,g,b) with 0<= r,g,b <= 255, the so-called rgb-value of the color. The number of available colors is restricted and depends on the underlying hardware. Colors can be created from rgb-values, from names in a color data base (X11), or from the 16 integer constants (enumeration in <LEDA/incl/impl/x_window.h>) black, white, red, green, blue, yellow, violet, orange; cyan, brown, pink, green2, blue2, grey1, grey2, grey3.

Creation

color col; creates a color with rgb-value (0,0,0) (i.e. black).

color

col(int r, int g, int b); creates a color with rgb-value (r,g,b).

color

col(const char* name); creates a color and initializes it with the rgb-value of color name from the X11 color data base ((0,0,0) if name does not exist).

color

col(int i); creates a color and initializes it with one of the 16 predefined colors. Here i is one of the 16 integer constants black, white, red, green, blue, yellow, violet, orange, cyan, brown, pink, green2, blue2, grey1, grey2, or grey3.

   

Operations

void col.set_rgb(int r, int g, int b)
    sets the rgb-value of col to (r,g,b).
void col.get_rgb(int& r, int& g, int& b)
    assigns the rgb-value of col to (r,g,b).
void col.set_red(int r) changes the r-value of col to r.
void col.set_green(int g) changes the g-value of col to g.
void col.set_blue(int b) changes the b-value of col to b.
color color::root_color() returns the background color of the root window.


next up previous contents
Next: Windows (window) Up: Graphics Previous: Graphics
LEDA research project
1998-10-02