RSS Feed

Lisp Project of the Day

simple-rgb

You can support this project by donating at:

Donate using PatreonDonate using Liberapay

Or see the list of project sponsors.

simple-rgbgraphics

Documentation😀
Docstrings😀
Tests 🥺
Examples🥺
RepositoryActivity🥺
CI 🥺

Two days ago I wrote about Dufy - the color manipulation library. While preparing that post, I found another library which is more practical if you need to work only with RGB.

It is able to convert to and from string representation and has some function for color manipulation.

For example, it has a builtin function similar to the one I wrote in the post about Dufy:

POFTHEDAY> (simple-rgb:parse "#F4BBFF")
#(244 187 255)

POFTHEDAY> (simple-rgb:darken-rgb * :alpha 0.25)
#(183 140 191)

POFTHEDAY> (simple-rgb:xmlify-rgb *)
"#B78CBF"

The result is the same:

Original (#F4BBFF)
Darker (#B78CBF)

Also, there are other functions for color manipulation:

POFTHEDAY> (flet ((h (c)
                    (simple-rgb:xmlify-rgb c)))
             (let ((color (simple-rgb:parse "#F4BBFF")))
               (list
                :original (h color)
                :grayscale (h (simple-rgb:greyscale-rgb color))
                :complement (h (simple-rgb:complement-rgb color))
                :inverted (h (simple-rgb:invert-rgb color))
                :contrasted (h (simple-rgb:contrast-rgb color))
                :lighter (h (simple-rgb:lighten-rgb color))
                :darker (h (simple-rgb:darken-rgb color))
                :greener (h (simple-rgb:mix-rgb
                             color
                             (simple-rgb:parse "#00FF00")
                             :alpha 0.25)))))
(:ORIGINAL "#F4BBFF"
 :GRAYSCALE "#D4D4D4"
 :COMPLEMENT "#C6FFBB"
 :INVERTED "#0B4400"
 :CONTRASTED "#FFFFFF"
 :LIGHTER "#FADDFF"
 :DARKER "#7A5E80"
 :GREENER "#B7CCBF")
ORIGINAL (#F4BBFF)
GRAYSCALE (#D4D4D4)
COMPLEMENT (#C6FFBB)
INVERTED (#0B4400)
CONTRASTED (#FFFFFF)
LIGHTER (#FADDFF)
DARKER (#7A5E80)
GREENER (#B7CCBF)

So, if want just to play with RGB colors, this library is exactly what you need!


Brought to you by 40Ants under Creative Commons License