summaryrefslogtreecommitdiff
path: root/helpers.el
diff options
context:
space:
mode:
Diffstat (limited to 'helpers.el')
-rw-r--r--helpers.el41
1 files changed, 41 insertions, 0 deletions
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)