Generated: May 24, 2003, 13:22:58Copyright ©2003, Kurt NørmarkThe local LAML software home page

Reference Manual of the Color Library

Kurt Nørmark ©    normark@cs.auc.dk    Department of Computer Science    Aalborg University    Denmark    

Master index
Source file: lib/color.scm
LAML Version 20.00 (May 24, 2003, full)

A library which contains the basic of handling colors in LAML. The library has encoding functions that convert rgb color lists, such as (rgb-color 255 255 255) and (255 255 255) to a strings, such as "#ffffff". The primary color encoding function is rgb-color-encoding. The primary color representation function is make-rgb-color, which is accompanied by the color predicate rgb-color? a the color selectors red-of-rgb-color, green-of-rgb-color, and blue-of-rgb-color.

Of historical reasons we support two representation of colors. The first - the old representation - is just a list of red, green, blue numbers (positive integers between 0 and 255), such as (255 0 255). The other is a tagged list of red, green, blue values such as (rgb-color 255 0 255), where rgb-color is the tag symbol. Please be aware of the two different representations when you use this library.

The library also contains a set of color constants, all bound to the old color format (of backward compatibility reasons).

Table of Contents:
1. Primary color encoding function.3. Color constructor, predicate, and selectors.
2. Secondary color encoding functions.4. Color constants.

Alphabetic index:
aquaaquaA color constant.
blackblackA color constant.
blueblueA color constant.
blue-of-rgb-color(blue-of-rgb-color color)Return the blue constituent of the color.
blue1blue1A color constant.
blue2blue2A color constant.
blue3blue3A color constant.
brownbrownA color constant.
dark-reddark-redA color constant.
dark-yellowdark-yellowA color constant.
fuchsiafuchsiaA color constant.
greengreenA color constant.
green-of-rgb-color(green-of-rgb-color color)Return the green constituent of the color.
green1green1A color constant.
green2green2A color constant.
greygreyA color constant.
grey1grey1A color constant.
grey2grey2A color constant.
light-bluelight-blueA color constant.
limelimeA color constant.
make-color(make-color r g b)Make and return the rgb-list representation of the color with r red, g green, and b blue.
make-rgb-color(make-rgb-color r g b)Make and return a color represented by a red, green and blue constituent.
maroonmaroonA color constant.
navynavyA color constant.
oliveoliveA color constant.
orangeorangeA color constant.
purplepurpleA color constant.
redredA color constant.
red-of-rgb-color(red-of-rgb-color color)Return the red constituent of the LAML color.
rgb-color(rgb-color r g b)Return an 'Internet color string" encoding the colors r, g, and b.
rgb-color-encoding(rgb-color-encoding . color-pars)Return a color encoding (a string of length seven such as "#123456") of color-pars.
rgb-color-list(rgb-color-list color-triple-list)Returns the color encoding of (list r g b) given a list of three color numbers as parameter.
rgb-color?(rgb-color? x)Is x a LAML color
silversilverA color constant.
tetaltetalA color constant.
whitewhiteA color constant.
yellowyellowA color constant.

 

1.   PRIMARY COLOR ENCODING FUNCTION.
The function in this section, rgb-color-encoding, accepts a variety of different color formats as input. It returns a string of length seven, such as "#ff00ff". The output format is the primary color representation in most web contexts.


rgb-color-encoding


Form
(rgb-color-encoding . color-pars)

Description
Return a color encoding (a string of length seven such as "#123456") of color-pars. The color-pars parameter(s) to this function are very versatile.

If it is a color encoding string already, just return it.
If it is a color value which satisfies the predicate rgb-color?, return the encoding of this value.
If it is a symbol, return the color encoding bound to it.
If it is a string, transform it to a symbol and return the color encoding bound to it.
If it is a list like (list 1 2 3), consider it as a red-green-blue list, and return the color encoding of it.
If it is three individiual parameters, say r, g, and b, return the color encoding of red r, green g, and blue b.

If you care about efficiency, use can consider to use the function rgb-string instead of rgb-color-encoding.


Returns
A string of length 7 of the format "#rrggbb".

Example
(rgb-color-encoding "red")

Example
(rgb-color-encoding 255 0 0)

Example
(rgb-color-encoding (make-rgb-color 255 0 0))

