diff options
author | Simen Heggestøyl <simenheg@gmail.com> | 2017-09-07 20:40:12 +0200 |
---|---|---|
committer | Simen Heggestøyl <simenheg@gmail.com> | 2017-09-13 20:23:44 +0200 |
commit | e7d6c622090dd2f4c77fbd04aba89c30a75514dd (patch) | |
tree | 775683d9e552e7add0e29ea01057aebfd62d0693 /lisp | |
parent | 63398071471f6cd6b006d3c35d2d83c597549e4a (diff) | |
download | emacs-e7d6c622090dd2f4c77fbd04aba89c30a75514dd.tar.gz |
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.el | 8 |
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 @@ (defun color-name-to-rgb (color &optional frame) "Convert COLOR string to a list of normalized RGB components. COLOR should be a color name (e.g. \"white\") or an RGB triplet -string (e.g. \"#ff12ec\"). +string (e.g. \"#ffff1122eecc\"). Normally the return value is a list of three floating-point numbers, (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." (defun color-complement (color-name) "Return the color that is the complement of COLOR-NAME. COLOR-NAME should be a string naming a color (e.g. \"white\"), or -a string specifying a color's RGB components (e.g. \"#ff12ec\")." +a string specifying a color's RGB +components (e.g. \"#ffff1212ecec\")." (let ((color (color-name-to-rgb color-name))) (list (- 1.0 (nth 0 color)) (- 1.0 (nth 1 color)) @@ -178,7 +179,8 @@ each element is between 0.0 and 1.0, inclusive." ((= r max) (- bc gc)) ((= g max) (+ 2.0 rc (- bc))) (t (+ 4.0 gc (- rc)))) - 6.0) 1.0))) + 6.0) + 1.0))) (list h s l))))) (defun color-srgb-to-xyz (red green blue) |