cl-colors-ng
2026-11-29
Simple color library for Common Lisp
Upstream URL
Author
Maintainer
License
1cl-colors-ng: a simple color library for Common Lisp
This is a very simple color library for Common Lisp, providing:
- Types for representing colors in HSV, HSL and RGB(A) spaces.
- Simple conversion functions between the above types (and also hexadecimal representation for RGB(A)).
- Some predefined colors as an association list of names and symbolswhich are bound to a corresponding RGB value.
- X11 color names as
*x11-color-list* - SVG basic color namesas
*svg-colors-list* - SVG extended color names as
*svg-extended-colors-list* - Example:
- X11 color names as
'(("lightgreen" . +LIGHTGREEN+)
("light-green" . +LIGHT-GREEN+)
("darkred" . +DARKRED+)
…
1.1Examples
(let ((color1 (hsv 107 62/100 52/100)) ; greenish (default value for alpha is: 1)
(color2 (rgb 14/15 26/51 14/15)) ; = violet from X11
(color3 (as-rgb "ff9e00"))) ; from hexadecimal
(list ;
(as-rgb color1) ; converting to RGB
(rgb-combination color1 +blue+ 0.4) ; HSV autoconverted to RGB
(hsv-combination color2 +blue+ 0.4) ; RGB autoconverted to HSV
color3))
evaluates to:
(#S(RGB :RED 20059/75000 :GREEN 13/25 :BLUE 247/1250 :ALPHA 1)
#S(RGB :RED 0.160472 :GREEN 0.312 :BLUE 0.51856 :ALPHA 1)
#S(HSV :HUE 60.0 :SATURATION 0.6722689 :VALUE 0.96000004)
#S(RGB :RED 1 :GREEN 158/255 :BLUE 0 :ALPHA 1))
Observe the float contagion: cl-colors-ng functions don't care about the type of the numbers as long as they are a subtype of real and within the right range.
1.2Documentation
This library is so simple that it does not need a lot of documentation; please check the file introduction.org or just look at the docstring in colors.lisp.
1.3Testing
Run (ql:quickload :cl-colors-ng/tests).
1.4Regeneration of the X11 color names
Normally you should not need to do this, the sources already contain the autogenerated file colornames.lisp. However, if for some reason you need to regenerate this, you can use make. Even though the library itself does not depend on X11, regenerating this file will
require the appropriate file in X11.
1.5Bugs and issues
Please report them on codeberg.
2Notes
This is a fork of https://codeberg.org/cage/cl-colors2.