diff options
| author | Mark Oteiza | 2017-09-13 10:00:39 -0400 |
|---|---|---|
| committer | Mark Oteiza | 2017-09-13 10:00:39 -0400 |
| commit | d532caaeee1d604e72e75072310c4447b694a070 (patch) | |
| tree | cdf20aacfd4a7394fe73e5a0cc1057b2d08d9a2c | |
| parent | 8d433d9b22d2c5f209cb27e80c13576e6d1bf9b7 (diff) | |
| download | emacs-d532caaeee1d604e72e75072310c4447b694a070.tar.gz emacs-d532caaeee1d604e72e75072310c4447b694a070.zip | |
Add other D series white points and some simple conversions
* lisp/color.el (color-d75-xyz, color-d55-xyz, color-d50-xyz): New
constants.
(color-xyz-to-xyy, color-xyy-to-xyz, color-lab-to-lch):
(color-lch-to-lab): New functions.
| -rw-r--r-- | lisp/color.el | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lisp/color.el b/lisp/color.el index ddd0fdb15ab..22b6808c87f 100644 --- a/lisp/color.el +++ b/lisp/color.el | |||
| @@ -212,9 +212,18 @@ RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive." | |||
| 212 | (* 12.92 b) | 212 | (* 12.92 b) |
| 213 | (- (* 1.055 (expt b (/ 2.4))) 0.055))))) | 213 | (- (* 1.055 (expt b (/ 2.4))) 0.055))))) |
| 214 | 214 | ||
| 215 | (defconst color-d75-xyz '(0.9497 1.0 1.2264) | ||
| 216 | "D75 white point in CIE XYZ.") | ||
| 217 | |||
| 215 | (defconst color-d65-xyz '(0.950455 1.0 1.088753) | 218 | (defconst color-d65-xyz '(0.950455 1.0 1.088753) |
| 216 | "D65 white point in CIE XYZ.") | 219 | "D65 white point in CIE XYZ.") |
| 217 | 220 | ||
| 221 | (defconst color-d55-xyz '(0.9568 1.0 0.9215) | ||
| 222 | "D55 white point in CIE XYZ.") | ||
| 223 | |||
| 224 | (defconst color-d50-xyz '(0.9642 1.0 0.8249) | ||
| 225 | "D50 white point in CIE XYZ.") | ||
| 226 | |||
| 218 | (defconst color-cie-ε (/ 216 24389.0)) | 227 | (defconst color-cie-ε (/ 216 24389.0)) |
| 219 | (defconst color-cie-κ (/ 24389 27.0)) | 228 | (defconst color-cie-κ (/ 24389 27.0)) |
| 220 | 229 | ||
| @@ -269,6 +278,24 @@ conversion. If omitted or nil, use `color-d65-xyz'." | |||
| 269 | "Convert CIE L*a*b* to RGB." | 278 | "Convert CIE L*a*b* to RGB." |
| 270 | (apply 'color-xyz-to-srgb (color-lab-to-xyz L a b))) | 279 | (apply 'color-xyz-to-srgb (color-lab-to-xyz L a b))) |
| 271 | 280 | ||
| 281 | (defun color-xyz-to-xyy (X Y Z) | ||
| 282 | "Convert CIE XYZ to xyY." | ||
| 283 | (let ((d (float (+ X Y Z)))) | ||
| 284 | (list (/ X d) (/ Y d) Y))) | ||
| 285 | |||
| 286 | (defun color-xyy-to-xyz (x y Y) | ||
| 287 | "Convert CIE xyY to XYZ." | ||
| 288 | (let ((y (float y))) | ||
| 289 | (list (/ (* Y x) y) Y (/ (* Y (- 1 x y)) y)))) | ||
| 290 | |||
| 291 | (defun color-lab-to-lch (L a b) | ||
| 292 | "Convert CIE L*a*b* to L*C*h*" | ||
| 293 | (list L (sqrt (+ (* a a) (* b b))) (atan b a))) | ||
| 294 | |||
| 295 | (defun color-lch-to-lab (L C h) | ||
| 296 | "Convert CIE L*a*b* to L*C*h*" | ||
| 297 | (list L (* C (cos h)) (* C (sin h)))) | ||
| 298 | |||
| 272 | (defun color-cie-de2000 (color1 color2 &optional kL kC kH) | 299 | (defun color-cie-de2000 (color1 color2 &optional kL kC kH) |
| 273 | "Return the CIEDE2000 color distance between COLOR1 and COLOR2. | 300 | "Return the CIEDE2000 color distance between COLOR1 and COLOR2. |
| 274 | Both COLOR1 and COLOR2 should be in CIE L*a*b* format, as | 301 | Both COLOR1 and COLOR2 should be in CIE L*a*b* format, as |