From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#41544: 26.3; Possible incorrect results from color-distance Date: Fri, 29 May 2020 17:17:41 +0200 Message-ID: References: <5C4A633D-8222-4439-BE37-9B8674F1DA6D@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_67070B8E-0C26-4D1D-B8AF-7A37D74DD869" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="130289"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Tom Tromey , 41544@debbugs.gnu.org To: Simon Pugnet Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 29 17:18:11 2020 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 1jeglv-000XqQ-9B for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 May 2020 17:18:11 +0200 Original-Received: from localhost ([::1]:52690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeglu-0007pL-Af for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 May 2020 11:18:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeglm-0007on-7S for bug-gnu-emacs@gnu.org; Fri, 29 May 2020 11:18:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44269) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jegll-0000Qj-U0 for bug-gnu-emacs@gnu.org; Fri, 29 May 2020 11:18:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jegll-0004B8-Oj for bug-gnu-emacs@gnu.org; Fri, 29 May 2020 11:18:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 May 2020 15:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41544 X-GNU-PR-Package: emacs Original-Received: via spool by 41544-submit@debbugs.gnu.org id=B41544.159076546916040 (code B ref 41544); Fri, 29 May 2020 15:18:01 +0000 Original-Received: (at 41544) by debbugs.gnu.org; 29 May 2020 15:17:49 +0000 Original-Received: from localhost ([127.0.0.1]:55815 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeglZ-0004AZ-Cu for submit@debbugs.gnu.org; Fri, 29 May 2020 11:17:49 -0400 Original-Received: from mail237c50.megamailservers.eu ([91.136.10.247]:59656 helo=mail56c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeglX-0004AK-04; Fri, 29 May 2020 11:17:47 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1590765465; bh=6AGewmx6FJbCD16+LEByyLmfff9r5+BfFD/QIb88nqs=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=qkBXcIij+X4b8i0nNpHJOwpjAUrtVGHm6SYyMEU5KU7Xd/KQKN6VwUf1p+DyhiFKp pGMYxjLkhCTRKqSvjXqKuAQjwGpYu9FXbqDNYKwFbxk952KXLru+jMpuzLDVzerSAI JZUyHDsqXeHyVbLYsM0Ri4UOJ+8sHcbIGW1yKk1E= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-4e4ae655.032-75-73746f71.bbcust.telenor.se [85.230.74.78]) (authenticated bits=0) by mail56c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 04TFHfUm028844; Fri, 29 May 2020 15:17:43 +0000 In-Reply-To: <5C4A633D-8222-4439-BE37-9B8674F1DA6D@acm.org> X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F1C.5ED12751.006D:SCFSTAT68638221, ss=1, re=-4.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: -4.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=UqsdyN4B c=1 sm=1 tr=0 a=klNLuyVZdLUgl+K5Uafb2A==:117 a=klNLuyVZdLUgl+K5Uafb2A==:17 a=M51BFTxLslgA:10 a=L-gs6BjLIPZIF3TP3vUA:9 a=CjuIK1q_8ugA:10 a=fNRX9wVF-h2nzrGUox4A:9 a=B2y7HmGcmWMA:10 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" Xref: news.gmane.io gmane.emacs.bugs:181191 Archived-At: --Apple-Mail=_67070B8E-0C26-4D1D-B8AF-7A37D74DD869 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii tags 41544 patch stop Try the attached patch. A couple of constants used for comparison were = recomputed, but since they mostly appeared to have been picked out of = thin air, I didn't bother attempting a very precise translation. --Apple-Mail=_67070B8E-0C26-4D1D-B8AF-7A37D74DD869 Content-Disposition: attachment; filename=0001-Make-color-distance-into-a-proper-distance-metric-bu.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Make-color-distance-into-a-proper-distance-metric-bu.patch" Content-Transfer-Encoding: quoted-printable =46rom=20f0eab8ad402baf8c4c790e685e84f3f89b1d6ecd=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Fri,=2029=20May=202020=2017:07:59=20+0200=0A= Subject:=20[PATCH]=20Make=20color-distance=20into=20a=20proper=20= distance=20metric=20(bug#41544)=0A=0AThe=20previous=20function=20= discarded=20bits=20in=20the=20arguments,=20was=20not=0Asymmetric,=20and=20= did=20not=20obey=20the=20triangle=20equality;=20the=20return=20value=0A= was=20quadratic=20in=20the=20perceived=20colour=20distance=20instead=20= of=20linear.=0A=0AReported=20by=20Simon=20Pugnet.=0A=0A*=20src/xfaces.c=20= (color_distance):=20Use=20all=2016=20bits=20per=20channel=20and=0Aadd=20= the=20missing=20square=20root=20operation.=0A(TTY_SAME_COLOR_THRESHOLD,=20= syms_of_xfaces):=0A*=20lisp/textmodes/css-mode.el=20= (css--contrasty-color):=0AUpdate=20colour=20distance=20constants=20to=20= values=20appropriate=20for=20the=20new=0Afunction.=0A---=0A=20etc/NEWS=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=206=20++++++=0A= =20lisp/textmodes/css-mode.el=20|=20=204=20++--=0A=20src/xfaces.c=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20|=2022=20+++++++++++-----------=0A=20= 3=20files=20changed,=2019=20insertions(+),=2013=20deletions(-)=0A=0Adiff=20= --git=20a/etc/NEWS=20b/etc/NEWS=0Aindex=2064cf0abbdb..d8470223e5=20= 100644=0A---=20a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-489,6=20+489,12=20= @@=20Use=20macro=20'with-current-buffer-window'=20with=20action=20alist=20= entry=20'body-function'.=0A=20**=20Some=20libraries=20obsolete=20since=20= Emacs=2023=20have=20been=20removed:=0A=20'ledit.el',=20'lmenu.el',=20= 'lucid.el=20and=20'old-whitespace.el'.=0A=20=0A+---=0A+**=20The=20= 'color-distance'=20function=20is=20now=20a=20proper=20distance=20metric.=0A= +It=20was=20previously=20not=20symmetric,=20nor=20did=20it=20obey=20the=20= triangle=20equality.=0A+The=20default=20value=20of=20the=20= 'face-near-same-color-threshold'=20variable=20has=0A+been=20updated=20to=20= a=20number=20that=20roughly=20corresponds=20to=20the=20same=20distance.=0A= +=0A=20=0C=0A=20*=20Lisp=20Changes=20in=20Emacs=2028.1=0A=20=0Adiff=20= --git=20a/lisp/textmodes/css-mode.el=20b/lisp/textmodes/css-mode.el=0A= index=200035c5e7b0..eda739a397=20100644=0A---=20= a/lisp/textmodes/css-mode.el=0A+++=20b/lisp/textmodes/css-mode.el=0A@@=20= -1156,8=20+1156,8=20@@=20css--contrasty-color=0A=20with=20NAME;=20in=20= particular=20so=20that=20if=20NAME=20is=20used=20as=20a=20background=0A=20= color,=20the=20returned=20color=20can=20be=20used=20as=20the=20= foreground=20and=20still=0A=20be=20readable."=0A-=20=20;;=20See=20= bug#25525=20for=20a=20discussion=20of=20this.=0A-=20=20(if=20(>=20= (color-distance=20name=20"black")=20292485)=0A+=20=20;;=20See=20= bug#25525=20and=20bug#41544=20for=20a=20discussion=20of=20this.=0A+=20=20= (if=20(>=20(color-distance=20name=20"black")=20138500)=0A=20=20=20=20=20=20= =20"black"=20"white"))=0A=20=0A=20(defcustom=20css-fontify-colors=20t=0A= diff=20--git=20a/src/xfaces.c=20b/src/xfaces.c=0Aindex=20= 7d7aff95c1..e828c12f09=20100644=0A---=20a/src/xfaces.c=0A+++=20= b/src/xfaces.c=0A@@=20-218,6=20+218,7=20@@=20Copyright=20(C)=20= 1993-1994,=201998-2020=20Free=20Software=20Foundation,=20Inc.=0A=20= #include=20=0A=20#include=20=0A=20#include=20= "sysstdio.h"=0A+#include=20=0A=20#include=20=0A=20= #include=20=0A=20=0A@@=20-4356,15=20+4357,14=20@@=20= color_distance=20(Emacs_Color=20*x,=20Emacs_Color=20*y)=0A=20=0A=20=20=20= =20=20=20See=20=20for=20more=20= info.=20=20*/=0A=20=0A-=20=20long=20r=20=3D=20(x->red=20=20=20-=20= y->red)=20=20=20>>=208;=0A-=20=20long=20g=20=3D=20(x->green=20-=20= y->green)=20>>=208;=0A-=20=20long=20b=20=3D=20(x->blue=20=20-=20y->blue)=20= =20>>=208;=0A-=20=20long=20r_mean=20=3D=20(x->red=20+=20y->red)=20>>=20= 9;=0A+=20=20long=20long=20r=20=3D=20x->red=20=20=20-=20y->red;=0A+=20=20= long=20long=20g=20=3D=20x->green=20-=20y->green;=0A+=20=20long=20long=20= b=20=3D=20x->blue=20=20-=20y->blue;=0A+=20=20long=20long=20r_mean=20=3D=20= (x->red=20+=20y->red)=20>>=201;=0A=20=0A-=20=20return=0A-=20=20=20=20= (((512=20+=20r_mean)=20*=20r=20*=20r)=20>>=208)=0A-=20=20=20=20+=204=20*=20= g=20*=20g=0A-=20=20=20=20+=20(((767=20-=20r_mean)=20*=20b=20*=20b)=20>>=20= 8);=0A+=20=20return=20(int)=20sqrt=20((((2=20*=2065536=20+=20r_mean)=20*=20= r=20*=20r)=20>>=2016)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20+=204=20*=20g=20*=20g=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20+=20(((2=20*=2065536=20+=2065535=20-=20= r_mean)=20*=20b=20*=20b)=20>>=2016));=0A=20}=0A=20=0A=20=0A@@=20-4931,9=20= +4931,9=20@@=20DEFUN=20("face-attributes-as-vector",=20= Fface_attributes_as_vector,=0A=20=0A=20/*=20If=20the=20distance=20(as=20= returned=20by=20color_distance)=20between=20two=20colors=20is=0A=20=20=20= =20less=20than=20this,=20then=20they=20are=20considered=20the=20same,=20= for=20determining=0A-=20=20=20whether=20a=20color=20is=20supported=20or=20= not.=20=20The=20range=20of=20values=20is=200-65535.=20=20*/=0A+=20=20=20= whether=20a=20color=20is=20supported=20or=20not.=20=20*/=0A=20=0A= -#define=20TTY_SAME_COLOR_THRESHOLD=20=2010000=0A+#define=20= TTY_SAME_COLOR_THRESHOLD=20=2025000=0A=20=0A=20#ifdef=20= HAVE_WINDOW_SYSTEM=0A=20=0A@@=20-7008,7=20+7008,7=20@@=20syms_of_xfaces=20= (void)=0A=20=0A=20Lisp=20programs=20that=20change=20the=20value=20of=20= this=20variable=20should=20also=0A=20clear=20the=20face=20cache,=20see=20= `clear-face-cache'.=20=20*/);=0A-=20=20face_near_same_color_threshold=20= =3D=2030000;=0A+=20=20face_near_same_color_threshold=20=3D=2044300;=0A=20= =0A=20#ifdef=20HAVE_WINDOW_SYSTEM=0A=20=20=20defsubr=20= (&Sbitmap_spec_p);=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_67070B8E-0C26-4D1D-B8AF-7A37D74DD869--