From 4def9b711509c48665d7390cccfd324423b4b3ec Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Tue, 28 May 2019 10:13:43 +0200 Subject: Tweak diff faces again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now with an actual formula to compute blends 🙌 Will probably tweak refined faces again to tone the color down. --- helpers.el | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 helpers.el (limited to 'helpers.el') diff --git a/helpers.el b/helpers.el new file mode 100644 index 0000000..4cd07c7 --- /dev/null +++ b/helpers.el @@ -0,0 +1,41 @@ +(defun my/color-mix (color-1 color-2 ratio) + (let* ((c1 (color-name-to-rgb color-1)) + (c2 (color-name-to-rgb color-2)) + (mix (-zip-with + (lambda (i1 i2) (+ (* ratio i1) + (* (- 1 ratio) i2))) + c1 c2))) + (apply 'color-rgb-to-hex `(,@mix 2)))) + +;; Alternate implementation without -zip-with from dash. +(defun my/color-mix (color-1 color-2 ratio) + (let* ((c1 (color-name-to-rgb color-1)) + (c2 (color-name-to-rgb color-2)) + (mix (seq-map + (lambda (pair) (+ (* ratio (car pair)) + (* (- 1 ratio) (cdr pair)))) + (cl-pairlis c1 c2)))) + (apply 'color-rgb-to-hex `(,@mix 2)))) + +;; Diff faces. + +(list-colors-display + (seq-map (lambda (r) (my/color-mix "gray20" "steelblue2" r)) + (number-sequence 0.0 1.0 0.01)) + "*steelblues*") + +(list-colors-display + (seq-map (lambda (r) (my/color-mix "gray20" "orange2" r)) + (number-sequence 0.0 1.0 0.01)) + "*oranges*") + +;; background: +(my/color-mix "gray20" "orange2" 0.9) +(my/color-mix "gray20" "steelblue2" 0.9) +(my/color-mix "gray20" "gold2" 0.9) +(my/color-mix "gray20" "maroon2" 0.9) +;; refined: +(my/color-mix "gray20" "orange2" 0.6) +(my/color-mix "gray20" "steelblue2" 0.6) +(my/color-mix "gray20" "gold2" 0.6) +(my/color-mix "gray20" "maroon2" 0.6) -- cgit v1.2.3