GNU bug report logs - #12559
color-hsl-to-rgb doesn't handle hue range overflow

Previous Next

Package: emacs;

Reported by: Julian Scheid <julians37 <at> gmail.com>

Date: Tue, 2 Oct 2012 16:27:04 UTC

Severity: normal

Tags: patch

Merged with 13047

Found in version 24.2

Fixed in version 24.3

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12559 in the body.
You can then email your comments to 12559 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#12559; Package emacs. (Tue, 02 Oct 2012 16:27:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Julian Scheid <julians37 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 02 Oct 2012 16:27:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Julian Scheid <julians37 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: color-hsl-to-rgb doesn't handle hue range overflow
Date: Tue, 02 Oct 2012 15:40:54 +0200
`color-hsl-to-rgb' manipulates hue without dealing with range overflow
or underflow.  This takes small and large hue values outside of the
range expected by `color-hue-to-rgb' and causes incorrect results for
such values:

    (color-rgb-to-hsl 0.65 0.25 0.75)
    ;; -> (0.7999999999999999 0.5 0.5)

    (apply 'color-hsl-to-rgb (color-rgb-to-hsl 0.65 0.25 0.75))
    ;; -> (0.25 0.25 0.75)

    (color-rgb-to-hsl 0.65 0.75 0.25)
    ;; -> (0.20000000000000004 0.5 0.5)

    (apply 'color-hsl-to-rgb (color-rgb-to-hsl 0.65 0.75 0.25))
    ;; -> (0.6499999999999999 0.75 -0.1499999999999998)

The patch below makes the conversion work as expected:

    (apply 'color-hsl-to-rgb (color-rgb-to-hsl 0.65 0.25 0.75))
    ;; -> (0.6499999999999999 0.25 0.75)

    (apply 'color-hsl-to-rgb (color-rgb-to-hsl 0.65 0.75 0.25))
    ;; -> (0.6499999999999999 0.75 0.25)


2012-10-02  Julian Scheid  <julians37 <at> gmail.com>

	* color.el (color-hsl-to-rgb): Fix for incorrect results for
        small and large hue values.


=== modified file 'lisp/color.el'
*** lisp/color.el	2012-08-13 19:10:35 +0000
--- lisp/color.el	2012-10-02 13:16:32 +0000
*************** Return a list (RED, GREEN, BLUE) which e
*** 116,124 ****
  		 (- (+ L S) (* L S))))
  	   (m1 (- (* 2.0 L) m2)))
        (list
!        (color-hue-to-rgb m1 m2 (+ H (/ 1.0 3)))
         (color-hue-to-rgb m1 m2 H)
!        (color-hue-to-rgb m1 m2 (- H (/ 1.0 3)))))))
  
  (defun color-complement-hex (color)
    "Return the color that is the complement of COLOR, in hexadecimal format."
--- 116,124 ----
  		 (- (+ 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 H)
!        (color-hue-to-rgb m1 m2 (mod (- H (/ 1.0 3)) 1))))))
  
  (defun color-complement-hex (color)
    "Return the color that is the complement of COLOR, in hexadecimal format."





Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Sat, 06 Oct 2012 02:23:02 GMT) Full text and rfc822 format available.

Notification sent to Julian Scheid <julians37 <at> gmail.com>:
bug acknowledged by developer. (Sat, 06 Oct 2012 02:23:03 GMT) Full text and rfc822 format available.

Message #10 received at 12559-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 12559-done <at> debbugs.gnu.org
Subject: Re: bug#12559: color-hsl-to-rgb doesn't handle hue range overflow
Date: Fri, 05 Oct 2012 22:21:51 -0400
Version: 24.3

Thanks; applied to trunk.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 03 Nov 2012 11:24:03 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 01 Dec 2012 18:42:02 GMT) Full text and rfc822 format available.

Forcibly Merged 12559 13047. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 01 Dec 2012 18:42:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 30 Dec 2012 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 131 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.