[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#25890: `color-values` gives wrong value
From: |
Michael Heerdegen |
Subject: |
bug#25890: `color-values` gives wrong value |
Date: |
Wed, 01 Mar 2017 00:42:02 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
Eli Zaretskii <eliz@gnu.org> writes:
> So I think the patch below is what is needed to fix this problem. Can
> you try it? (There's one user of the functions the patch changes,
> shr-color.el, which will need to be adapted to the change, if we
> decide to install it.)
>
>
> --- lisp/color.el~0 2017-01-02 06:25:09.000000000 +0200
> +++ lisp/color.el 2017-02-28 17:35:43.570586100 +0200
> @@ -52,14 +52,14 @@
> If FRAME cannot display COLOR, return nil."
> ;; `colors-values' maximum value is either 65535 or 65280 depending on the
> ;; display system. So we use a white conversion to get the max value.
> - (let ((valmax (float (car (color-values "#ffffff")))))
> + (let ((valmax (float (car (color-values "#ffffffffffff")))))
> (mapcar (lambda (x) (/ x valmax)) (color-values color frame))))
>
> (defun color-rgb-to-hex (red green blue)
> "Return hexadecimal notation for the color RED GREEN BLUE.
> RED, GREEN, and BLUE should be numbers between 0.0 and 1.0, inclusive."
> - (format "#%02x%02x%02x"
> - (* red 255) (* green 255) (* blue 255)))
> + (format "#%04x%04x%04x"
> + (* red 65535) (* green 65535) (* blue 65535)))
>
> (defun color-complement (color-name)
> "Return the color that is the complement of COLOR-NAME.
With that patch, for me in the recipe of bug #24273, it makes a
difference; now
(color-name-to-rgb "#ffffff")
==>
(0.9961089494163424 0.9961089494163424 0.9961089494163424)
and
(color-name-to-rgb "white")
==>
(1.0 1.0 1.0)
For the recipe of this bug report, the values are the same as without
the patch.
I guess this is what you expected. But is it ok that "#ffffff" is not
equivalent to "white"? If it is, seems there is no inconsistency left.
Thanks so far,
Michael.