15 The Color System
The LispWorks Color System allows you to manipulate colors, which are used as the color values in Graphics Ports and CAPI functions. For example, to draw a string in red, you call:
(gp:draw-string pane string x y :foreground :red)
The value of :foreground
(:red
above) must be a color specification that is recognized by the Color System (:red
is recognized because it is part of the color database that is pre-loaded)..
In the LispWorks Color System, colors can be represented in two ways:
-
A color spec, which specifies a color model (for example RGB) and the values of the parameters in this model (for example the parameters in RGB would be the values of the red, green and blue components, and optionally the alpha value).
-
A symbol, normally a keyword. For a symbol to be used a color, it must be associated with a color spec, either directly or via another symbol. Symbols that are used as colors are looked up in a color database. The LispWorks image is supplied with a large color database already loaded (approximately 660 entries), and you can add your own entries using define-color-alias or by loading your own color database.
The LispWorks Color System allows you to:
-
Make your own color specs in RGB, HSV or GRAY color models, and access components of color specs. See Color specs.
-
Define new association between symbols and colors, query which association exist, and find the color spec associated with a symbol. See Color aliases.
-
Convert color specs between color models. See Color models.
-
Load a color database from a file of color descriptions. See Loading the color database.
-
Define new color models. See Defining new color models.
The Color System symbols are exported from the COLOR package, and all symbols mentioned in this chapter are assumed to be external to this package unless otherwise stated.
CAPI User Guide and Reference Manual (Unix version) - 3 Aug 2017