From: Noah Friedman <noah@splode.com>
To: 54514@debbugs.gnu.org
Subject: bug#54514: incorrect arithmetic in color-lighten-hsl?
Date: Mon, 21 Mar 2022 16:31:01 -0700 (PDT) [thread overview]
Message-ID: <20220321163101.477162.FMU1355@unexploded-cow.prv.splode.com> (raw)
(Any branch or release; this function in color.el looks to be unchanged
since it was originally introduced)
I might be mistaken, but I think color-lighten-hsl is wrong. It's
increasing luminance by an absolute percent of 1, not the present
luminance.
Suppose you want to lighten the color "red":
(color-name-to-rgb "red")
=> (1.0 0.0 0.0)
(color-rgb-to-hsl 1.0 0.0 0.0)
=> (0.0 1.0 0.5)
If you try to lighten this by, say, 50%, currently the result is
(color-lighten-hsl 0.0 1.0 0.5 50)
=> (0.0 1.0 1.0)
Which is clearly wrong. 50% lighter red is not white!
The result I would have expected to see is
=> (0.0 1.0 0.75)
Currently, the function reads:
(defun color-lighten-hsl (H S L percent)
...
(list H S (color-clamp (+ L (/ percent 100.0)))))
I think it should be:
(defun color-lighten-hsl (H S L percent)
...
(list H S (color-clamp (+ L (* L (/ percent 100.0))))))
Could someone sanity check me? My color theory background is pretty weak.
next reply other threads:[~2022-03-21 23:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-21 23:31 Noah Friedman [this message]
2022-03-22 14:28 ` bug#54514: incorrect arithmetic in color-lighten-hsl? Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220321163101.477162.FMU1355@unexploded-cow.prv.splode.com \
--to=noah@splode.com \
--cc=54514@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).