/[cl-colors]/introduction.txt
ViewVC logotype

Contents of /introduction.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Mon Aug 13 14:00:13 2007 UTC (6 years, 8 months ago) by tpapp
File MIME type: text/plain
File size: 1785 byte(s)
added introduction
1 Color classes
2 -------------
3
4 The two main color classes are rgb and hsv, which have slots red,
5 green, blue and hue, saturation, value respectively. There is also an
6 rgb class with an alpha channel (slot alpha) called rgba. In the rgb
7 class, valid slot values are from 0 to 1, while in the hsv class,
8 saturation and value are in the interval [0,1], but hue is in [0,360).
9
10 You can convert between rgb and hsv using rgb->hsv and hsv->rgb. Note
11 that for the former, you need to specify what happens when the hue is
12 undefined (ie the color is gray). By default, the hue of red (0) is
13 assigned.
14
15 Generic functions which find the appropriate conversion method are
16 available with names ->rgb and ->hsv. Use these if you want your
17 functions to handle various different color representations but
18 eventually you need to work with a single one.
19
20
21
22 Named colors
23 ------------
24
25 Named colors, parsed from the X11 colors file, are loaded from
26 colornames.lisp. As they are constants, names are between +'s. All
27 named colors are rgb.
28
29
30
31 Convex combinations
32 -------------------
33
34 Use hsv-combination or rgb-combination for taking convex combinations
35 in the respective color space. Note that in the HSV space, you need
36 to specify the direction on the color wheel, the default is positive.
37
38
39 Example session
40 ---------------
41
42 CL-COLORS> +blue+
43 #<RGB red: 0.0d0 green: 0.0d0 blue: 1.0d0>
44 CL-COLORS> (->hsv +blue+)
45 #<HSV hue: 240.0d0 saturation: 1.0d0 value: 1.0d0>
46 CL-COLORS> (rgb-combination +blue+ +green+ 0.5)
47 #<RGB red: 0.0d0 green: 0.5d0 blue: 0.5d0>
48 CL-COLORS> (->rgb (hsv-combination (->hsv +blue+) (->hsv +green+) 0.5))
49 #<RGB red: 1.0d0 green: 0.0d0 blue: 0.0d0>
50 CL-COLORS> (->rgb (hsv-combination (->hsv +blue+) (->hsv +green+) 0.5 nil))
51 #<RGB red: 0.0d0 green: 1.0d0 blue: 1.0d0>
52

  ViewVC Help
Powered by ViewVC 1.1.5