diff options
| author | Glenn Morris | 2012-10-05 00:17:23 -0700 |
|---|---|---|
| committer | Glenn Morris | 2012-10-05 00:17:23 -0700 |
| commit | d8788e1e6f06cc719c4348c407015338a59a2f05 (patch) | |
| tree | fd4c9d66d0fbbc2540bc5bc22465d62320484f63 | |
| parent | 677c110942b7016e35b9c9338b881ca4882c6fcf (diff) | |
| download | emacs-d8788e1e6f06cc719c4348c407015338a59a2f05.tar.gz emacs-d8788e1e6f06cc719c4348c407015338a59a2f05.zip | |
Doc fixes
* lisp/color.el (color-name-to-rgb, color-rgb-to-hex)
(color-hue-to-rgb, color-hsl-to-rgb, color-rgb-to-hsv)
(color-rgb-to-hsl, color-srgb-to-xyz, color-saturate-hsl)
(color-desaturate-hsl, color-desaturate-name, color-lighten-hsl)
(color-lighten-name, color-darken-hsl, color-darken-name): Doc fixes.
Fixes: debbugs:12558
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/color.el | 94 |
2 files changed, 46 insertions, 56 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c569b3c9f05..e38e06298d7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2012-10-05 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * color.el (color-name-to-rgb, color-rgb-to-hex) | ||
| 4 | (color-hue-to-rgb, color-hsl-to-rgb, color-rgb-to-hsv) | ||
| 5 | (color-rgb-to-hsl, color-srgb-to-xyz, color-saturate-hsl) | ||
| 6 | (color-desaturate-hsl, color-desaturate-name, color-lighten-hsl) | ||
| 7 | (color-lighten-name, color-darken-hsl, color-darken-name): Doc fixes. | ||
| 8 | |||
| 1 | 2012-10-04 Glenn Morris <rgm@gnu.org> | 9 | 2012-10-04 Glenn Morris <rgm@gnu.org> |
| 2 | 10 | ||
| 3 | * emacs-lisp/timer.el (with-timeout): Add missing progn. (Bug#12577) | 11 | * emacs-lisp/timer.el (with-timeout): Add missing progn. (Bug#12577) |
diff --git a/lisp/color.el b/lisp/color.el index 6ccf9a79494..39b172d1e55 100644 --- a/lisp/color.el +++ b/lisp/color.el | |||
| @@ -50,17 +50,17 @@ string (e.g. \"#ff12ec\"). | |||
| 50 | Normally the return value is a list of three floating-point | 50 | Normally the return value is a list of three floating-point |
| 51 | numbers, (RED GREEN BLUE), each between 0.0 and 1.0 inclusive. | 51 | numbers, (RED GREEN BLUE), each between 0.0 and 1.0 inclusive. |
| 52 | 52 | ||
| 53 | Optional arg FRAME specifies the frame where the color is to be | 53 | Optional argument FRAME specifies the frame where the color is to be |
| 54 | displayed. If FRAME is omitted or nil, use the selected frame. | 54 | displayed. If FRAME is omitted or nil, use the selected frame. |
| 55 | If FRAME cannot display COLOR, return nil." | 55 | If FRAME cannot display COLOR, return nil." |
| 56 | ;; `colors-values' maximum value is either 65535 or 65280 depending on the | 56 | ;; `colors-values' maximum value is either 65535 or 65280 depending on the |
| 57 | ;; display system. So we use a white conversion to get the max value. | 57 | ;; display system. So we use a white conversion to get the max value. |
| 58 | (let ((valmax (float (car (color-values "#ffffff"))))) | 58 | (let ((valmax (float (car (color-values "#ffffff"))))) |
| 59 | (mapcar (lambda (x) (/ x valmax)) (color-values color frame)))) | 59 | (mapcar (lambda (x) (/ x valmax)) (color-values color frame)))) |
| 60 | 60 | ||
| 61 | (defun color-rgb-to-hex (red green blue) | 61 | (defun color-rgb-to-hex (red green blue) |
| 62 | "Return hexadecimal notation for the color RED GREEN BLUE. | 62 | "Return hexadecimal notation for the color RED GREEN BLUE. |
| 63 | RED GREEN BLUE must be numbers between 0.0 and 1.0 inclusive." | 63 | RED, GREEN, and BLUE should be numbers between 0.0 and 1.0, inclusive." |
| 64 | (format "#%02x%02x%02x" | 64 | (format "#%02x%02x%02x" |
| 65 | (* red 255) (* green 255) (* blue 255))) | 65 | (* red 255) (* green 255) (* blue 255))) |
| 66 | 66 | ||
| @@ -76,7 +76,7 @@ a string specifying a color's RGB components (e.g. \"#ff12ec\")." | |||
| 76 | (defun color-gradient (start stop step-number) | 76 | (defun color-gradient (start stop step-number) |
| 77 | "Return a list with STEP-NUMBER colors from START to STOP. | 77 | "Return a list with STEP-NUMBER colors from START to STOP. |
| 78 | The color list builds a color gradient starting at color START to | 78 | The color list builds a color gradient starting at color START to |
| 79 | color STOP. It does not include the START and STOP color in the | 79 | color STOP. It does not include the START and STOP color in the |
| 80 | resulting list." | 80 | resulting list." |
| 81 | (let* ((r (nth 0 start)) | 81 | (let* ((r (nth 0 start)) |
| 82 | (g (nth 1 start)) | 82 | (g (nth 1 start)) |
| @@ -93,8 +93,8 @@ resulting list." | |||
| 93 | (nreverse result))) | 93 | (nreverse result))) |
| 94 | 94 | ||
| 95 | (defun color-hue-to-rgb (v1 v2 h) | 95 | (defun color-hue-to-rgb (v1 v2 h) |
| 96 | "Compute hue from V1 and V2 H. Internally used by | 96 | "Compute hue from V1 and V2 H. |
| 97 | `color-hsl-to-rgb'." | 97 | Used internally by `color-hsl-to-rgb'." |
| 98 | (cond | 98 | (cond |
| 99 | ((< h (/ 1.0 6)) (+ v1 (* (- v2 v1) h 6.0))) | 99 | ((< h (/ 1.0 6)) (+ v1 (* (- v2 v1) h 6.0))) |
| 100 | ((< h 0.5) v2) | 100 | ((< h 0.5) v2) |
| @@ -102,13 +102,10 @@ resulting list." | |||
| 102 | (t v1))) | 102 | (t v1))) |
| 103 | 103 | ||
| 104 | (defun color-hsl-to-rgb (H S L) | 104 | (defun color-hsl-to-rgb (H S L) |
| 105 | "Convert H S L (HUE, SATURATION, LUMINANCE) , where HUE is in | 105 | "Convert hue, saturation and luminance to their RGB representation. |
| 106 | radians and both SATURATION and LUMINANCE are between 0.0 and | 106 | H, S, and L should each be numbers between 0.0 and 1.0, inclusive. |
| 107 | 1.0, inclusive to their RGB representation. | 107 | Return a list (RED GREEN BLUE), where each element is between 0.0 and 1.0, |
| 108 | 108 | inclusive." | |
| 109 | Return a list (RED, GREEN, BLUE) which each be numbers between | ||
| 110 | 0.0 and 1.0, inclusive." | ||
| 111 | |||
| 112 | (if (= S 0.0) | 109 | (if (= S 0.0) |
| 113 | (list L L L) | 110 | (list L L L) |
| 114 | (let* ((m2 (if (<= L 0.5) | 111 | (let* ((m2 (if (<= L 0.5) |
| @@ -125,9 +122,9 @@ Return a list (RED, GREEN, BLUE) which each be numbers between | |||
| 125 | (apply 'color-rgb-to-hex (color-complement color))) | 122 | (apply 'color-rgb-to-hex (color-complement color))) |
| 126 | 123 | ||
| 127 | (defun color-rgb-to-hsv (red green blue) | 124 | (defun color-rgb-to-hsv (red green blue) |
| 128 | "Convert RED, GREEN, and BLUE color components to HSV. | 125 | "Convert RGB color components to HSV. |
| 129 | RED, GREEN, and BLUE should each be numbers between 0.0 and 1.0, | 126 | RED, GREEN, and BLUE should each be numbers between 0.0 and 1.0, |
| 130 | inclusive. Return a list (HUE, SATURATION, VALUE), where HUE is | 127 | inclusive. Return a list (HUE SATURATION VALUE), where HUE is |
| 131 | in radians and both SATURATION and VALUE are between 0.0 and 1.0, | 128 | in radians and both SATURATION and VALUE are between 0.0 and 1.0, |
| 132 | inclusive." | 129 | inclusive." |
| 133 | (let* ((r (float red)) | 130 | (let* ((r (float red)) |
| @@ -155,13 +152,10 @@ inclusive." | |||
| 155 | (/ max 255.0))))) | 152 | (/ max 255.0))))) |
| 156 | 153 | ||
| 157 | (defun color-rgb-to-hsl (red green blue) | 154 | (defun color-rgb-to-hsl (red green blue) |
| 158 | "Convert RED GREEN BLUE colors to their HSL representation. | 155 | "Convert RGB colors to their HSL representation. |
| 159 | RED, GREEN, and BLUE should each be numbers between 0.0 and 1.0, | 156 | RED, GREEN, and BLUE should each be numbers between 0.0 and 1.0, |
| 160 | inclusive. | 157 | inclusive. Return a list (HUE SATURATION LUMINANCE), where |
| 161 | 158 | each element is between 0.0 and 1.0, inclusive." | |
| 162 | Return a list (HUE, SATURATION, LUMINANCE), where HUE is in radians | ||
| 163 | and both SATURATION and LUMINANCE are between 0.0 and 1.0, | ||
| 164 | inclusive." | ||
| 165 | (let* ((r red) | 159 | (let* ((r red) |
| 166 | (g green) | 160 | (g green) |
| 167 | (b blue) | 161 | (b blue) |
| @@ -187,7 +181,7 @@ inclusive." | |||
| 187 | 181 | ||
| 188 | (defun color-srgb-to-xyz (red green blue) | 182 | (defun color-srgb-to-xyz (red green blue) |
| 189 | "Convert RED GREEN BLUE colors from the sRGB color space to CIE XYZ. | 183 | "Convert RED GREEN BLUE colors from the sRGB color space to CIE XYZ. |
| 190 | RED, BLUE and GREEN must be between 0 and 1, inclusive." | 184 | RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive." |
| 191 | (let ((r (if (<= red 0.04045) | 185 | (let ((r (if (<= red 0.04045) |
| 192 | (/ red 12.95) | 186 | (/ red 12.95) |
| 193 | (expt (/ (+ red 0.055) 1.055) 2.4))) | 187 | (expt (/ (+ red 0.055) 1.055) 2.4))) |
| @@ -225,7 +219,7 @@ RED, BLUE and GREEN must be between 0 and 1, inclusive." | |||
| 225 | (defun color-xyz-to-lab (X Y Z &optional white-point) | 219 | (defun color-xyz-to-lab (X Y Z &optional white-point) |
| 226 | "Convert CIE XYZ to CIE L*a*b*. | 220 | "Convert CIE XYZ to CIE L*a*b*. |
| 227 | WHITE-POINT specifies the (X Y Z) white point for the | 221 | WHITE-POINT specifies the (X Y Z) white point for the |
| 228 | conversion. If omitted or nil, use `color-d65-xyz'." | 222 | conversion. If omitted or nil, use `color-d65-xyz'." |
| 229 | (destructuring-bind (Xr Yr Zr) (or white-point color-d65-xyz) | 223 | (destructuring-bind (Xr Yr Zr) (or white-point color-d65-xyz) |
| 230 | (let* ((xr (/ X Xr)) | 224 | (let* ((xr (/ X Xr)) |
| 231 | (yr (/ Y Yr)) | 225 | (yr (/ Y Yr)) |
| @@ -247,7 +241,7 @@ conversion. If omitted or nil, use `color-d65-xyz'." | |||
| 247 | (defun color-lab-to-xyz (L a b &optional white-point) | 241 | (defun color-lab-to-xyz (L a b &optional white-point) |
| 248 | "Convert CIE L*a*b* to CIE XYZ. | 242 | "Convert CIE L*a*b* to CIE XYZ. |
| 249 | WHITE-POINT specifies the (X Y Z) white point for the | 243 | WHITE-POINT specifies the (X Y Z) white point for the |
| 250 | conversion. If omitted or nil, use `color-d65-xyz'." | 244 | conversion. If omitted or nil, use `color-d65-xyz'." |
| 251 | (destructuring-bind (Xr Yr Zr) (or white-point color-d65-xyz) | 245 | (destructuring-bind (Xr Yr Zr) (or white-point color-d65-xyz) |
| 252 | (let* ((fy (/ (+ L 16) 116.0)) | 246 | (let* ((fy (/ (+ L 16) 116.0)) |
| 253 | (fz (- fy (/ b 200.0))) | 247 | (fz (- fy (/ b 200.0))) |
| @@ -344,17 +338,14 @@ returned by `color-srgb-to-lab' or `color-xyz-to-lab'." | |||
| 344 | (min 1.0 (max 0.0 value))) | 338 | (min 1.0 (max 0.0 value))) |
| 345 | 339 | ||
| 346 | (defun color-saturate-hsl (H S L percent) | 340 | (defun color-saturate-hsl (H S L percent) |
| 347 | "Return a color PERCENT more saturated than the one defined in | 341 | "Make a color more saturated by a specified amount. |
| 348 | H S L color-space. | 342 | Given a color defined in terms of hue, saturation, and luminance |
| 349 | 343 | \(arguments H, S, and L), return a color that is PERCENT more | |
| 350 | Return a list (HUE, SATURATION, LUMINANCE), where HUE is in radians | 344 | saturated. Returns a list (HUE SATURATION LUMINANCE)." |
| 351 | and both SATURATION and LUMINANCE are between 0.0 and 1.0, | ||
| 352 | inclusive." | ||
| 353 | (list H (color-clamp (+ S (/ percent 100.0))) L)) | 345 | (list H (color-clamp (+ S (/ percent 100.0))) L)) |
| 354 | 346 | ||
| 355 | (defun color-saturate-name (name percent) | 347 | (defun color-saturate-name (name percent) |
| 356 | "Short hand to saturate COLOR by PERCENT. | 348 | "Make a color with a specified NAME more saturated by PERCENT. |
| 357 | |||
| 358 | See `color-saturate-hsl'." | 349 | See `color-saturate-hsl'." |
| 359 | (apply 'color-rgb-to-hex | 350 | (apply 'color-rgb-to-hex |
| 360 | (apply 'color-hsl-to-rgb | 351 | (apply 'color-hsl-to-rgb |
| @@ -365,32 +356,26 @@ See `color-saturate-hsl'." | |||
| 365 | (list percent)))))) | 356 | (list percent)))))) |
| 366 | 357 | ||
| 367 | (defun color-desaturate-hsl (H S L percent) | 358 | (defun color-desaturate-hsl (H S L percent) |
| 368 | "Return a color PERCENT less saturated than the one defined in | 359 | "Make a color less saturated by a specified amount. |
| 369 | H S L color-space. | 360 | Given a color defined in terms of hue, saturation, and luminance |
| 370 | 361 | \(arguments H, S, and L), return a color that is PERCENT less | |
| 371 | Return a list (HUE, SATURATION, LUMINANCE), where HUE is in radians | 362 | saturated. Returns a list (HUE SATURATION LUMINANCE)." |
| 372 | and both SATURATION and LUMINANCE are between 0.0 and 1.0, | ||
| 373 | inclusive." | ||
| 374 | (color-saturate-hsl H S L (- percent))) | 363 | (color-saturate-hsl H S L (- percent))) |
| 375 | 364 | ||
| 376 | (defun color-desaturate-name (name percent) | 365 | (defun color-desaturate-name (name percent) |
| 377 | "Short hand to desaturate COLOR by PERCENT. | 366 | "Make a color with a specified NAME less saturated by PERCENT. |
| 378 | |||
| 379 | See `color-desaturate-hsl'." | 367 | See `color-desaturate-hsl'." |
| 380 | (color-saturate-name name (- percent))) | 368 | (color-saturate-name name (- percent))) |
| 381 | 369 | ||
| 382 | (defun color-lighten-hsl (H S L percent) | 370 | (defun color-lighten-hsl (H S L percent) |
| 383 | "Return a color PERCENT lighter than the one defined in | 371 | "Make a color lighter by a specified amount. |
| 384 | H S L color-space. | 372 | Given a color defined in terms of hue, saturation, and luminance |
| 385 | 373 | \(arguments H, S, and L), return a color that is PERCENT lighter. | |
| 386 | Return a list (HUE, SATURATION, LUMINANCE), where HUE is in radians | 374 | Returns a list (HUE SATURATION LUMINANCE)." |
| 387 | and both SATURATION and LUMINANCE are between 0.0 and 1.0, | ||
| 388 | inclusive." | ||
| 389 | (list H S (color-clamp (+ L (/ percent 100.0))))) | 375 | (list H S (color-clamp (+ L (/ percent 100.0))))) |
| 390 | 376 | ||
| 391 | (defun color-lighten-name (name percent) | 377 | (defun color-lighten-name (name percent) |
| 392 | "Short hand to saturate COLOR by PERCENT. | 378 | "Make a color with a specified NAME lighter by PERCENT. |
| 393 | |||
| 394 | See `color-lighten-hsl'." | 379 | See `color-lighten-hsl'." |
| 395 | (apply 'color-rgb-to-hex | 380 | (apply 'color-rgb-to-hex |
| 396 | (apply 'color-hsl-to-rgb | 381 | (apply 'color-hsl-to-rgb |
| @@ -401,17 +386,14 @@ See `color-lighten-hsl'." | |||
| 401 | (list percent)))))) | 386 | (list percent)))))) |
| 402 | 387 | ||
| 403 | (defun color-darken-hsl (H S L percent) | 388 | (defun color-darken-hsl (H S L percent) |
| 404 | "Return a color PERCENT darker than the one defined in | 389 | "Make a color darker by a specified amount. |
| 405 | H S L color-space. | 390 | Given a color defined in terms of hue, saturation, and luminance |
| 406 | 391 | \(arguments H, S, and L), return a color that is PERCENT darker. | |
| 407 | Return a list (HUE, SATURATION, LUMINANCE), where HUE is in radians | 392 | Returns a list (HUE SATURATION LUMINANCE)." |
| 408 | and both SATURATION and LUMINANCE are between 0.0 and 1.0, | ||
| 409 | inclusive." | ||
| 410 | (color-lighten-hsl H S L (- percent))) | 393 | (color-lighten-hsl H S L (- percent))) |
| 411 | 394 | ||
| 412 | (defun color-darken-name (name percent) | 395 | (defun color-darken-name (name percent) |
| 413 | "Short hand to saturate COLOR by PERCENT. | 396 | "Make a color with a specified NAME darker by PERCENT. |
| 414 | |||
| 415 | See `color-darken-hsl'." | 397 | See `color-darken-hsl'." |
| 416 | (color-lighten-name name (- percent))) | 398 | (color-lighten-name name (- percent))) |
| 417 | 399 | ||