Next: , Previous: , Up: Top   [Contents][Index]


4 Colors

Sawfish provides a primitive type allowing colors to be represented. Each color object allows a single color value to be named and passed between Lisp functions.

Function: colorp arg

Returns t when arg is a member of the color type.

Function: get-color name #!optional alpha

Returns the color object representing the color specified by the string name. This is according to the standard X11 color specifiers, either a named color from the rgb.txt database, or a string defining the red, green and blue components of the color, either eight or sixteen bits in hexadecimal, i.e. ‘#RRGGBB’ or ‘#RRRRGGGGBBBB’.

Optional argument alpha becomes the alpha value of the returned color. It is passed through to get-color-rgb.

Signals an error if no known color has the name name.

Function: get-color-rgb red green blue #!optional alpha

Return the color object representing the color with RGB components as specified (each component ranging from 0 to 65535).

Optional argument alpha becomes the alpha value of the returned color. Use an integer value in the range from 0 to 65535. Integers outside that range are not supported, while non-integers such as nil are silently converted to 65535 (fully opaque).

Given a color object, it’s possible to find both the actual rgb values defining the color and one of the names that X11 uses to refer to the color.

Function: color-rgb color

Return a list of integers (red green blue alpha), the actual color values of the color represented by object COLOR. The individual values range from 0 to 65535.

Function: color-rgb-8 color

Return a list of integers (red green blue alpha), just like color-rgb. However, the color values are scaled to fit a range from from 0 to 255.

Function: color-name color

Return the name of the color represented by the color object color. Note that this picks one name from the set of valid names for this color; it may well be different to the name used when the color was originally allocated.

The X11 name does not include alpha information.

Where a color object is used to define the foreground color of a piece of text, the default-foreground color provides the default value used if no actual color is specified.

Variable: default-foreground

The color used for text where no other color is defined.


Next: , Previous: , Up: Top   [Contents][Index]