aboutsummaryrefslogtreecommitdiff
path: root/module/util/color.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-24 20:34:11 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-24 20:34:11 +0200
commitd3afa54144748685d12c159407194e03538e98de (patch)
tree7a260d6ed4e52e2e1c72729a0922551e3790ba97 /module/util/color.scm
parent. (diff)
downloadcalp-d3afa54144748685d12c159407194e03538e98de.tar.gz
calp-d3afa54144748685d12c159407194e03538e98de.tar.xz
Move util modules into calp module..
Diffstat (limited to 'module/util/color.scm')
-rw-r--r--module/util/color.scm22
1 files changed, 0 insertions, 22 deletions
diff --git a/module/util/color.scm b/module/util/color.scm
deleted file mode 100644
index 7b6dacec..00000000
--- a/module/util/color.scm
+++ /dev/null
@@ -1,22 +0,0 @@
-(define-module (util color)
- )
-
-;; Returns a color with good contrast to the given background color.
-;; https://stackoverflow.com/questions/1855884/determine-font-color-based-on-background-color/1855903#1855903
-(define-public (calculate-fg-color c)
- (catch #t
- (lambda ()
- (define (str->num c n) (string->number (substring/shared c n (+ n 2)) 16))
- ;; (format (current-error-port) "COLOR = ~s~%" c)
- (let ((r (str->num c 1))
- (g (str->num c 3))
- (b (str->num c 5)))
- (if (< 1/2 (/ (+ (* 0.299 r)
- (* 0.587 g)
- (* 0.114 b))
- #xFF))
- "#000000" "#FFFFFF")))
- (lambda args
- (format (current-error-port) "Error calculating foreground color?~%~s~%" args)
- "#FF0000"
- )))