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

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

[elpa] externals/beardbolt 16f887917b 252/323: Improve rainbow color sel


From: ELPA Syncer
Subject: [elpa] externals/beardbolt 16f887917b 252/323: Improve rainbow color selection algorithm
Date: Thu, 9 Mar 2023 10:58:36 -0500 (EST)

branch: externals/beardbolt
commit 16f887917b6a89e6a3e3b08e585d972ae6a4844b
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Improve rainbow color selection algorithm
    
    * rmsbolt.el (rmsbolt--rainbowize): Improve color selection
    algorithm.
---
 rmsbolt.el | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/rmsbolt.el b/rmsbolt.el
index 98c79fd394..b570d1c8d3 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -1349,17 +1349,25 @@ Argument ASM-LINES input lines."
   (let* ((background-hsl
           (apply #'color-rgb-to-hsl (color-name-to-rgb (face-background 
'default))))
          all-ovs
-         (idx -1)
-         (total (hash-table-count line-mappings)))
+         (idx 0)
+         ;; The 1+ helps us keep our hue distance from the actual
+         ;; background color
+         (total (1+ (hash-table-count line-mappings))))
     (maphash
      (lambda (src-line asm-regions)
        (when (not (zerop src-line))
          (cl-loop
           with color =
           (apply #'color-rgb-to-hex
-                 (color-hsl-to-rgb (/ (* 1.0 (cl-incf idx)) total)
-                                   (cl-second background-hsl)
-                                   (cl-third background-hsl)))
+                 (color-hsl-to-rgb (mod (+ (cl-first background-hsl)
+                                           (/ (cl-incf idx) (float total)))
+                                        1)
+                                   (min (max (cl-second background-hsl)
+                                             0.25)
+                                        0.8)
+                                   (min (max (cl-third background-hsl)
+                                             0.25)
+                                        0.8)))
           for (beg . end) in (cl-getf asm-regions :positions)
           for asm-ov = (make-overlay beg end)
           do



reply via email to

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