]> git.eshelyaron.com Git - emacs.git/commit
Improved light/dark colour predicate (bug#41544)
authorMattias Engdegård <mattiase@acm.org>
Wed, 10 Jun 2020 17:18:58 +0000 (19:18 +0200)
committerMattias Engdegård <mattiase@acm.org>
Wed, 10 Jun 2020 18:11:13 +0000 (20:11 +0200)
commit68ae6faa7f1b4c348740667f98fbf1d1ce5a7979
tree2a1e1c310ad97110a9f691d29b5e51505fa7418b
parentb19259c8412ee2e715c4bd145711e23729411fd0
Improved light/dark colour predicate (bug#41544)

Add a predicate, color-dark-p, for deciding whether a colour is more
readable with black or white as contrast.  It has experimentally been
shown to be more accurate and robust than the various methods
currently employed.

The new predicate compares the relative luminance of the colour to an
empirically determined cut-off value, and it seems to get it right in
almost all cases, with no value leading to outright bad results.

* lisp/faces.el (readable-foreground-color): Use color-dark-p.
(color-dark-p): New function.
* lisp/facemenu.el (list-colors-print): Use readable-foreground-color,
improving readability of list-colors-display.
* lisp/textmodes/css-mode.el (css--contrasty-color): Remove.
(css--fontify-region): Use readable-foreground-color.
lisp/facemenu.el
lisp/faces.el
lisp/textmodes/css-mode.el