diff options
| author | Simen Heggestøyl | 2017-09-07 20:40:12 +0200 |
|---|---|---|
| committer | Simen Heggestøyl | 2017-09-13 20:23:44 +0200 |
| commit | e7d6c622090dd2f4c77fbd04aba89c30a75514dd (patch) | |
| tree | 775683d9e552e7add0e29ea01057aebfd62d0693 /lisp | |
| parent | 63398071471f6cd6b006d3c35d2d83c597549e4a (diff) | |
| download | emacs-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.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 @@ | |||
| 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. |
| 44 | COLOR should be a color name (e.g. \"white\") or an RGB triplet | 44 | COLOR should be a color name (e.g. \"white\") or an RGB triplet |
| 45 | string (e.g. \"#ff12ec\"). | 45 | string (e.g. \"#ffff1122eecc\"). |
| 46 | 46 | ||
| 47 | Normally the return value is a list of three floating-point | 47 | Normally the return value is a list of three floating-point |
| 48 | numbers, (RED GREEN BLUE), each between 0.0 and 1.0 inclusive. | 48 | 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." | |||
| 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. |
| 70 | COLOR-NAME should be a string naming a color (e.g. \"white\"), or | 70 | COLOR-NAME should be a string naming a color (e.g. \"white\"), or |
| 71 | a string specifying a color's RGB components (e.g. \"#ff12ec\")." | 71 | a string specifying a color's RGB |
| 72 | components (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) |