Function: readable-foreground-color

readable-foreground-color is a byte-compiled function defined in faces.el.gz.

Signature

(readable-foreground-color COLOR)

Documentation

Return a readable foreground color for background COLOR.

The returned value is a string representing black or white, depending on which one provides better contrast with COLOR.

Source Code

;; Defined in /usr/src/emacs/lisp/faces.el.gz
(defun readable-foreground-color (color)
  "Return a readable foreground color for background COLOR.
The returned value is a string representing black or white, depending
on which one provides better contrast with COLOR."
  ;; We use #ffffff instead of "white", because the latter is sometimes
  ;; less than white.  That way, we get the best contrast possible.
  (if (color-dark-p (mapcar (lambda (c) (/ c 65535.0))
                            (color-values color)))
      "#ffffff" "black"))