Next: , Previous: Color, Up: Color


5.11.1 Color Data-Type

(require 'color)

— Function: color? obj

Returns #t if obj is a color.

— Function: color? obj typ

Returns #t if obj is a color of color-space typ. The symbol typ must be one of:

— Function: make-color space arg ...

Returns a color of type space.

— Function: color-space color

Returns the symbol for the color-space in which color is embedded.

— Function: color-precision color

For colors in digital color-spaces, color-precision returns the number of bits used for each of the R, G, and B channels of the encoding. Otherwise, color-precision returns #f

— Function: color-white-point color

Returns the white-point of color in all color-spaces except CIEXYZ.

— Function: convert-color color space white-point
— Function: convert-color color space
— Function: convert-color color e-sRGB precision

Converts color into space at optional white-point.

5.11.1.1 External Representation

Each color encoding has an external, case-insensitive representation. To ensure portability, the white-point for all color strings is D65. 1

Color Space External Representation
CIEXYZ CIEXYZ:<X>/<Y>/<Z>
RGB709 RGBi:<R>/<G>/<B>
L*a*b* CIELAB:<L>/<a>/<b>
L*u*v* CIELuv:<L>/<u>/<v>
L*C*h CIELCh:<L>/<C>/<h>

The X, Y, Z, L, a, b, u, v, C, h, R, G, and B fields are (Scheme) real numbers within the appropriate ranges.

Color Space External Representation
sRGB sRGB:<R>/<G>/<B>
e-sRGB10 e-sRGB10:<R>/<G>/<B>
e-sRGB12 e-sRGB12:<R>/<G>/<B>
e-sRGB16 e-sRGB16:<R>/<G>/<B>

The R, G, and B, fields are non-negative exact decimal integers within the appropriate ranges.

Several additional syntaxes are supported by string->color:

Color Space External Representation
sRGB sRGB:<RRGGBB>
sRGB #<RRGGBB>
sRGB 0x<RRGGBB>
sRGB #x<RRGGBB>

Where RRGGBB is a non-negative six-digit hexadecimal number.

— Function: color->string color

Returns a string representation of color.

— Function: string->color string

Returns the color represented by string. If string is not a syntactically valid notation for a color, then string->color returns #f.

5.11.1.2 White

We experience color relative to the illumination around us. CIEXYZ coordinates, although subject to uniform scaling, are objective. Thus other color spaces are specified relative to a white point in CIEXYZ coordinates. The white point for digital color spaces is set to D65. For the other spaces a white-point argument can be specified. The default if none is specified is the white-point with which the color was created or last converted; and D65 if none has been specified.

— Constant: D65

Is the color of 6500.K (blackbody) illumination. D65 is close to the average color of daylight.

— Constant: D50

Is the color of 5000.K (blackbody) illumination. D50 is the color of indoor lighting by incandescent bulbs, whose filaments have temperatures around 5000.K.


Footnotes

[1] Readers may recognize these color string formats from Xlib. X11's color management system was doomed by its fiction that CRT monitors' (and X11 default) color-spaces were linear RGBi. Unable to shed this legacy, the only practical way to view pictures on X is to ignore its color management system and use an sRGB monitor. In this implementation the device-independent RGB709 and sRGB spaces replace the device-dependent RGBi and RGB spaces of Xlib.