All Manuals > CAPI User Guide and Reference Manual > 15 The Color System

NextPrevUpTopContentsIndex

15.3 Color specs

A color spec is an object which numerically defines a color in some color-model. For example the object returned by the call:

(color:make-rgb 0.0 1.0 0.0) =>
#(:RGB 0.0 1.0 0.0) 

defines the color green in the RGB color model. Generally short-floats are used; this results in the most efficient color conversion process. However, any float type can be used.

To find out what color-spec is associated with a color name, use the function get-color-spec. It returns the color-spec associated with a symbol. If there is no color-spec associated with color-name , this function returns nil. If color-name is the name of a color alias, the color alias is dereferenced until a color-spec is found.

Color-specs are made using standard functions make-rgb, make-hsv and make-gray. For example:

(make-rgb 0.0s0 1.0s0 0.0s0)
(make-hsv 1.2s0 0.5s0 0.9s0)
(make-gray 0.66667s0)

To create a color spec with an alpha component using the above constructors, pass an extra optional argument. For example this specifies green with 40% transparency:

(make-rgb 0.0s0 1.0s0 0.0s0 0.6s0)

You can also make a transparent color using color-with-alpha:

(color-with-alpha color-spec 0.8s0)

Note that the alpha component is not supported on Motif.

The predicate color-spec-p can be used to test for color-spec objects. The function color-model returns the model in which a color-spec object has been defined.


CAPI User Guide and Reference Manual (Unix version) - 25 Feb 2015

NextPrevUpTopContentsIndex