introduction.txt 1.7 KB

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