;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/color-incal.el (defun color-p (c) (and (integerp c) (<= 0 c) (< c 256) )) (defun blue-p (r g b) (unless (and (color-p r) (color-p g) (color-p b) ) (error "Bogus data") ) (let*((min-adv 64) (rg (ceiling (/ (+ r g) 2.0))) (diff (- b rg)) (rg-diff (- r g)) ) (and (<= min-adv diff) (< -64 rg-diff) (< rg-diff 32) ))) (defun all-blue () (cl-member-if (lambda (c) (blue-p (/ (nth 0 #1=(color-values c)) #2=256) (/ (nth 1 #1#) #2#) (/ (nth 2 #1#) #2#)) (defined-colors)))) ;; (all-blue) ;; (blue-p 0 0 64) ; t ;; (blue-p 1 0 64) ; nil ;; (blue-p 191 191 255) ; t ;; (blue-p 191 192 255) ; nil (provide 'color-incal)