color: fix color-rgb-to-hsv computing
authorJulien Danjou <julien@danjou.info>
Fri, 11 Jan 2013 09:52:53 +0000 (10:52 +0100)
committerJulien Danjou <julien@danjou.info>
Fri, 11 Jan 2013 09:54:48 +0000 (10:54 +0100)
Signed-off-by: Julien Danjou <julien@danjou.info>
lisp/ChangeLog
lisp/color.el

index 2ed5647..c6519ea 100644 (file)
@@ -1,3 +1,9 @@
+2013-01-11  Julien Danjou  <julien@danjou.info>
+
+       * color.el (color-rgb-to-hsv): Fix conversion computing in case min and
+       max are almost equal. Also return the correct value for V which is
+       already between 0 and 1.
+
 2013-01-10  Uwe Brauer  <oub@mat.ucm.es>  (tiny change)
 
        * mml-smime.el (mml-smime-encrypt-to-self): New user option analogous
index 3b6e33c..6b60684 100644 (file)
@@ -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.