bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#61188: 30.0.50; color-lighten-name seems not to work


From: Stephen Berman
Subject: bug#61188: 30.0.50; color-lighten-name seems not to work
Date: Mon, 30 Jan 2023 23:58:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

On Mon, 30 Jan 2023 21:48:20 +0000 "Mark Bestley" <gnu@bestley.co.uk> wrote:

> Look at the results of
>
> (require 'color)
> (message "reduce by 100 = %s" (color-lighten-name "Black" 100))
> (message "reduce by 0 = %s" (color-lighten-name "Black" 0))
>
> In emacs 28.2 they give "#ffffffffffff" and 0 as expected.
> In emacs 30.0.50 they give 0 and 0

This difference is due to this commit:

commit 656c2dd66e77a5fbeb99d358017e8327401fae05
Author:     Lars Ingebrigtsen <larsi@gnus.org>
Commit:     Lars Ingebrigtsen <larsi@gnus.org>
CommitDate: Tue Mar 22 15:28:02 2022 +0100

    Fix color-lighten-hsl logic

    * lisp/color.el (color-lighten-hsl): Lighten by percentage,
    instead of just adding the specified number to the luminance
    element (bug#54514).

The patch below restores the Emacs 28 result for the above examples
while keeping the desired result for the example in bug#54514, but I
have no idea if it yields undesirable results in other cases.

Steve Berman

diff --git a/lisp/color.el b/lisp/color.el
index f68cf5e6b17..a251b1a24a0 100644
--- a/lisp/color.el
+++ b/lisp/color.el
@@ -407,7 +407,7 @@ color-lighten-hsl
 Given a color defined in terms of hue, saturation, and luminance
 \(arguments H, S, and L), return a color that is PERCENT lighter.
 Returns a list (HUE SATURATION LUMINANCE)."
-  (list H S (color-clamp (+ L (* L (/ percent 100.0))))))
+  (list H S (color-clamp (+ L (* (if (> L 0) L 1) (/ percent 100.0))))))

 (defun color-lighten-name (name percent)
   "Make a color with a specified NAME lighter by PERCENT.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]