bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#41544: 26.3; Possible incorrect results from color-distance


From: Drew Adams
Subject: bug#41544: 26.3; Possible incorrect results from color-distance
Date: Sun, 7 Jun 2020 09:00:34 -0700 (PDT)

> > +(defun color-dark-p (rgb)
> > +  "Whether RGB is more readable against white than black.
> > +RGB is a 3-element list (R G B), each component in the range [0,1]."
> 
> > The predicate name suggests it's about testing a
> > color (via RGB) to determine whether it's dark or
> > light.
> >
> > The doc string suggests it's specifically about
> > the readability of _foreground_ text that is of
> > that color - specifically whether it's more
> > readable against a white than a black background.
> 
> Thank you, this actually raises a good point.
> 
> The predicate should work with the argument both as a foreground and as a
> background colour, for selecting a black or white contrasting colour. The
> assumption is that the same predicate can be used for both, which may be
> wrong, but absent evidence to the contrary, I think it is a reasonable one to
> make.
> 
> If you are in doubt, see if you can come up with a colour for which it does
> not hold. For example, if you find a rare shade of beige that when used for
> text looks better against a white background, but when used as a background
> prefers black text. I have yet to do so, much less been able to articulate it
> formally as an algorithm.
> 
> I agree that this could be stated more explicitly in the doc string.

1. Please do consider stating the behavior more explicitly
in the doc.

2. I don't have any special knowledge or suggestion about
whether the same criteria should be used for light and dark
foreground/background.  I'd think that the comparison would
need to use the complement of the foreground or background,
a priori.  E.g. if a background is 90% light then what
works as a "readable" dark foreground would lead to a light
foreground that is more or less similarly "readable" when
against a 90% dark background.
___

In my own work, when I supply a default foreground or
background for a face, I typically do this:

I start with a light background (my own setup uses LightBlue
- somewhat light), and I pick a color that seems reasonable
enough for the foreground default - by eyeball.  Then I
check it against the default (emacs -Q) background - again,
by eyeball.

Once I've picked a default foreground color for a light
`background-mode', I take its complement (using `hexrgb.el')
as the default foreground for a dark background.  I check
that with emacs -Q.  (I use a light background in my setup,
and I don't spend a lot of energy trying to get a great
default for a dark background.)

In my experience (feedback from users), complementing works
pretty well.  And since, in my setup, I use a background
that's only somewhat light, it gives a pretty good idea of
what works (according to my eyes) for a complemented
(hence somewhat dark) background.

No idea whether any of this info helps you, but it's
what I do.  I don't use color-distance in this endeavor.





reply via email to

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