* bug#74055: 31.0.50; color-lighten-name not lightening black
@ 2024-10-28 8:27 Gerd Möllmann
2024-10-28 12:39 ` Eli Zaretskii
0 siblings, 1 reply; 13+ messages in thread
From: Gerd Möllmann @ 2024-10-28 8:27 UTC (permalink / raw)
To: 74055
The function color-lighten-name doesn't work as I would expect for
black:
(color-lighten-name "#000000" 50)
=> "#000000000000"
I think there is even a test that checks that, in color-tests.el:
(ert-deftest color-tests-lighten-name ()
(should (equal (color-lighten-name "black" 100) "#000000000000"))
I don't understand this, and it is different from what I'd expect, and
tools for the web return, for example
https://mdigi.tools/lighten-color/#000000
In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.0.0, NS
appkit-2566.00 Version 15.0.1 (Build 24A348)) of 2024-10-28 built on
pro2
Repository revision: ea685170063b59855322ceffdeaaab4acaf8e388
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2566
System Description: macOS 15.0.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-10-28 8:27 bug#74055: 31.0.50; color-lighten-name not lightening black Gerd Möllmann
@ 2024-10-28 12:39 ` Eli Zaretskii
2024-10-28 15:18 ` Ship Mints
2024-10-28 16:57 ` Mattias Engdegård
0 siblings, 2 replies; 13+ messages in thread
From: Eli Zaretskii @ 2024-10-28 12:39 UTC (permalink / raw)
To: Gerd Möllmann, Julien Danjou, Mattias Engdegård
Cc: Noah Friedman, 74055
> From: Gerd Möllmann <gerd.moellmann@gmail.com>
> Date: Mon, 28 Oct 2024 09:27:29 +0100
>
> The function color-lighten-name doesn't work as I would expect for
> black:
>
> (color-lighten-name "#000000" 50)
> => "#000000000000"
>
> I think there is even a test that checks that, in color-tests.el:
>
> (ert-deftest color-tests-lighten-name ()
> (should (equal (color-lighten-name "black" 100) "#000000000000"))
>
> I don't understand this, and it is different from what I'd expect, and
> tools for the web return, for example
>
> https://mdigi.tools/lighten-color/#000000
Our notion of "lighten color" seems to be to increase the color's
luminance by P percent. Since the black color's luminance is zero,
increasing that by 50% still yields zero.
By contrast, the page you point to seems to interpret "lighten" to
mean that P is the percentage of the full scale, not of the original
color's luminance.
This goes back to commit 656c2dd66e, which was supposed to fix
bug#54514. But maybe Noah's interpretation of "lighten" was
incorrect, and we should revert that change? OTOH, if we do revert
it, then Noah's example will disagree with the above page.
So I guess our algorithm is incorrect somewhere?
Adding Julien and Mattias, in the hope that they could help unconfuse
us.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-10-28 12:39 ` Eli Zaretskii
@ 2024-10-28 15:18 ` Ship Mints
2024-10-28 16:57 ` Mattias Engdegård
1 sibling, 0 replies; 13+ messages in thread
From: Ship Mints @ 2024-10-28 15:18 UTC (permalink / raw)
To: Eli Zaretskii
Cc: Gerd Möllmann, Julien Danjou, Noah Friedman, 74055,
Mattias Engdegård
[-- Attachment #1: Type: text/plain, Size: 2585 bytes --]
I use below to compute adjusted colors given that lighten doesn't work when
black multipliers are all zero.
(defun my/color-rgb-transform-by-frac (c1 c2 frac)
"Compute RGB color from C1 adjusted closer to C2 by FRAC.
FRAC is a floating-point number between 0 and 1."
(cl-destructuring-bind (c1-r c1-g c1-b) c1
(cl-destructuring-bind (c2-r c2-g c2-b) c2
(list (+ c1-r (* (- c2-r c1-r) frac))
(+ c1-g (* (- c2-g c1-g) frac))
(+ c1-b (* (- c2-b c1-b) frac))))))
(defun my/color-hex-transform-by-frac (c1 c2 frac)
"Compute hex color from C1 adjusted closer to C2 by FRAC.
FRAC is a floating-point number between 0 and 1."
(apply #'color-rgb-to-hex
(my/color-rgb-transform-by-frac (color-name-to-rgb c1)
(color-name-to-rgb c2)
frac)))
;; e.g.,
(my/color-hex-transform-by-frac "black"
"white"
0.10) ; produces "#199919991999"
(color-lighten-name "black" 10) ; produces "#000000000000"
On Mon, Oct 28, 2024 at 8:40 AM Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Gerd Möllmann <gerd.moellmann@gmail.com>
> > Date: Mon, 28 Oct 2024 09:27:29 +0100
> >
> > The function color-lighten-name doesn't work as I would expect for
> > black:
> >
> > (color-lighten-name "#000000" 50)
> > => "#000000000000"
> >
> > I think there is even a test that checks that, in color-tests.el:
> >
> > (ert-deftest color-tests-lighten-name ()
> > (should (equal (color-lighten-name "black" 100) "#000000000000"))
> >
> > I don't understand this, and it is different from what I'd expect, and
> > tools for the web return, for example
> >
> > https://mdigi.tools/lighten-color/#000000
>
> Our notion of "lighten color" seems to be to increase the color's
> luminance by P percent. Since the black color's luminance is zero,
> increasing that by 50% still yields zero.
>
> By contrast, the page you point to seems to interpret "lighten" to
> mean that P is the percentage of the full scale, not of the original
> color's luminance.
>
> This goes back to commit 656c2dd66e, which was supposed to fix
> bug#54514. But maybe Noah's interpretation of "lighten" was
> incorrect, and we should revert that change? OTOH, if we do revert
> it, then Noah's example will disagree with the above page.
>
> So I guess our algorithm is incorrect somewhere?
>
> Adding Julien and Mattias, in the hope that they could help unconfuse
> us.
>
>
>
>
[-- Attachment #2: Type: text/html, Size: 3927 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-10-28 12:39 ` Eli Zaretskii
2024-10-28 15:18 ` Ship Mints
@ 2024-10-28 16:57 ` Mattias Engdegård
2024-10-28 17:24 ` Eli Zaretskii
1 sibling, 1 reply; 13+ messages in thread
From: Mattias Engdegård @ 2024-10-28 16:57 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Gerd Möllmann, Julien Danjou, Noah Friedman, 74055
28 okt. 2024 kl. 13.39 skrev Eli Zaretskii <eliz@gnu.org>:
> Our notion of "lighten color" seems to be to increase the color's
> luminance by P percent. Since the black color's luminance is zero,
> increasing that by 50% still yields zero.
>
> By contrast, the page you point to seems to interpret "lighten" to
> mean that P is the percentage of the full scale, not of the original
> color's luminance.
>
> This goes back to commit 656c2dd66e, which was supposed to fix
> bug#54514. But maybe Noah's interpretation of "lighten" was
> incorrect, and we should revert that change? OTOH, if we do revert
> it, then Noah's example will disagree with the above page.
That change may have been made in haste. For example, it didn't touch the corresponding saturate and desaturate functions which use similar mechanics, so there is now an inconsistency in that respect.
But which interpretation is better isn't obvious. It doesn't have much to do with colour theory per se. As luminance is already a percentage of sorts, it's not at all clear what it means by increasing it by a certain percentage. Personally I wouldn't use either function because of how ill-defined they are.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-10-28 16:57 ` Mattias Engdegård
@ 2024-10-28 17:24 ` Eli Zaretskii
2024-10-29 4:41 ` Gerd Möllmann
2024-10-29 12:54 ` Mattias Engdegård
0 siblings, 2 replies; 13+ messages in thread
From: Eli Zaretskii @ 2024-10-28 17:24 UTC (permalink / raw)
To: Mattias Engdegård; +Cc: gerd.moellmann, julien, noah, 74055
> From: Mattias Engdegård <mattias.engdegard@gmail.com>
> Date: Mon, 28 Oct 2024 17:57:49 +0100
> Cc: Gerd Möllmann <gerd.moellmann@gmail.com>,
> Julien Danjou <julien@danjou.info>,
> 74055@debbugs.gnu.org,
> Noah Friedman <noah@splode.com>
>
> 28 okt. 2024 kl. 13.39 skrev Eli Zaretskii <eliz@gnu.org>:
>
> > Our notion of "lighten color" seems to be to increase the color's
> > luminance by P percent. Since the black color's luminance is zero,
> > increasing that by 50% still yields zero.
> >
> > By contrast, the page you point to seems to interpret "lighten" to
> > mean that P is the percentage of the full scale, not of the original
> > color's luminance.
> >
> > This goes back to commit 656c2dd66e, which was supposed to fix
> > bug#54514. But maybe Noah's interpretation of "lighten" was
> > incorrect, and we should revert that change? OTOH, if we do revert
> > it, then Noah's example will disagree with the above page.
>
> That change may have been made in haste. For example, it didn't touch the corresponding saturate and desaturate functions which use similar mechanics, so there is now an inconsistency in that respect.
>
> But which interpretation is better isn't obvious. It doesn't have much to do with colour theory per se. As luminance is already a percentage of sorts, it's not at all clear what it means by increasing it by a certain percentage. Personally I wouldn't use either function because of how ill-defined they are.
Maybe there are widely-accepted de-facto standards for that?
Or maybe we should support more than one interpretation, by way of
some user option?
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-10-28 17:24 ` Eli Zaretskii
@ 2024-10-29 4:41 ` Gerd Möllmann
2024-10-29 8:25 ` Gerd Möllmann
2024-10-29 12:54 ` Mattias Engdegård
1 sibling, 1 reply; 13+ messages in thread
From: Gerd Möllmann @ 2024-10-29 4:41 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: julien, Mattias Engdegård, noah, 74055
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Mattias Engdegård <mattias.engdegard@gmail.com>
>> Date: Mon, 28 Oct 2024 17:57:49 +0100
>> Cc: Gerd Möllmann <gerd.moellmann@gmail.com>,
>> Julien Danjou <julien@danjou.info>,
>> 74055@debbugs.gnu.org,
>> Noah Friedman <noah@splode.com>
>>
>> 28 okt. 2024 kl. 13.39 skrev Eli Zaretskii <eliz@gnu.org>:
>>
>> > Our notion of "lighten color" seems to be to increase the color's
>> > luminance by P percent. Since the black color's luminance is zero,
>> > increasing that by 50% still yields zero.
>> >
>> > By contrast, the page you point to seems to interpret "lighten" to
>> > mean that P is the percentage of the full scale, not of the original
>> > color's luminance.
>> >
>> > This goes back to commit 656c2dd66e, which was supposed to fix
>> > bug#54514. But maybe Noah's interpretation of "lighten" was
>> > incorrect, and we should revert that change? OTOH, if we do revert
>> > it, then Noah's example will disagree with the above page.
>>
>> That change may have been made in haste. For example, it didn't
>> touch the corresponding saturate and desaturate functions which use
>> similar mechanics, so there is now an inconsistency in that respect.
>>
>> But which interpretation is better isn't obvious. It doesn't have
>> much to do with colour theory per se. As luminance is already a
>> percentage of sorts, it's not at all clear what it means by
>> increasing it by a certain percentage. Personally I wouldn't use
>> either function because of how ill-defined they are.
>
> Maybe there are widely-accepted de-facto standards for that?
I think HSL colors (Hue Saturation Luminescence) are used by CSS for
example, so that's good, and color.el has support for HSL colors. Except
that something is currently not working right, I guess.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-10-29 4:41 ` Gerd Möllmann
@ 2024-10-29 8:25 ` Gerd Möllmann
0 siblings, 0 replies; 13+ messages in thread
From: Gerd Möllmann @ 2024-10-29 8:25 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: julien, Mattias Engdegård, noah, 74055
Gerd Möllmann <gerd.moellmann@gmail.com> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Mattias Engdegård <mattias.engdegard@gmail.com>
>>> Date: Mon, 28 Oct 2024 17:57:49 +0100
>>> Cc: Gerd Möllmann <gerd.moellmann@gmail.com>,
>>> Julien Danjou <julien@danjou.info>,
>>> 74055@debbugs.gnu.org,
>>> Noah Friedman <noah@splode.com>
>>>
>>> 28 okt. 2024 kl. 13.39 skrev Eli Zaretskii <eliz@gnu.org>:
>>>
>>> > Our notion of "lighten color" seems to be to increase the color's
>>> > luminance by P percent. Since the black color's luminance is zero,
>>> > increasing that by 50% still yields zero.
>>> >
>>> > By contrast, the page you point to seems to interpret "lighten" to
>>> > mean that P is the percentage of the full scale, not of the original
>>> > color's luminance.
>>> >
>>> > This goes back to commit 656c2dd66e, which was supposed to fix
>>> > bug#54514. But maybe Noah's interpretation of "lighten" was
>>> > incorrect, and we should revert that change? OTOH, if we do revert
>>> > it, then Noah's example will disagree with the above page.
>>>
>>> That change may have been made in haste. For example, it didn't
>>> touch the corresponding saturate and desaturate functions which use
>>> similar mechanics, so there is now an inconsistency in that respect.
>>>
>>> But which interpretation is better isn't obvious. It doesn't have
>>> much to do with colour theory per se. As luminance is already a
>>> percentage of sorts, it's not at all clear what it means by
>>> increasing it by a certain percentage. Personally I wouldn't use
>>> either function because of how ill-defined they are.
>>
>> Maybe there are widely-accepted de-facto standards for that?
>
> I think HSL colors (Hue Saturation Luminescence) are used by CSS for
> example, so that's good, and color.el has support for HSL colors. Except
> that something is currently not working right, I guess.
TIL the L in HSL actually stands for lightness. And the math for RGB <->
HSL conversion is nicely explained here:
https://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-10-28 17:24 ` Eli Zaretskii
2024-10-29 4:41 ` Gerd Möllmann
@ 2024-10-29 12:54 ` Mattias Engdegård
2024-10-29 18:27 ` Gerd Möllmann
1 sibling, 1 reply; 13+ messages in thread
From: Mattias Engdegård @ 2024-10-29 12:54 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gerd.moellmann, julien, noah, 74055
28 okt. 2024 kl. 18.24 skrev Eli Zaretskii <eliz@gnu.org>:
> Maybe there are widely-accepted de-facto standards for that?
Perhaps the documentation should said 'percentage points' instead of just 'percent' to be unambiguous, since the lightness value is relative to the white-point.
I'd say the old model (percentage points) is better because it results in changes that are perceptually more uniform. For example, with the current code,
(color-lighten-name C 5)
has much less effect when C is a dark colour than for a light one. Therefore the change was probably a mistake in hindsight.
> Or maybe we should support more than one interpretation, by way of
> some user option?
Don't think so -- only really a good solution for user preferences, not for an API.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-10-29 12:54 ` Mattias Engdegård
@ 2024-10-29 18:27 ` Gerd Möllmann
2024-11-02 16:17 ` Eli Zaretskii
0 siblings, 1 reply; 13+ messages in thread
From: Gerd Möllmann @ 2024-10-29 18:27 UTC (permalink / raw)
To: Mattias Engdegård; +Cc: julien, Eli Zaretskii, noah, 74055
Mattias Engdegård <mattias.engdegard@gmail.com> writes:
> I'd say the old model (percentage points) is better because it results
> in changes that are perceptually more uniform. For example, with the
> current code,
>
> (color-lighten-name C 5)
>
> has much less effect when C is a dark colour than for a light one.
> Therefore the change was probably a mistake in hindsight.
+1
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-10-29 18:27 ` Gerd Möllmann
@ 2024-11-02 16:17 ` Eli Zaretskii
2024-11-02 17:10 ` Gerd Möllmann
0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2024-11-02 16:17 UTC (permalink / raw)
To: Gerd Möllmann; +Cc: julien, mattias.engdegard, noah, 74055
> From: Gerd Möllmann <gerd.moellmann@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, julien@danjou.info,
> 74055@debbugs.gnu.org, noah@splode.com
> Date: Tue, 29 Oct 2024 19:27:14 +0100
>
> Mattias Engdegård <mattias.engdegard@gmail.com> writes:
>
> > I'd say the old model (percentage points) is better because it results
> > in changes that are perceptually more uniform. For example, with the
> > current code,
> >
> > (color-lighten-name C 5)
> >
> > has much less effect when C is a dark colour than for a light one.
> > Therefore the change was probably a mistake in hindsight.
>
> +1
I hope I fixed that now, please take a look.
Noah's original example works as expected, and the comparison with Web
sites also seems to be working.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-11-02 16:17 ` Eli Zaretskii
@ 2024-11-02 17:10 ` Gerd Möllmann
2024-11-04 12:35 ` Gerd Möllmann
0 siblings, 1 reply; 13+ messages in thread
From: Gerd Möllmann @ 2024-11-02 17:10 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: julien, mattias.engdegard, noah, 74055
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Gerd Möllmann <gerd.moellmann@gmail.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>, julien@danjou.info,
>> 74055@debbugs.gnu.org, noah@splode.com
>> Date: Tue, 29 Oct 2024 19:27:14 +0100
>>
>> Mattias Engdegård <mattias.engdegard@gmail.com> writes:
>>
>> > I'd say the old model (percentage points) is better because it results
>> > in changes that are perceptually more uniform. For example, with the
>> > current code,
>> >
>> > (color-lighten-name C 5)
>> >
>> > has much less effect when C is a dark colour than for a light one.
>> > Therefore the change was probably a mistake in hindsight.
>>
>> +1
>
> I hope I fixed that now, please take a look.
>
> Noah's original example works as expected, and the comparison with Web
> sites also seems to be working.
Works for me, too. Thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-11-02 17:10 ` Gerd Möllmann
@ 2024-11-04 12:35 ` Gerd Möllmann
2024-11-04 13:31 ` Eli Zaretskii
0 siblings, 1 reply; 13+ messages in thread
From: Gerd Möllmann @ 2024-11-04 12:35 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: julien, mattias.engdegard, noah, 74055
Gerd Möllmann <gerd.moellmann@gmail.com> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Gerd Möllmann <gerd.moellmann@gmail.com>
>>> Cc: Eli Zaretskii <eliz@gnu.org>, julien@danjou.info,
>>> 74055@debbugs.gnu.org, noah@splode.com
>>> Date: Tue, 29 Oct 2024 19:27:14 +0100
>>>
>>> Mattias Engdegård <mattias.engdegard@gmail.com> writes:
>>>
>>> > I'd say the old model (percentage points) is better because it results
>>> > in changes that are perceptually more uniform. For example, with the
>>> > current code,
>>> >
>>> > (color-lighten-name C 5)
>>> >
>>> > has much less effect when C is a dark colour than for a light one.
>>> > Therefore the change was probably a mistake in hindsight.
>>>
>>> +1
>>
>> I hope I fixed that now, please take a look.
>>
>> Noah's original example works as expected, and the comparison with Web
>> sites also seems to be working.
>
> Works for me, too. Thanks!
Guess I can close this now.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#74055: 31.0.50; color-lighten-name not lightening black
2024-11-04 12:35 ` Gerd Möllmann
@ 2024-11-04 13:31 ` Eli Zaretskii
0 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2024-11-04 13:31 UTC (permalink / raw)
To: Gerd Möllmann; +Cc: julien, mattias.engdegard, noah, 74055
> From: Gerd Möllmann <gerd.moellmann@gmail.com>
> Cc: julien@danjou.info, mattias.engdegard@gmail.com, noah@splode.com,
> 74055@debbugs.gnu.org
> Date: Mon, 04 Nov 2024 13:35:37 +0100
>
> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>
> >> I hope I fixed that now, please take a look.
> >>
> >> Noah's original example works as expected, and the comparison with Web
> >> sites also seems to be working.
> >
> > Works for me, too. Thanks!
>
> Guess I can close this now.
Please do, and thanks.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2024-11-04 13:31 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-28 8:27 bug#74055: 31.0.50; color-lighten-name not lightening black Gerd Möllmann
2024-10-28 12:39 ` Eli Zaretskii
2024-10-28 15:18 ` Ship Mints
2024-10-28 16:57 ` Mattias Engdegård
2024-10-28 17:24 ` Eli Zaretskii
2024-10-29 4:41 ` Gerd Möllmann
2024-10-29 8:25 ` Gerd Möllmann
2024-10-29 12:54 ` Mattias Engdegård
2024-10-29 18:27 ` Gerd Möllmann
2024-11-02 16:17 ` Eli Zaretskii
2024-11-02 17:10 ` Gerd Möllmann
2024-11-04 12:35 ` Gerd Möllmann
2024-11-04 13:31 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).