src/swipl-devel/packages/xpce/man/refmanual/md/colour.md

class colour {#class-colour}

A colour object represents a 32-bit RGBA colour value (8 bits each for red, green, blue and alpha). Colours are typically attached to graphical objects:

?- send(new(P, picture), open),
   send(P, display, new(B, box(100, 100))),
   send(B, colour, red),
   send(B, fill, blue).

Like fonts and cursors, colour objects are reusable — they can be attached to multiple graphicals. xpce will not create the same colour twice; instead it returns the existing colour object from the @colours table (see <-lookup). Application code normally just names a colour and lets the type-checker convert.

xpce ships with the classic SVG/CSS named-colour set (red, blue, dark_green, …) in the hash table @colour_names; any name not in that table is looked up via the OS colour database. Colours may also be specified in CSS hex notation (#RGB, #RGBA, #RRGGBB, #RRGGBBAA) or constructed from RGB or HSV triples — see ->initialise.

@see device->foreground @see graphical<->colour @see window->colour

Class variables {#class-colour-classvars}

Instance variables {#class-colour-instvars}

Send methods {#class-colour-send}

Get methods {#class-colour-get}



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on June 16, 2026, 5:07 p.m.