From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: /srv/bzr/emacs/trunk r102478: shr.el (shr-tag-color-check):Convert colors to hexadecimal with shr-color->hexadecimal. Date: Tue, 23 Nov 2010 16:12:32 -0800 Message-ID: <4A76DA00C61D4637AC671E53FB7A4FCB@us.oracle.com> References: <961v6bom3j.fsf@fencepost.gnu.org> <87eiabdc04.fsf@stupidchicken.com><87ipznhhe3.fsf@keller.adm.naquadah.org><87mxoz7mml.fsf@stupidchicken.com> <874ob71y6v.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1290557671 17035 80.91.229.12 (24 Nov 2010 00:14:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 24 Nov 2010 00:14:31 +0000 (UTC) To: "'Lars Magne Ingebrigtsen'" , Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 24 01:14:27 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PL30D-0003Ds-Mh for ged-emacs-devel@m.gmane.org; Wed, 24 Nov 2010 01:14:25 +0100 Original-Received: from localhost ([127.0.0.1]:42470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PL30C-0003Vz-Qs for ged-emacs-devel@m.gmane.org; Tue, 23 Nov 2010 19:14:24 -0500 Original-Received: from [140.186.70.92] (port=46812 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PL304-0003Va-1t for emacs-devel@gnu.org; Tue, 23 Nov 2010 19:14:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PL2zu-0005jl-As for emacs-devel@gnu.org; Tue, 23 Nov 2010 19:14:16 -0500 Original-Received: from rcsinet10.oracle.com ([148.87.113.121]:30509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PL2zu-0005jb-4F for emacs-devel@gnu.org; Tue, 23 Nov 2010 19:14:06 -0500 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id oAO0E2Bm016935 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 24 Nov 2010 00:14:03 GMT Original-Received: from acsmt354.oracle.com (acsmt354.oracle.com [141.146.40.154]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id oAO0DxVg011786; Wed, 24 Nov 2010 00:14:00 GMT Original-Received: from abhmt003.oracle.com by acsmt353.oracle.com with ESMTP id 807714221290557554; Tue, 23 Nov 2010 16:12:34 -0800 Original-Received: from dradamslap1 (/10.159.218.132) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 23 Nov 2010 16:12:34 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: AcuLXrYwDPwI2+ACS+eeIVWSe2sMYwABa7QQ X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:133102 Archived-At: > > I see. Why not just use hexrgb.el (or build on it)? It's > > been around long enough that such teething problems should > > have been eliminated. > > ... > color-lab computes a "distance" between black and a blue > hue that is readable... > > So it doesn't have much to do with hexrgb.el, I think. Dunno. Such a particular color distance computation is I guess complementary to what is in hexrgb.el. But in general that is the kind of thing that hexrgb.el does. For example, `hexrgb-complement' returns the complement of a given color. Taking the difference between the hue values of two colors gives you a hue distance, and so on. That kind of color distance is already there - nothing to be done. You can easily combine these kinds of distance in some way - e.g. A * hue-dist + B * saturation-dist + C * value-dist = my-dist. You seem to be describing something oriented toward a particular application: "just distant enough to improve readability" or some such. It would not be off-topic for hexrgb to include such a color-distance metric. I just haven't needed that so I haven't added it. If it is decided to include hexrgb.el in Emacs then we could add such a function to hexrgb.el if the function is fairly general. Or we could add it elsewhere (e.g. gnus) and just use hexrgb.el for its definition (or not). It sounds like the real task for your function is the design: just what kind of distance function do you want? You mention "readable", so that could be one criterion of use. But the devil might well be in the details (influence of dark/light backgrounds, human eye characteristics, etc.) Certainly you can already use hexrgb.el to calculate the distance between two colors in terms of any color components. The question is what you want to do with such a difference: what distance is a good one for something to be "readable enough", etc. hexrgb.el has an approximately-equal function that you can use for this kind of thing (not approximatly equal = sufficiently distant), passing an appropriate fuzz factor. For instance, I do something similar in my palette.el code, in order to determine when a color is essentially the same as its complement. When that's the case I change the cursor color to an alternative color that stands out better against that color as background. You might look at hexrgb.el to see if you can use the functions there to define what you need. Just a suggestion. In sum, this sounds hexrgb.el-like to me, and I cannot tell whether what you want is already available using what is in hexrgb.el.