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

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

[elpa] externals/face-shift 80ed3c9ee2 17/50: added missing cl-lib depen


From: ELPA Syncer
Subject: [elpa] externals/face-shift 80ed3c9ee2 17/50: added missing cl-lib dependency
Date: Sun, 30 Apr 2023 12:03:19 -0400 (EDT)

branch: externals/face-shift
commit 80ed3c9ee2a2aa16ed455c83d6fda21645bf4c1c
Author: Philip K <philip@warpmail.net>
Commit: Philip K <philip@warpmail.net>

    added missing cl-lib dependency
---
 face-shift.el | 51 ++++++++++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/face-shift.el b/face-shift.el
index fbb7bbe44d..7b73147627 100644
--- a/face-shift.el
+++ b/face-shift.el
@@ -3,7 +3,7 @@
 ;; Author: Philip K. <philip@warpmail.net>
 ;; Version: 0.1.0
 ;; Keywords: faces
-;; Package-Requires: ((emacs "24.1"))
+;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
 ;; URL: https://git.sr.ht/~zge/face-shift
 
 ;; This file is NOT part of Emacs.
@@ -16,8 +16,8 @@
 
 ;;; Commentary:
 ;;
-;; `face-shift-by' generates a function that linearly shifts all faces
-;; in `face-shift-faces'.
+;; `face-shift--shift' generates a function that shifts all faces in
+;; `face-shift-faces'.
 ;;
 ;; To use face shift, add a function generated by `face-shift' to a hook
 ;; of your choice like so:
@@ -44,19 +44,19 @@ Note that it might be necessary to change the value of
 `face-shift-intensity' to get the intended effect."
   :type 'boolean)
 
-(defcustom face-shift-intensity 0.25
+(defcustom face-shift-intensity 0.75
   "Value to replace a `int' symbol with in `face-shift-color'."
   :type 'float)
 
 (defcustom face-shift-color
-  '((red . 0)
-    (cyan . 180)
-    (blue . 240)
-    (pink . 300)
-    (yellow . 60)
-    (peach . 40)
-    (green . 120)
-    (purple . 280))
+  `((red . ,(* 2 pi (/ 0 360.0)))
+    (cyan . ,(* 2 pi (/ 180 360.0)))
+    (blue . ,(* 2 pi (/ 240 360.0)))
+    (pink . ,(* 2 pi (/ 300 360.0)))
+    (yellow . ,(* 2 pi (/ 60 360.0)))
+    (peach . ,(* 2 pi (/ 40 360.0)))
+    (green . ,(* 2 pi (/ 120 360.0)))
+    (purple . ,(* 2 pi (/ 280 360.0))))
   "Alist of matrices representing RGB transformations.
 Symbols `int', `max' and `min' are substituted with
 `face-shift-intensity', `face-shift-maximum' and
@@ -75,30 +75,31 @@ Symbols `int', `max' and `min' are substituted with
   :type '(list face)
   :group 'face-shift)
 
-(defun face-shift-by (face prop hue)
+(defun face-shift--shift (face prop hue)
   "Calculate color distortion and apply to property PROP of FACE.
 MAT describes the linear transformation that calculates the new
 color. If property PROP is not a color, nothing is changed."
   (let* ((intensity (if face-shift-inverted
-                           (- 1 face-shift-intensity)
+                        (- 1 face-shift-intensity)
                       face-shift-intensity))
          (bg (face-attribute face prop)))
     (unless (eq bg 'unspecified)
-         (let* ((color-rgb (color-name-to-rgb bg))
-                        (color-hsl (apply #'color-rgb-to-hsl color-rgb))
-                        (new-rgb (apply #'color-hsl-to-rgb
-                                                        (list (/ hue 360.0)
-                                                                  
face-shift-intensity
-                                                                  (nth 2 
color-hsl))))
-                        (ncolor (apply #'color-rgb-to-hex new-rgb)))
-               (face-remap-add-relative face `(,prop ,ncolor))))))
+         (let* ((rgb (color-name-to-rgb bg))
+                        (hsl (apply #'color-rgb-to-hsl rgb))
+             (hsl* (list (sqrt (* hue (nth 0 hsl)))
+                         intensity
+                                                (nth 2 hsl)))
+                        (rgb* (apply #'color-hsl-to-rgb hsl*))
+                        (shift (apply #'color-rgb-to-hex rgb*)))
+        (message "shift %s/%s %d to %s" face prop hue shift)
+               (face-remap-add-relative face `(,prop ,shift))))))
 
 (defun face-shift (color &optional ignore)
   "Produce a function that will shift face color.
 
 All background and foreground color behind the faces listed in
 `face-shift-faces' will be attempted to shift using
-`face-shift-by'. The generated function can then be added to a
+`face-shift--shift'. The generated function can then be added to a
 hook. COLOR should index a transformation from the
 `face-shift-color' alist.
 
@@ -113,8 +114,8 @@ added to is ‘mail-mode’ or a derivative."
     (lambda ()
       (unless (cl-some #'derived-mode-p ignore)
         (dolist (face face-shift-faces)
-          (face-shift-by face :foreground hue)
-          (face-shift-by face :background hue))))))
+          (face-shift--shift face :foreground hue)
+          (face-shift--shift face :background hue))))))
 
 (provide 'face-shift)
 



reply via email to

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