aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorSimen Heggestøyl2017-09-07 20:40:12 +0200
committerSimen Heggestøyl2017-09-13 20:23:44 +0200
commite7d6c622090dd2f4c77fbd04aba89c30a75514dd (patch)
tree775683d9e552e7add0e29ea01057aebfd62d0693 /lisp
parent63398071471f6cd6b006d3c35d2d83c597549e4a (diff)
downloademacs-e7d6c622090dd2f4c77fbd04aba89c30a75514dd.tar.gz
emacs-e7d6c622090dd2f4c77fbd04aba89c30a75514dd.zip
Add tests for color.el
* lisp/color.el (color-name-to-rgb, color-complement): Clarify in docstrings that RGB triplets should use four digits per component. (color-rgb-to-hsl): Break line to avoid "Hidden behind deeper element" warning. * test/lisp/color-tests.el: New file.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/color.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/lisp/color.el b/lisp/color.el
index 22b6808c87f..e22b3cf0f6e 100644
--- a/lisp/color.el
+++ b/lisp/color.el
@@ -42,7 +42,7 @@
42(defun color-name-to-rgb (color &optional frame) 42(defun color-name-to-rgb (color &optional frame)
43 "Convert COLOR string to a list of normalized RGB components. 43 "Convert COLOR string to a list of normalized RGB components.
44COLOR should be a color name (e.g. \"white\") or an RGB triplet 44COLOR should be a color name (e.g. \"white\") or an RGB triplet
45string (e.g. \"#ff12ec\"). 45string (e.g. \"#ffff1122eecc\").
46 46
47Normally the return value is a list of three floating-point 47Normally the return value is a list of three floating-point
48numbers, (RED GREEN BLUE), each between 0.0 and 1.0 inclusive. 48numbers, (RED GREEN BLUE), each between 0.0 and 1.0 inclusive.
@@ -68,7 +68,8 @@ or 2; use the latter if you need a 24-bit specification of a color."
68(defun color-complement (color-name) 68(defun color-complement (color-name)
69 "Return the color that is the complement of COLOR-NAME. 69 "Return the color that is the complement of COLOR-NAME.
70COLOR-NAME should be a string naming a color (e.g. \"white\"), or 70COLOR-NAME should be a string naming a color (e.g. \"white\"), or
71a string specifying a color's RGB components (e.g. \"#ff12ec\")." 71a string specifying a color's RGB
72components (e.g. \"#ffff1212ecec\")."
72 (let ((color (color-name-to-rgb color-name))) 73 (let ((color (color-name-to-rgb color-name)))
73 (list (- 1.0 (nth 0 color)) 74 (list (- 1.0 (nth 0 color))
74 (- 1.0 (nth 1 color)) 75 (- 1.0 (nth 1 color))
@@ -178,7 +179,8 @@ each element is between 0.0 and 1.0, inclusive."
178 ((= r max) (- bc gc)) 179 ((= r max) (- bc gc))
179 ((= g max) (+ 2.0 rc (- bc))) 180 ((= g max) (+ 2.0 rc (- bc)))
180 (t (+ 4.0 gc (- rc)))) 181 (t (+ 4.0 gc (- rc))))
181 6.0) 1.0))) 182 6.0)
183 1.0)))
182 (list h s l))))) 184 (list h s l)))))
183 185
184(defun color-srgb-to-xyz (red green blue) 186(defun color-srgb-to-xyz (red green blue)