From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ship Mints Newsgroups: gmane.emacs.bugs Subject: bug#74055: 31.0.50; color-lighten-name not lightening black Date: Mon, 28 Oct 2024 11:18:22 -0400 Message-ID: References: <86plnk766i.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000060a3c406258afb7c" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29538"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Gerd =?UTF-8?Q?M=C3=B6llmann?= , Julien Danjou , Noah Friedman , 74055@debbugs.gnu.org, Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 28 16:21:29 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t5RYe-0007S9-1I for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Oct 2024 16:21:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RXi-0001oZ-6a; Mon, 28 Oct 2024 11:20:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RXe-0001iT-1X for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2024 11:20:26 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5RXd-0001D2-Nr for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2024 11:20:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:From:In-Reply-To:References:MIME-Version:To:Subject; bh=EGFZ6AbaX2LeOZsJlviGiIdFn71E8XweTdV+lOhLBVY=; b=ZfGpLicDNmkqEExUTFF7ryAir+W7CSW25ieAytWJnObl/Qw/i1rr5k4FHVejT2SHDKYcZ/0KtWp6s8X7V4NnC8xXRUx8UU9ibceorrcY3p6xVlviZ6auhc3D3hJQBbuA6aSZLhd45OPa6luk7VtK3uC/BMuDz0+MBvdoCX/robIMFCxiVGGZvTp7SZnY/4SKCrKzRXi8iJgTVwqzkyktcy0jHf8QnJXdQ593ScECqC9KGkLuT4wr8kIY397Enpudgj7jzT9m+y+22tOe6ihoFaLCar5yjXkuBpQjLkVuyrqOyTSrzCvyTx5xzQTGu+Fg1XJ0UsIyTUxQsfGS70yaxA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t5RYD-0005lM-Uc for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2024 11:21:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ship Mints Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Oct 2024 15:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74055 X-GNU-PR-Package: emacs Original-Received: via spool by 74055-submit@debbugs.gnu.org id=B74055.173012881321722 (code B ref 74055); Mon, 28 Oct 2024 15:21:01 +0000 Original-Received: (at 74055) by debbugs.gnu.org; 28 Oct 2024 15:20:13 +0000 Original-Received: from localhost ([127.0.0.1]:54390 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5RXQ-0005eI-K5 for submit@debbugs.gnu.org; Mon, 28 Oct 2024 11:20:13 -0400 Original-Received: from mail-oi1-f174.google.com ([209.85.167.174]:44175) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5RXO-0005eA-Dm for 74055@debbugs.gnu.org; Mon, 28 Oct 2024 11:20:11 -0400 Original-Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3e606cba08eso2594406b6e.0 for <74055@debbugs.gnu.org>; Mon, 28 Oct 2024 08:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730128713; x=1730733513; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=EGFZ6AbaX2LeOZsJlviGiIdFn71E8XweTdV+lOhLBVY=; b=bW/0AgvTorPISEaxgD11Ha/O+UoeBHDrVgVYc6sUJDGiczv3P7ygyAmR8eXLNB+yjI BZ4xzU1tHcYWWDf5l2riCYvS+Au2fyIec441KNg0174raF0Yc8UH9WUPVi8714W0aBIH w1Vhdl43Dvgyk+b/RNV+1yI1aPfO+PBSLgvs6FxHaDt757kv0Mz5FGj5IKYzBkbE1Q/Y CjhXLEe+KXLngfjfZVhwiVQiLn91asYhlKB9RVSbIUmZEMYSAXTjPTbSISVhAszalIiE 80EZhT8lbFlh6AvwtGFNJYjiUNrLjV+pocA7GT7lwKOiAOpq72FM391hqs+xHZ0qy3Vz MR3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128713; x=1730733513; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EGFZ6AbaX2LeOZsJlviGiIdFn71E8XweTdV+lOhLBVY=; b=dj1hQ8DFaI7y5UtmUzb2HB9kwAe2JNrBu4coRBX8kg/BD3wiVRFOvAr9iktQ1gnZzS VVKijb6F6YiHOu6qKQJWpT8DynfQsIcIKtTyNAbN/rlSCvrl3WhM0HO1tI2m2gMpKXtM pKzBzkwefWoJWr9+DU8Wb8YHEiVdsC4USNZnnJphp/A3uA15J62gb9zR9llluJ/J1+/0 2nyKxmAqvFuIQRRWZnrxYhGWfsCF1BxnmfrZHFKpa7ME3zzPOzCuzUgzvM5wmI+VVu8p aqeKjTkmuxGon7Mc157txSJcpOvcQCZksKl4rvxuB1hJP4N0J8lbMgaqaQjWutX7lOzR yxnA== X-Forwarded-Encrypted: i=1; AJvYcCXCv26SyoSGri7OAdhvss8/+LQHdHx7RswMntHC+KjeWwEo/KKKUMKgVjvTgm+eZrDr3pfD7Q==@debbugs.gnu.org X-Gm-Message-State: AOJu0YxYinJ4MiS6kygfZ/7EaTw1dtoO+Vh7CSB+FLeR3mJLmWboyYc0 1Cey9o0itjekGpQ/2PW+Hddod8eV+Ch9yK9ckEivHOU3FJcMIYMKxQWyFprrWvx218l/Y0C+3rF bboaZGDChWs7UMDxsIFAGtQEGa98= X-Google-Smtp-Source: AGHT+IGBYmL1Xd0voX5ScGjf2B+1+lkVm7RYFXD37rUPoig+VYr+UDCP84KapZp/boweN2s6JgplhcraWV+w1Gy5UGI= X-Received: by 2002:a05:6808:1924:b0:3e2:8483:dbe3 with SMTP id 5614622812f47-3e6384901a2mr7326742b6e.35.1730128713390; Mon, 28 Oct 2024 08:18:33 -0700 (PDT) In-Reply-To: <86plnk766i.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:294434 Archived-At: --00000000000060a3c406258afb7c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=E2=80=AFAM Eli Zaretskii wrote: > > From: Gerd M=C3=B6llmann > > 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) > > =3D> "#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. > > > > --00000000000060a3c406258afb7c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I use below to compute adjusted colors given that lighten doesn't wo= rk when black multipliers are all zero.

