mirror of
https://github.com/larstvei/Focus.git
synced 2024-11-26 11:38:32 +00:00
Improved average color function
It assumed to receive hex-strings, fixed with using color-name-to-rgb instead.
This commit is contained in:
parent
e691113e4b
commit
8028fc088f
@ -1,3 +1,5 @@
|
|||||||
|
(require 'cl-lib)
|
||||||
|
|
||||||
(defvar-local focus-pre-overlay nil)
|
(defvar-local focus-pre-overlay nil)
|
||||||
(defvar-local focus-post-overlay nil)
|
(defvar-local focus-post-overlay nil)
|
||||||
|
|
||||||
@ -7,13 +9,13 @@
|
|||||||
(defun focus-search-forward (regex)
|
(defun focus-search-forward (regex)
|
||||||
(save-excursion (re-search-forward regex nil t)))
|
(save-excursion (re-search-forward regex nil t)))
|
||||||
|
|
||||||
(defun focus-hexstr-to-int (str)
|
(defun focus-average-colors (color &rest colors)
|
||||||
(read (concat "#x" (substring str 1))))
|
(let* ((colors (cons color colors))
|
||||||
|
(colors (mapcar 'color-name-to-rgb colors))
|
||||||
(defun focus-average-colors (hstr1 hstr2 &rest hstrs)
|
(len (length colors))
|
||||||
(let* ((strs (cons hstr1 (cons hstr2 hstrs)))
|
(sums (apply 'cl-mapcar '+ colors))
|
||||||
(avg (/ (apply '+ (mapcar 'focus-hexstr-to-int strs)) 2)))
|
(avg (mapcar (lambda (v) (/ v len)) sums)))
|
||||||
(format "#%X" avg)))
|
(apply 'color-rgb-to-hex avg)))
|
||||||
|
|
||||||
(defun focus-move-focus ()
|
(defun focus-move-focus ()
|
||||||
(let* ((pre (or (focus-search-backward "^\n") (point-min)))
|
(let* ((pre (or (focus-search-backward "^\n") (point-min)))
|
||||||
|
Loading…
Reference in New Issue
Block a user