Algorithmic Solutions > LEDA > LEDA Guide > Windows and Panels > Colors


The data type color represents all colors available in drawing operations of windows. Each color value corresponds to a triple of integers (r,g,b) with 0<=r,g,b<=255.

The number of available colors is restricted and depends on the underlying hardware. Colors can be created from the rgb-values, from names in a color data base (X11), or from the following integer constants black, white, red, green, blue, yellow, violet, orange, cyan, brown, pink, green2, blue2, grey1, grey2, grey3.

Checking for Failed Color Definition

A color definition may fail for the following reasons
  • system dependent limitation of colors
  • illegal rgb-value
  • color name not present in system color data base or system does not have color data base
If the definition of a color fails, we say that the constructed color is bad; otherwise it is good. The operation
	bool col.is_good()

tests whether a color is good or bad.


The program below implements a simple color definition panel. It uses three slider items for adjusting the (r,g,b)-values of the color.

On the right there is a screenshot of the program. Clicking on the picture shows the window in original size.

#include <LEDA/graphics/window.h>
#include <LEDA/graphics/color.h>

using namespace leda;

static int r,g,b;
void slider_red(int x)

void slider_green(int x)

void slider_blue(int x)

int main()
  window W(320,300,"define color");
  color col=green2;
  W.int_item("red  ",r,0,255,slider_red);
  W.int_item("blue ",b,0,255,slider_blue);

  if (col.is_good()) W.set_bg_color(col);


  return 0;
Example of Convex Hull

See also:

Drawing Operations

Windows and Panels

Panel Items

Manual Pages:

Manual Page Colors

Please send any suggestions, comments or questions to
© Copyright 2001-2003, Algorithmic Solutions Software GmbH