From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#25890: `color-values` gives wrong value Date: Fri, 03 Mar 2017 16:16:47 +0200 Message-ID: <83wpc6la28.fsf@gnu.org> References: <87zih7n2yt.fsf@pank.eu> <83r32jpr8b.fsf@gnu.org> <87bmtnryqr.fsf@drachen> <87d1e2tzt5.fsf@pank.eu> <8337eypb5l.fsf@gnu.org> <87vartx4qd.fsf@drachen> <56bad9de-8111-4962-a9e9-2dbf0084e004@default> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1488550699 7883 195.159.176.226 (3 Mar 2017 14:18:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 3 Mar 2017 14:18:19 +0000 (UTC) Cc: michael_heerdegen@web.de, 25890@debbugs.gnu.org, rasmus@gmx.us To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 03 15:18:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjo28-0001Om-Hv for geb-bug-gnu-emacs@m.gmane.org; Fri, 03 Mar 2017 15:18:12 +0100 Original-Received: from localhost ([::1]:58354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjo2E-0001mJ-G4 for geb-bug-gnu-emacs@m.gmane.org; Fri, 03 Mar 2017 09:18:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjo23-0001kC-Sh for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2017 09:18:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjo1x-0007dO-V6 for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2017 09:18:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39363) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjo1x-0007dJ-Rt for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2017 09:18:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cjo1x-0006RM-LU for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2017 09:18:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 03 Mar 2017 14:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25890 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25890-submit@debbugs.gnu.org id=B25890.148855064424711 (code B ref 25890); Fri, 03 Mar 2017 14:18:01 +0000 Original-Received: (at 25890) by debbugs.gnu.org; 3 Mar 2017 14:17:24 +0000 Original-Received: from localhost ([127.0.0.1]:37562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjo1K-0006QU-Vd for submit@debbugs.gnu.org; Fri, 03 Mar 2017 09:17:24 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:53157) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjo1I-0006QH-M9 for 25890@debbugs.gnu.org; Fri, 03 Mar 2017 09:17:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjo1C-0007KO-34 for 25890@debbugs.gnu.org; Fri, 03 Mar 2017 09:17:15 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:55964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjo15-0007ID-Nb; Fri, 03 Mar 2017 09:17:07 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2964 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cjo14-0000nJ-HA; Fri, 03 Mar 2017 09:17:07 -0500 In-reply-to: <56bad9de-8111-4962-a9e9-2dbf0084e004@default> (message from Drew Adams on Tue, 28 Feb 2017 15:54:46 -0800 (PST)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:130109 Archived-At: > Date: Tue, 28 Feb 2017 15:54:46 -0800 (PST) > From: Drew Adams > Cc: 25890@debbugs.gnu.org, Rasmus > > > > (defun color-rgb-to-hex (red green blue) > > > "Return hexadecimal notation for the color RED GREEN BLUE. > > > RED, GREEN, and BLUE should be numbers between 0.0 and 1.0, inclusive." > > > - (format "#%02x%02x%02x" > > > - (* red 255) (* green 255) (* blue 255))) > > > + (format "#%04x%04x%04x" > > > + (* red 65535) (* green 65535) (* blue 65535))) > > The function should accept an optional arg NB-DIGITS, which > specifies the number of hex digits for each of R, G, B. And > yes, it should default to 4 digits: #RRRRGGGGBBBB. > > (That's what the original function in hexrgb.el does, from > which color.el was supposedly derived.) The code in hexrgb.el produces strange results in this regard (e.g., it produces "#FFFFFFFFE0E0" instead of "#FFFFFFFFE000" for the color mentioned by the OP). I believe that's because it interprets the conversion between 2 and 4 hex digits incorrectly: the 2 hex digits are the _most_ significant bits of the 4-digit version, not the LSB. But I did add such an optional argument to color-rgb-to-hex, with the difference that its value can only be either 4 or 2, as I see no reason for anyone to want a 12-bit per component color notations. Thanks.