(defun my/color-rgb-transform-by-frac (c1 c2 fra= c)
=C2=A0 "Compute RGB color from C1 adjusted closer to C2 by FRAC.=
FRAC is a floating-point number between 0 and 1."
=C2=A0 (cl-de= structuring-bind (c1-r c1-g c1-b) c1
=C2=A0 =C2=A0 (cl-destructuring-bin= d (c2-r c2-g c2-b) c2
=C2=A0 =C2=A0 =C2=A0 (list (+ c1-r (* (- c2-r c1-r= ) frac))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (+ c1-g (* (- c2-g c1= -g) frac))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (+ c1-b (* (- c2-b = c1-b) frac))))))

(defun my/color-hex-transform-by-frac (c1 c2 frac)<= br>=C2=A0 "Compute hex color from C1 adjusted closer to C2 by FRAC.FRAC is a floating-point number between 0 and 1."
=C2=A0 (apply #&= #39;color-rgb-to-hex
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(my/color-rgb-tra= nsform-by-frac (color-name-to-rgb c1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(color-name-to-rgb c2)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0frac)))

=
;; e.g.,
=
(my/color-hex-= transform-by-frac "black"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 "white"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0.10) ; prod= uces=C2=A0"#199919991999"
(color-lighten-name "black" 10) ; = produces=C2=A0"#000000000000"

On Mon, Oct 28, 2024 at 8:40= =E2=80=AFAM Eli Zaretskii <eliz@gnu.org<= /a>> wrote:
&= gt; From: Gerd M=C3=B6llmann <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:
>
>=C2=A0 =C2=A0(color-lighten-name "#000000" 50)
>=C2=A0 =C2=A0=3D> "#000000000000"
>
> I think there is even a test that checks that, in color-tests.el:
>
> (ert-deftest color-tests-lighten-name ()
>=C2=A0 =C2=A0(should (equal (color-lighten-name "black" 100) = "#000000000000"))
>
> I don't understand this, and it is different from what I'd exp= ect, and
> tools for the web return, for example
>
>=C2=A0 =C2=A0https://mdigi.tools/lighten-color/#000000=

Our notion of "lighten color" seems to be to increase the color&#= 39;s
luminance by P percent.=C2=A0 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" t= o
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.=C2=A0 But maybe Noah's interpretation of "lighten"= was
incorrect, and we should revert that change?=C2=A0 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.



--00000000000060a3c406258afb7c--