diff options
| -rw-r--r-- | lisp/faces.el | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lisp/faces.el b/lisp/faces.el index f6b9593b9df..2480aaaf146 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -1794,6 +1794,11 @@ on which one provides better contrast with COLOR." | |||
| 1794 | (color-values color))) | 1794 | (color-values color))) |
| 1795 | "#ffffff" "black")) | 1795 | "#ffffff" "black")) |
| 1796 | 1796 | ||
| 1797 | (defconst color-luminance-dark-limit 0.325 | ||
| 1798 | "The relative luminance below which a color is considered 'dark', | ||
| 1799 | in the sense that white text is more readable than black with the | ||
| 1800 | color as background. This value was determined experimentally.") | ||
| 1801 | |||
| 1797 | (defun color-dark-p (rgb) | 1802 | (defun color-dark-p (rgb) |
| 1798 | "Whether RGB is more readable against white than black. | 1803 | "Whether RGB is more readable against white than black. |
| 1799 | RGB is a 3-element list (R G B), each component in the range [0,1]. | 1804 | RGB is a 3-element list (R G B), each component in the range [0,1]. |
| @@ -1814,7 +1819,7 @@ contrast colour with RGB as background and as foreground." | |||
| 1814 | (g (expt sg 2.2)) | 1819 | (g (expt sg 2.2)) |
| 1815 | (b (expt sb 2.2)) | 1820 | (b (expt sb 2.2)) |
| 1816 | (y (+ (* r 0.2126) (* g 0.7152) (* b 0.0722)))) | 1821 | (y (+ (* r 0.2126) (* g 0.7152) (* b 0.0722)))) |
| 1817 | (< y (eval-when-compile (expt 0.6 2.2))))) | 1822 | (< y color-luminance-dark-limit))) |
| 1818 | 1823 | ||
| 1819 | (declare-function xw-color-defined-p "xfns.c" (color &optional frame)) | 1824 | (declare-function xw-color-defined-p "xfns.c" (color &optional frame)) |
| 1820 | 1825 | ||