All Manuals > CLIM 2.0 User Guide > 5 Drawing in Color

5.1 Conceptual Overview of Drawing With Color

This chapter describes the :ink drawing option and the simpler values that can be supplied for that option, such as colors.

To draw in color, you supply the :ink drawing option to CLIM's drawing functions (see Chapter 2, "Drawing Graphics in CLIM," for details). :ink can take as its value:

The drawing functions work by selecting a region of the drawing plane and painting it with color. The region is clipped by the current :clipping-region drawing option in effect, and is then transformed by the current :transformation drawing option (see 3 The CLIM Drawing Environment for the rules controlling these options). The shape can be a graphical area (such as a rectangle or an ellipse), a path (such as a line segment or the outline of an ellipse), or the letter forms of text. Any viewports or dataports attached to this drawing plane are updated accordingly. The :ink drawing option is never affected by the :transformation drawing option nor by the sheet transformation; this ensures that stipple patterns on adjacent sheets join seamlessly.

Along with its drawing plane, a medium has a foreground and a background. The foreground is the default ink when the :ink drawing option is not specified. The background is drawn all over the drawing plane before any output is drawn. You can erase by drawing the background over the region to be erased. You can change the foreground or background at any time. This changes the contents of the drawing plane. The effect is as if everything on the drawing plane is erased, the background is drawn on the entire drawing plane, and then everything that was ever drawn (provided it was saved in the output history) is redrawn using the new foreground and background.

5.1.1 Color Objects

A color in CLIM is an object representing the intuitive definition of color: white, black, red, pale yellow, and so forth. The visual appearance of a single point is completely described by its color.

A color can be specified by three real numbers between 0 and 1 inclusive, giving the amounts of red, green, and blue. Three 0's mean black; three 1's mean white. A color can also be specified by three numbers giving the intensity, hue, and saturation. A totally unsaturated color (a shade of gray) can be specified by a single real number between 0 and 1, giving the amount of white.

You can obtain a color object by calling one of make-rgb-color, make-ihs-color, or make-gray-color, or by using one of the predefined colors listed in 5.3 Predefined Color Names in LispWorks CLIM or . Specifying a color object as the :ink drawing option, the foreground, or the background causes CLIM to use that color in the appropriate drawing operations.

color Protocol Class

Summary: The color class is the protocol class for a color. If you want to create a new class that behaves like a color, it should be a subclass of color. Subclasses of color must obey the color protocol.

All of the standard instantiable color classes provided by CLIM are immutable.

colorp Function

colorp object

Summary: Returns t if object is a color; otherwise, it returns nil.

5.1.2 Rendering

When CLIM renders the graphics and text in the drawing plane onto a real display device, physical limitations of the display device force the visual appearance to be an approximation of the drawing plane. Colors that the hardware does not support might be approximated by using a different color or by using a stipple pattern. Even primary colors such as red and green can't be guaranteed to have distinct visual appearance on all devices, so if device independence is desired, it is best to use make-contrasting-inks (which produces designs of different appearances) rather than a fixed palette of colors.

The line style and text style respectively control the region of the display device that is colored when a path or text is rendered.


CLIM 2.0 User Guide - 01 Dec 2021 19:38:57