GNU bug report logs -
#41544
26.3; Possible incorrect results from color-distance
Previous Next
Full log
Message #112 received at 41544 <at> debbugs.gnu.org (full text, mbox):
6 juni 2020 kl. 20.15 skrev Drew Adams <drew.adams <at> oracle.com>:
> +(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.
This bug report was last modified 4 years and 304 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.