All Manuals > CAPI User Guide > 14 The Color System

NextPrevUpTopContentsIndex

14.1 Introduction

The LispWorks Color System allows applications to use keyword symbols as aliases for colors in Graphics Ports drawing functions. They can also be used for backgrounds and foregrounds of windows and CAPI objects.

For example, the call

(gp:draw-line my-port x1 y1 x2 y2 
    :foreground :navyblue)

uses the keyword symbol :navyblue for the color of the line.

Colors are looked up in a color database. The LispWorks image is delivered with a large color database already loaded (approximately 660 entries.) The color database contains color-specs which define the colors in terms of a standard color model. When the drawing function is executed, the color-spec is converted into a colormap index (or "pixel" value).

The LispWorks Color System has facilities for:

It is accessible from the color package, and all symbols mentioned in this chapter are assumed to be external to this package unless otherwise stated. You can qualify them all explicitly in your code, for example color:apropos-color-names .

However it is more convenient to create a package which has the color package on its package-use-list:

(defpackage "MY-PACKAGE"
	(:add-use-defaults t)
	(:use "COLOR" "CAPI") 
)

This creates a package in which all the color symbols (and for convenience, capi as well) are accessible. To run the examples in this chapter, evaluate the form above and then:

(in-package "MY-PACKAGE")

The color-models available by default are RGB, HSV and GRAY.

14.1.1 Rendering of colors


CAPI User Guide (Macintosh version) - 30 Aug 2011

NextPrevUpTopContentsIndex