git.fiddlerwoaroof.com
Browse code

feat: make hex->color always available

Ed Langley authored on 01/05/2020 22:07:32
Showing 1 changed files
... ...
@@ -337,22 +337,23 @@
337 337
                                    :solarized-magenta))
338 338
 
339 339
 
340
-(defun hex->color (hex)
341
-  (declare (optimize (speed 3) (safety 1) (debug 1)))
342
-  (check-type hex (string 7))
343
-  (flet ((extract-digits (string start end)
344
-           (check-type string (simple-string 7))
345
-           (parse-integer string
346
-                          :start start
347
-                          :end end
348
-                          :radix 16)))
349
-    (let* ((hex (coerce hex 'simple-string))
350
-           (r (extract-digits hex 1 3))
351
-           (g (extract-digits hex 3 5))
352
-           (b (extract-digits hex 5 7)))
353
-      (color:make-rgb (/ r 255.0)
354
-                      (/ g 255.0)
355
-                      (/ b 255.0)))))
340
+(eval-when (:compile-toplevel :load-toplevel :execute)
341
+  (defun hex->color (hex)
342
+    (declare (optimize (speed 3) (safety 1) (debug 1)))
343
+    (check-type hex (string 7))
344
+    (flet ((extract-digits (string start end)
345
+             (check-type string (simple-string 7))
346
+             (parse-integer string
347
+                            :start start
348
+                            :end end
349
+                            :radix 16)))
350
+      (let* ((hex (coerce hex 'simple-string))
351
+             (r (extract-digits hex 1 3))
352
+             (g (extract-digits hex 3 5))
353
+             (b (extract-digits hex 5 7)))
354
+        (color:make-rgb (/ r 255.0)
355
+                        (/ g 255.0)
356
+                        (/ b 255.0))))))
356 357
 
357 358
 (eval-when (:compile-toplevel :load-toplevel :execute)
358 359
   (defparameter +zenburn-colors+