Function: color-blend
color-blend is an autoloaded and byte-compiled function defined in
color.el.gz.
Signature
(color-blend A B &optional ALPHA)
Documentation
Blend the two colors A and B in linear space with ALPHA.
A and B should be lists (RED GREEN BLUE), where each element is between 0.0 and 1.0, inclusive. ALPHA controls the influence A has on the result and should be between 0.0 and 1.0, inclusive.
For instance:
(color-blend '(1 0.5 1) '(0 0 0) 0.75)
=> (0.75 0.375 0.75)
Probably introduced at or before Emacs version 31.1.
Source Code
;; Defined in /usr/src/emacs/lisp/color.el.gz
;;;###autoload
(defun color-blend (a b &optional alpha)
"Blend the two colors A and B in linear space with ALPHA.
A and B should be lists (RED GREEN BLUE), where each element is
between 0.0 and 1.0, inclusive. ALPHA controls the influence A
has on the result and should be between 0.0 and 1.0, inclusive.
For instance:
(color-blend \\='(1 0.5 1) \\='(0 0 0) 0.75)
=> (0.75 0.375 0.75)"
(setq alpha (or alpha 0.5))
(let (blend)
(dotimes (i 3)
(push (+ (* (nth i a) alpha) (* (nth i b) (- 1 alpha))) blend))
(nreverse blend)))