Example
(rgb-color-encoding '(255 0 0))

Example
(rgb-color-encoding (make-color 255 0 0))

Example
(rgb-color-encoding "#ff0000")

Example
(rgb-color-encoding 'red)

See also
more efficient functionsrgb-color    rgb-color-list    


 

2.   SECONDARY COLOR ENCODING FUNCTIONS.
The functions in this section only work with the old version of the color representation. This is the untagged list representation, such as '(255 0 0).

For new development, the function make-rgb-color should be used together with the color encoding function rgb-color-encoding.


rgb-color


Form
(rgb-color r g b)

Description
Return an 'Internet color string" encoding the colors r, g, and b.

Parameters
rThe amount of red - a decimal number between 0 and 255.
gThe amount of green - a decimal number between 0 and 255.
bThe amount of blue - a decimal number between 0 and 255.

Returns
A string of length 7 of the form "#rrggbb".


rgb-color-list


Form
(rgb-color-list color-triple-list)

Description
Returns the color encoding of (list r g b) given a list of three color numbers as parameter.

Parameters
color-triple-listA list of length 3. Each element of the list is a decimal integer between 0 and 255.

Returns
A string of length 7 of the form "#rrggbb".


 

3.   COLOR CONSTRUCTOR, PREDICATE, AND SELECTORS.
The function make-rgb-color is the primary color constructor in LAML-based software. The predidate and the selectors only work with make-rgb-color. The function make-color is an old version of the constructor.


make-rgb-color


Form
(make-rgb-color r g b)

Description
Make and return a color represented by a red, green and blue constituent. This is the primary color constructor of LAML-based software.

Parameters
rThe amount of red - a decimal number between 0 and 255.
gThe amount of green - a decimal number between 0 and 255.
bThe amount of blue - a decimal number between 0 and 255.

Returns
A tagged list of color numbers.

Example
(rgb-color-encoding (make-rgb-color 255 0 0)) => "#ff0000"

Example
(make-rgb-color 255 0 0) => (rgb-color 255 0 0)

See also
conversion functionrgb-color-encoding    


rgb-color?


Form
(rgb-color? x)

Description
Is x a LAML color


red-of-rgb-color


Form
(red-of-rgb-color color)

Description
Return the red constituent of the LAML color.

Parameters
colorA color constructed with make-rgb-color.

See also
color constructormake-rgb-color    


green-of-rgb-color


Form
(green-of-rgb-color color)

Description
Return the green constituent of the color.

Parameters
colorA color constructed with make-rgb-color.

See also
color constructormake-rgb-color    


blue-of-rgb-color


Form
(blue-of-rgb-color color)

Description
Return the blue constituent of the color.

Parameters
colorA color constructed with make-rgb-color.

See also
color constructormake-rgb-color    


make-color


Form
(make-color r g b)

Description
Make and return the rgb-list representation of the color with r red, g green, and b blue. This is an old version of the color contructor.

Note
Deprecated. Use make-rgb-color.


 

4.   COLOR CONSTANTS.
To stay backward compatible with a substantial amount of older LAML software, all color constants are bound to the old LAML color representation. Thus, for instance, the value of red is (255 0 0), and not (rgb-color 255 0 0). As an important observation, the primary color encoding function, rgb-color-encoding, accepts the value of the color constants as input (besides a number of other kinds of input).


red


Form
red

Description
A color constant. A color is represented as a list of integers of length three (rgb).


dark-red


Form
dark-red

Description
A color constant. A color is represented as a list of integers of length three (rgb).


green


Form
green

Description
A color constant. A color is represented as a list of integers of length three (rgb).


green1


Form
green1

Description
A color constant. A color is represented as a list of integers of length three (rgb).


green2


Form
green2

Description
A color constant. A color is represented as a list of integers of length three (rgb).


blue


Form
blue

Description
A color constant. A color is represented as a list of integers of length three (rgb).


white


Form
white

Description
A color constant. A color is represented as a list of integers of length three (rgb).


black


Form
black

Description
A color constant. A color is represented as a list of integers of length three (rgb).


yellow


Form
yellow

Description
A color constant. A color is represented as a list of integers of length three (rgb).


purple


Form
purple

Description
A color constant. A color is represented as a list of integers of length three (rgb).


light-blue


Form
light-blue

Description
A color constant. A color is represented as a list of integers of length three (rgb).


blue1


Form
blue1

Description
A color constant. A color is represented as a list of integers of length three (rgb).


blue2


Form
blue2

Description
A color constant. A color is represented as a list of integers of length three (rgb).


blue3


Form
blue3

Description
A color constant. A color is represented as a list of integers of length three (rgb).


orange


Form
orange

Description
A color constant. A color is represented as a list of integers of length three (rgb).


dark-yellow


Form
dark-yellow

Description
A color constant. A color is represented as a list of integers of length three (rgb).


grey1


Form
grey1

Description
A color constant. A color is represented as a list of integers of length three (rgb).


grey2


Form
grey2

Description
A color constant. A color is represented as a list of integers of length three (rgb).


brown


Form
brown

Description
A color constant. A color is represented as a list of integers of length three (rgb).


maroon


Form
maroon

Description
A color constant. A color is represented as a list of integers of length three (rgb).


grey


Form
grey

Description
A color constant. A color is represented as a list of integers of length three (rgb).


silver


Form
silver

Description
A color constant. A color is represented as a list of integers of length three (rgb).


tetal


Form
tetal

Description
A color constant. A color is represented as a list of integers of length three (rgb).


aqua


Form
aqua

Description
A color constant. A color is represented as a list of integers of length three (rgb). A color constant. A color is represented as a list of integers of length three (rgb).


lime


Form
lime

Description
A color constant. A color is represented as a list of integers of length three (rgb). A color constant. A color is represented as a list of integers of length three (rgb).


olive


Form
olive

Description
A color constant. A color is represented as a list of integers of length three (rgb).


navy


Form
navy

Description
A color constant. A color is represented as a list of integers of length three (rgb).


fuchsia


Form
fuchsia

Description
A color constant. A color is represented as a list of integers of length three (rgb).


Generated: May 24, 2003, 13:22:58
This documentation has been extracted automatically from the Scheme source file by means of the Schemedoc tool