Next: Explicit Colour Coding Up: Colour in X/Motif Previous: Colour in X/Motif

Colour Database

X provides a database of colours. We simply refer to these by name and X will go away a find the appropriate RGB values for us. We have in fact been using this style of colour programming in previous examples.

The colours stored in the database are comprehensive ranging form red, green, grey, black .... to more exotic colours like light salmon, tomato.

The function we typically use to perform this is:

XAllocNamedColor(display, cmap, colour_name, &xcolour, 

This assigns the appropriate pixel value in the xcolour XColour structure for a given String naming a colour stored in a specified colourmap cmap.

We would normally use the default colormap which is obtained for a given widget w via:

cmap = DefaultColormapOfScreen(w);
Tue May 24 16:52:56 BST 1994