emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: /srv/bzr/emacs/trunk r102478: shr.el (shr-tag-color-check):Convert c


From: Drew Adams
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

> > 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]