[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/focus 8028fc088f 04/82: Improved average color function
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/focus 8028fc088f 04/82: Improved average color function |
Date: |
Tue, 6 Sep 2022 04:58:54 -0400 (EDT) |
branch: elpa/focus
commit 8028fc088f6fb13411db835e5399e973e9a194cc
Author: Lars Tveito <larstvei@ifi.uio.no>
Commit: Lars Tveito <larstvei@ifi.uio.no>
Improved average color function
It assumed to receive hex-strings, fixed with using color-name-to-rgb
instead.
---
focus-mode.el | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/focus-mode.el b/focus-mode.el
index 47d6825e4c..7e876d72e6 100644
--- a/focus-mode.el
+++ b/focus-mode.el
@@ -1,3 +1,5 @@
+(require 'cl-lib)
+
(defvar-local focus-pre-overlay nil)
(defvar-local focus-post-overlay nil)
@@ -7,13 +9,13 @@
(defun focus-search-forward (regex)
(save-excursion (re-search-forward regex nil t)))
-(defun focus-hexstr-to-int (str)
- (read (concat "#x" (substring str 1))))
-
-(defun focus-average-colors (hstr1 hstr2 &rest hstrs)
- (let* ((strs (cons hstr1 (cons hstr2 hstrs)))
- (avg (/ (apply '+ (mapcar 'focus-hexstr-to-int strs)) 2)))
- (format "#%X" avg)))
+(defun focus-average-colors (color &rest colors)
+ (let* ((colors (cons color colors))
+ (colors (mapcar 'color-name-to-rgb colors))
+ (len (length colors))
+ (sums (apply 'cl-mapcar '+ colors))
+ (avg (mapcar (lambda (v) (/ v len)) sums)))
+ (apply 'color-rgb-to-hex avg)))
(defun focus-move-focus ()
(let* ((pre (or (focus-search-backward "^\n") (point-min)))
- [nongnu] elpa/focus 5f3f20e7f2 80/82: Bump version, (continued)
- [nongnu] elpa/focus 5f3f20e7f2 80/82: Bump version, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 155da77a32 60/82: Fixes #14, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus cbba87b062 74/82: Trim candidate list of *things*, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 0a6e9624ea 49/82: Allow for changing the current thing interactively, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 90806dc7ea 18/82: Added custom variable for setting dimness, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 704db49988 82/82: Merge pull request #24 from phikal/master, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus c89d08f510 24/82: Applied purcell's recommendations, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 94ed8ab68b 36/82: Defined variables to help hide the cursor, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus e8c1eb5ce2 16/82: Added short commentary, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 75202c9445 58/82: Version bump, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 8028fc088f 04/82: Improved average color function,
ELPA Syncer <=
- [nongnu] elpa/focus e9ab37b865 81/82: Improved user option types, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus aa5ea31118 65/82: Fixed package lint warnings., ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus a80b7b6eba 71/82: Add possibility of customizing the face of the focused region, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 1c664fb992 17/82: Added installation section, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus bf5fcff0d0 69/82: Allow setting a color for dimmed text. Fixes #21, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus f310fa1c31 52/82: Split up `focus-move-focus', ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 5e483363ac 75/82: New README, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 6b9620a73d 44/82: Added section on `focus-read-only-mode' in README, ELPA Syncer, 2022/09/06