All Manuals > CAPI User Guide > 14 The Color System

NextPrevUpTopContentsIndex

14.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:

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

defines the color green in the RGB color model. (Note that short-floats are used; this results in the most efficient color conversion process. However, any floating-point number 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 only supported on Cocoa and Windows.

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


CAPI User Guide (Windows version) - 30 Aug 2011

NextPrevUpTopContentsIndex