Generated: Monday, November 14, 2011, 09:17:53 Copyright © 2011 , Kurt Nørmark The local LAML software home page

Reference Manual of the Color Library

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

LAML Source file: lib/color.scm

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:
aqua aqua A color constant.
black black A color constant.
blue blue A color constant.
blue-of-rgb-color (blue-of-rgb-color color) Return the blue constituent of the color.
blue1 blue1 A color constant.
blue2 blue2 A color constant.
blue3 blue3 A color constant.
brown brown A color constant.
dark-red dark-red A color constant.
dark-yellow dark-yellow A color constant.
fuchsia fuchsia A color constant.
green green A color constant.
green-of-rgb-color (green-of-rgb-color color) Return the green constituent of the color.
green1 green1 A color constant.
green2 green2 A color constant.
grey grey A color constant.
grey1 grey1 A color constant.
grey2 grey2 A color constant.
light-blue light-blue A color constant.
lime lime A 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.
maroon maroon A color constant.
navy navy A color constant.
olive olive A color constant.
orange orange A color constant.
purple purple A color constant.
red red A 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
silver silver A color constant.
tetal tetal A color constant.
white white A color constant.
yellow yellow A 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-color instead of rgb-color-encoding.

Returns A string of length 7 of the format "#rrggbb".
Examples (rgb-color-encoding "red") => "#ff0000"
(rgb-color-encoding 'red) => "#ff0000"
(rgb-color-encoding "#ff0000") => "#ff0000"
(rgb-color-encoding (make-color 255 0 0)) => "#ff0000"
(rgb-color-encoding '(255 0 0)) => "#ff0000"
(rgb-color-encoding (make-rgb-color 255 0 0)) => "#ff0000"
(rgb-color-encoding 255 0 0) => "#ff0000"
See also Scheme source file rgb-color-encoding
more efficient functions rgb-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 r The amount of red - a decimal number between 0 and 255.
g The amount of green - a decimal number between 0 and 255.
b The amount of blue - a decimal number between 0 and 255.
Returns A string of length 7 of the form "#rrggbb".
Examples (rgb-color 1 2 3) => "#010203"
(rgb-color 10 11 12) => "#0a0b0c"
See also Scheme source file rgb-color

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-list A 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".
Examples (rgb-color-list (list 1 2 3)) => "#010203"
(rgb-color-list (list 10 11 12)) => "#0a0b0c"
See also Scheme source file rgb-color-list


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 r The amount of red - a decimal number between 0 and 255.
g The amount of green - a decimal number between 0 and 255.
b The amount of blue - a decimal number between 0 and 255.
Returns A tagged list of color numbers.
Examples (rgb-color-encoding (make-rgb-color 255 0 0)) => "#ff0000"
(make-rgb-color 1 2 3) => (rgb-color 1 2 3)
(red-of-rgb-color (make-rgb-color 1 2 3)) => 1
(green-of-rgb-color (make-rgb-color 1 2 3)) => 2
(blue-of-rgb-color (make-rgb-color 1 2 3)) => 3
(rgb-color? (make-rgb-color 1 2 3)) => #t
See also Scheme source file make-rgb-color
conversion function rgb-color-encoding

rgb-color?
Form (rgb-color? x)
Description Is x a LAML color
Examples (rgb-color? 1) => #f
(rgb-color? (make-rgb-color 1 2 3)) => #t
(rgb-color? (make-color 1 2 3)) => #f
See also Scheme source file rgb-color?

red-of-rgb-color
Form (red-of-rgb-color color)
Description Return the red constituent of the LAML color.
Parameters color A color constructed with make-rgb-color.
Examples (red-of-rgb-color (make-rgb-color 1 2 3)) => 1
See also Scheme source file red-of-rgb-color
color constructor make-rgb-color

green-of-rgb-color
Form (green-of-rgb-color color)
Description Return the green constituent of the color.
Parameters color A color constructed with make-rgb-color.
Examples (green-of-rgb-color (make-rgb-color 1 2 3)) => 2
See also Scheme source file green-of-rgb-color
color constructor make-rgb-color

blue-of-rgb-color
Form (blue-of-rgb-color color)
Description Return the blue constituent of the color.
Parameters color A color constructed with make-rgb-color.
Examples (blue-of-rgb-color (make-rgb-color 1 2 3)) => 3
See also Scheme source file blue-of-rgb-color
color constructor make-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.
Examples (rgb-color-encoding (make-color 255 0 0)) => "#ff0000"
(make-color 1 2 3) => (1 2 3)
(rgb-color? (make-color 1 2 3)) => #f
See also Scheme source file make-color
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).
See also Scheme source file red

dark-red
Form dark-red
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file dark-red

green
Form green
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file green

green1
Form green1
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file green1

green2
Form green2
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file green2

blue
Form blue
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file blue

white
Form white
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file white

black
Form black
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file black

yellow
Form yellow
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file yellow

purple
Form purple
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file purple

light-blue
Form light-blue
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file light-blue

blue1
Form blue1
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file blue1

blue2
Form blue2
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file blue2

blue3
Form blue3
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file blue3

orange
Form orange
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file orange

dark-yellow
Form dark-yellow
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file dark-yellow

grey1
Form grey1
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file grey1

grey2
Form grey2
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file grey2

brown
Form brown
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file brown

maroon
Form maroon
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file maroon

grey
Form grey
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file grey

silver
Form silver
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file silver

tetal
Form tetal
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file tetal

aqua
Form aqua
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file aqua

lime
Form lime
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file lime

olive
Form olive
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file olive

navy
Form navy
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file navy

fuchsia
Form fuchsia
Description A color constant. A color is represented as a list of integers of length three (rgb).
See also Scheme source file fuchsia

Generated: Monday, November 14, 2011, 09:17:54
Generated by LAML SchemeDoc using LAML Version 38.0 (November 14, 2011, full)