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

From: Mattias Engdegård <[email-masked]>
Date: Wed, 3 Jun 2020 22:08:46 +0200

3 juni 2020 kl. 17.59 skrev Eli Zaretskii <[email-masked]>:

> Then I think we should install it.

Thank you; pushed to master.

Now about the consolidation of the contrast colour predicate (color-dark-p): as described previously in detail, the current code for doing so in various places is unsatisfactory. For example, some of the methods employed classify #00ff00 as a "dark" colour, leading to suboptimal results. (Try typing #00ff00 in css-mode.)

There are other bugs that are annoying in themselves, but need to be fixed in order to make progress. Start Emacs in TTY mode with TERM=xterm-color and evaluate (color-name-to-rgb "blue"). Notice how one of the components is greater than 1 -- this is the unfortunate result of several bad decisions.

The attached patch supersedes the previous one; after staring at colour combinations I came to the conclusion that gamma-expansion is a necessity, but the exact sRGB composite gamma curve isn't quite necessary, and a power of 2.2 is close enough.

It also uses a contrasting text colour for the first column in list-colors-display, which serves as a good demonstration of how the predicate works for the standard named colours.