summaryrefslogtreecommitdiff
path: root/color.lisp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2023-07-24 00:09:53 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2023-07-24 00:09:53 -0300
commitbb4b2bc484ed1d827d707a5a50b234d6994af90c (patch)
tree832ec90bf0f34252447c3fd49311d3af3e319d56 /color.lisp
parent3d6e80b447ef96cdac3aada1f2ca08073648294f (diff)
downloadutils-bb4b2bc484ed1d827d707a5a50b234d6994af90c.tar.gz
utils-bb4b2bc484ed1d827d707a5a50b234d6994af90c.zip
Add char, color and name transformersHEADmain
Diffstat (limited to 'color.lisp')
-rw-r--r--color.lisp28
1 files changed, 28 insertions, 0 deletions
diff --git a/color.lisp b/color.lisp
new file mode 100644
index 0000000..d9ed800
--- /dev/null
+++ b/color.lisp
@@ -0,0 +1,28 @@
+(in-package #:color)
+
+(defun hsl->rgb (h s l)
+ (let* ((c (* (- 1 (abs (- (* 2 l) 1))) s))
+ (x (* c (- 1 (abs (- (mod (/ h 60) 2) 1)))))
+ (m (- l (/ c 2)))
+ (r m)
+ (g m)
+ (b m))
+ (cond ((<= 0 h 59)
+ (incf r c)
+ (incf g x))
+ ((<= 60 h 119)
+ (incf r x)
+ (incf g c))
+ ((<= 120 h 179)
+ (incf g c)
+ (incf b x))
+ ((<= 180 239)
+ (incf g x)
+ (incf b c))
+ ((<= 240 299)
+ (incf r x)
+ (incf b c))
+ ((<= 300 359)
+ (incf r c)
+ (incf b x)))
+ (values r g b)))