;;; -*- lexical-binding: t -*- (require 'cl-lib) (cl-pushnew "." load-path :test #'string=) (require 'luki-lisp) (cl-defmethod bad-blend ((_ symbol) (_ symbol)) (bad-color-norm "black")) (cl-defmethod bad-blend ((_ symbol) (c string)) (bad-color-norm c)) (cl-defmethod bad-blend ((c string) (_ symbol)) (bad-color-norm c)) (cl-defmethod bad-blend ((c1 string) (c2 string)) (cl-loop with cols1 = (bad-color-decimal c1) with cols2 = (bad-color-decimal c2) with w = 0.5625 with (r g b) = (color-blend cols1 cols2 w) with res = (color-rgb-to-hex r g b) return res)) (cl-defmethod bad-color-decimal ((col string)) (cl-loop with cols = (color-values col) with deci = (mapcar (L (e) (* e (/ 1.0 65535))) cols) return deci)) (cl-defmethod bad-color-clamp ((val number) &optional (mini 0.0) (maxi 1.0)) (min maxi (max mini val))) (cl-defmethod bad-color-norm ((c sequence)) (cl-loop with cols = (cond ((su c) (color-name-to-rgb c)) ((lu c) (take 3 c))) with (r g b) = (mapcar (L (e) (bad-color-clamp e)) cols) with normhex = (color-rgb-to-hex r g b) return normhex)) (cl-defmethod bad-col+ ((c1 sequence) (c2 sequence)) (cl-loop with c1n = (bad-color-norm c1) with c2n = (bad-color-norm c2) with (r1 g1 b1) = (bad-color-decimal c1n) with (r2 g2 b2) = (bad-color-decimal c2n) with sum = (list (+ r1 r2) (+ g1 g2) (+ b1 b2)) with sumn = (bad-color-norm sum) return sumn)) (cl-defmethod bad-col* ((k float) (col sequence)) (cl-loop with normc = (bad-color-norm col) with normv = (bad-color-decimal normc) with norme = (mapcar (L (v) (* k v)) normv) with normr = (bad-color-norm norme) return normr)) (<- 'bad-color-norm)