]> code.delx.au - gnu-emacs/blobdiff - lisp/color.el
Update copyright year to 2016
[gnu-emacs] / lisp / color.el
index 63326e7c5b3528fa5ccfe4fabf843b78c1f37847..ae4298746a6306ff9b723f821830608ce6b86126 100644 (file)
@@ -1,6 +1,6 @@
-;;; color.el --- Color manipulation library -*- coding: utf-8; lexical-binding:t -*-
+;;; color.el --- Color manipulation library -*- lexical-binding:t -*-
 
-;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
 
 ;; Authors: Julien Danjou <julien@danjou.info>
 ;;          Drew Adams <drew.adams@oracle.com>
@@ -93,7 +93,7 @@ resulting list."
   "Compute hue from V1 and V2 H.
 Used internally by `color-hsl-to-rgb'."
   (cond
-   ((< h (/ 1.0 6))   (+ v1 (* (- v2 v1) h 6.0)))
+   ((< h (/ 6.0))     (+ v1 (* (- v2 v1) h 6.0)))
    ((< h 0.5)         v2)
    ((< h (/ 2.0 3))   (+ v1 (* (- v2 v1) (- (/ 2.0 3) h) 6.0)))
    (t                 v1)))
@@ -110,9 +110,9 @@ inclusive."
                 (- (+ L S) (* L S))))
           (m1 (- (* 2.0 L) m2)))
       (list
-       (color-hue-to-rgb m1 m2 (mod (+ H (/ 1.0 3)) 1))
+       (color-hue-to-rgb m1 m2 (mod (+ H (/ 3.0)) 1))
        (color-hue-to-rgb m1 m2 H)
-       (color-hue-to-rgb m1 m2 (mod (- H (/ 1.0 3)) 1))))))
+       (color-hue-to-rgb m1 m2 (mod (- H (/ 3.0)) 1))))))
 
 (defun color-complement-hex (color)
   "Return the color that is the complement of COLOR, in hexadecimal format."
@@ -130,7 +130,7 @@ inclusive."
         (max (max r g b))
         (min (min r g b)))
     (if (< (- max min) 1e-8)
-       (list 0.0 0.0 0.0)
+       (list 0.0 0.0 min)
       (list
        (/ (* 2 float-pi
             (cond ((and (= r g) (= g b)) 0)
@@ -146,7 +146,7 @@ inclusive."
                    (+ 240 (* 60 (/ (- r g) (- max min)))))))
          360)
        (if (= max 0) 0 (- 1 (/ min max)))
-       (/ max 255.0)))))
+       max))))
 
 (defun color-rgb-to-hsl (red green blue)
   "Convert RGB colors to their HSL representation.
@@ -199,13 +199,13 @@ RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive."
         (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z))))
     (list (if (<= r 0.0031308)
               (* 12.92 r)
-            (- (* 1.055 (expt r (/ 2.4))) 0.055))
+            (- (* 1.055 (expt r (/ 2.4))) 0.055))
           (if (<= g 0.0031308)
               (* 12.92 g)
-            (- (* 1.055 (expt g (/ 2.4))) 0.055))
+            (- (* 1.055 (expt g (/ 2.4))) 0.055))
           (if (<= b 0.0031308)
               (* 12.92 b)
-            (- (* 1.055 (expt b (/ 2.4))) 0.055)))))
+            (- (* 1.055 (expt b (/ 2.4))) 0.055)))))
 
 (defconst color-d65-xyz '(0.950455 1.0 1.088753)
   "D65 white point in CIE XYZ.")
@@ -222,13 +222,13 @@ conversion.  If omitted or nil, use `color-d65-xyz'."
              (yr (/ Y Yr))
              (zr (/ Z Zr))
              (fx (if (> xr color-cie-ε)
-                     (expt xr (/ 3.0))
+                     (expt xr (/ 3.0))
                    (/ (+ (* color-cie-κ xr) 16) 116.0)))
              (fy (if (> yr color-cie-ε)
-                     (expt yr (/ 3.0))
+                     (expt yr (/ 3.0))
                    (/ (+ (* color-cie-κ yr) 16) 116.0)))
              (fz (if (> zr color-cie-ε)
-                     (expt zr (/ 3.0))
+                     (expt zr (/ 3.0))
                    (/ (+ (* color-cie-κ zr) 16) 116.0))))
         (list
          (- (* 116 fy) 16)                  ; L