NextPrevUpTopContentsIndex

13.7 Defining new color models

Before using the definition described here, you should evaluate the form:

(require "color-defmodel")

The macro define-color-models can be used to define new color models for use in the color system.

The default color models are defined by the following form:

(define-color-models ((:rgb (red 0.0 1.0) 
                            (green 0.0 1.0) 
                            (blue 0.0 1.0))
                      (:hsv (hue 0.0 5.99999)
                            (saturation 0.0 1.0) 
                            (value 0.0 1.0)) 
                      (:gray (level 0.0 1.0))))

For example, to define a new color model YMC and keep the existing RGB, HSV and GRAY models:

(define-color-models ((:rgb (red 0.0 1.0) 
                            (green 0.0 1.0) 
                            (blue 0.0 1.0))
                      (:hsv (hue 0.0 5.99999)
                            (saturation 0.0 1.0) 
                            (value 0.0 1.0)) 
                      (:gray (level 0.0 1.0))
                      (:ymc (yellow 0.0 1.0) 
                            (magenta 0.0 1.0) 
                            (cyan 0.0 1.0))))

You must then define some functions to convert YMC color-specs to other color-specs. In this example, those functions are named

make-ymc-from-rgb
make-ymc-from-hsv
make-ymc-from-gray

and

make-rgb-from-ymc
make-hsv-from-ymc
make-gray-from-ymc

You can make this easier, of course, by defining the functions

make-ymc-from-hsv
make-ymc-from-gray
make-hsv-from-ymc
make-gray-from-ymc

in terms of make-ymc-from-rgb and make-rgb-from-ymc .

If you never convert between YMC and any other model, you need only define the function make-rgb-from-ymc .


LispWorks CAPI User Guide (Unix version) - 17 Mar 2008

NextPrevUpTopContentsIndex