emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/focus eeb12d8db8 19/82: Added function to generate color b


From: ELPA Syncer
Subject: [nongnu] elpa/focus eeb12d8db8 19/82: Added function to generate color based on `focus-dimness'
Date: Tue, 6 Sep 2022 04:58:55 -0400 (EDT)

branch: elpa/focus
commit eeb12d8db89064cc07092b289a8c8436eabdf449
Author: Lars Tveito <larstvei@ifi.uio.no>
Commit: Lars Tveito <larstvei@ifi.uio.no>

    Added function to generate color based on `focus-dimness'
---
 focus.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/focus.el b/focus.el
index f8bbe8378f..e20356f4af 100644
--- a/focus.el
+++ b/focus.el
@@ -69,6 +69,17 @@ of RGB values of the given colors."
          (avg    (mapcar (lambda (v) (/ v len)) sums)))
     (apply 'color-rgb-to-hex avg)))
 
+(defun focus-make-dim-color ()
+  "Uses `focus-dimness' to determine how dim a color that should
+be generated, and returns this color."
+  (let ((background (face-attribute 'default :background))
+        (foreground (face-attribute 'default :foreground))
+        (backgrounds (if (> focus-dimness 0)    focus-dimness  1))
+        (foregrounds (if (< focus-dimness 0) (- focus-dimness) 1)))
+    (apply 'focus-average-colors
+           (append (make-list backgrounds background)
+                   (make-list foregrounds foreground)))))
+
 (defun focus-move-focus ()
   "If `focus-mode' is enabled, this command fires after each
 command, and moves the dimming overlays."
@@ -84,9 +95,7 @@ are invisible until `focus-move-focus' is run. It adds
 focus-move-focus to `post-command-hook'."
   (setq focus-pre-overlay  (make-overlay (point-min) (point-min))
         focus-post-overlay (make-overlay (point-max) (point-max)))
-  (let ((color (focus-average-colors
-                (face-attribute 'default :foreground)
-                (face-attribute 'default :background))))
+  (let ((color (focus-make-dim-color)))
     (mapc (lambda (o) (overlay-put o 'face (cons 'foreground-color color)))
           (list focus-pre-overlay focus-post-overlay)))
   (add-hook 'post-command-hook 'focus-move-focus nil t))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]