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

NextPrevUpTopContentsIndex

15.2 Color aliases

You can enter a color alias in the color database using the function define-color-alias. You can remove an entry in the color database using delete-color-translation.

define-color-alias makes an entry in the color database under a name, which should be a symbol. LispWorks by convention uses keyword symbols. The name points to either a color-spec or another color name (symbol):

(define-color-alias :wire-color :darkslategray)

Attempting to replace an existing color-spec in the color database results in an error. By default, replacement of existing aliases is allowed but there is an option to control this (see the manual page for define-color-alias).

delete-color-translation removes an entry from the color-database. Both original entries and aliases can be removed:

(delete-color-translation :wire-color)

As described in Color specs, the function get-color-spec returns the color-spec associated with a color alias. The function get-color-alias-translation returns the ultimate color name for an alias:

(define-color-alias :lispworks-blue 
            (make-rgb 0.70s0 0.90s0 0.99s0))
(define-color-alias :color-background 
                   :lispworks-blue)
(define-color-alias :listener-background 
                   :color-background)
(get-color-alias-translation :listener-background)
         => :lispworks-blue
(get-color-alias-translation :color-background)
         => :lispworks-blue

There is a system-defined color alias :transparent which is useful when specified as the background of a pane. It is currently supported only on Cocoa. For example:

(capi:popup-confirmer
 (make-instance 'capi:display-pane
                :text
                (format nil "The background of this pane~%is transparent")
                :background :transparent)  
 "")

To find out what colors are defined in the color database, use the function apropos-color-names. For example:

(apropos-color-names "RED") =>
 (:ORANGERED3 :ORANGERED1 :INDIANRED3 :INDIANRED1
  :PALEVIOLETRED :RED :INDIANRED :INDIANRED2
  :INDIANRED4 :ORANGERED :MEDIUMVIOLETRED 
  :VIOLETRED :ORANGERED2 :ORANGERED4 :RED1 :RED2 :RED3
  :RED4 :PALEVIOLETRED1 :PALEVIOLETRED2 :PALEVIOLETRED3
  :PALEVIOLETRED4 :VIOLETRED3 :VIOLETRED1 :VIOLETRED2
  :VIOLETRED4)

For information about only aliases or only original entries, use apropos-color-alias-names or apropos-color-spec-names respectively.

To get a list of all color names in the color database, call get-all-color-names.


CAPI User Guide and Reference Manual (Macintosh version) - 3 Aug 2017

NextPrevUpTopContentsIndex