[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ef-themes 41b9acb843: Use updated modus-themes formula
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/ef-themes 41b9acb843: Use updated modus-themes formula for contrast tables |
|
Date: |
Fri, 17 Nov 2023 00:57:58 -0500 (EST) |
branch: externals/ef-themes
commit 41b9acb843d306c7658c55c5bf45c3367ae203f5
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Use updated modus-themes formula for contrast tables
I made this change in commit b410fcc in the modus-themes repo. The
idea is to avoid the use of the cl-loop and other cl- functions that
we don't really need.
---
contrast-ratios.org | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/contrast-ratios.org b/contrast-ratios.org
index 6fe30c5c38..b56aea0b13 100644
--- a/contrast-ratios.org
+++ b/contrast-ratios.org
@@ -7,20 +7,27 @@ Check this files Git history for updates.
Evaluate these snippets, otherwise the tables will not work. Then
update a table by typing =C-c C-c= with point at the =#+TBLFM:= line.
-#+begin_src emacs-lisp
+#+begin_src emacs-lisp :results output silent
;; Copied from my `modus-themes'.
;; This is the WCAG formula to measure relative luminance:
;; <https://www.w3.org/TR/WCAG20-TECHS/G18.html>.
+(defun modus-themes--wcag-contribution (channel weight)
+ "Return the CHANNEL contribution to overall luminance given WEIGHT."
+ (* weight
+ (if (<= channel 0.03928)
+ (/ channel 12.92)
+ (expt (/ (+ channel 0.055) 1.055) 2.4))))
+
(defun modus-themes-wcag-formula (hex)
"Get WCAG value of color value HEX.
-The value is defined in hexadecimal RGB notation, such as those in
-`modus-themes-operandi-colors' and `modus-themes-vivendi-colors'."
- (cl-loop for k in '(0.2126 0.7152 0.0722)
- for x in (color-name-to-rgb hex)
- sum (* k (if (<= x 0.03928)
- (/ x 12.92)
- (expt (/ (+ x 0.055) 1.055) 2.4)))))
+The value is defined in hexadecimal RGB notation, such #123456."
+ (let ((channels (color-name-to-rgb hex))
+ (weights '(0.2126 0.7152 0.0722))
+ contribution)
+ (while channels
+ (push (modus-themes--wcag-contribution (pop channels) (pop weights))
contribution))
+ (apply #'+ contribution)))
;;;###autoload
(defun modus-themes-contrast (c1 c2)
| [Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/ef-themes 41b9acb843: Use updated modus-themes formula for contrast tables,
ELPA Syncer <=