[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/svg-lib 472b1f9dc6 4/5: Refactor date icons to use a ge
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/svg-lib 472b1f9dc6 4/5: Refactor date icons to use a generic box icon |
|
Date: |
Wed, 22 Nov 2023 03:58:38 -0500 (EST) |
branch: externals/svg-lib
commit 472b1f9dc6fb740926fdbcfe48652bc01bf67cbd
Author: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Commit: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Refactor date icons to use a generic box icon
---
svg-lib.el | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/svg-lib.el b/svg-lib.el
index e440508aa1..7a5fec09c8 100644
--- a/svg-lib.el
+++ b/svg-lib.el
@@ -67,6 +67,9 @@
;;; NEWS:
+;; Version 0.2.8
+;; - No background for icon when background color is nil
+
;; Version 0.2.7
;; - Added a dynamic date icon
@@ -635,18 +638,41 @@ and style elements ARGS."
(svg-lib--image svg :ascent svg-ascent)))
+
(defun svg-lib-date (&optional date style &rest args)
"Create a two lines date icon showing given DATE, using given
STYLE and style elements ARGS."
+ (let* ((date (or date (current-time)))
+ (month (upcase (format-time-string "%b" date)))
+ (day (format-time-string "%d" date)))
+ (apply 'svg-lib-box month day style args)))
+
+(defun svg-lib-week-date (&optional date style &rest args)
+ "Create a two lines date icon showing given DATE, using given
+STYLE and style elements ARGS."
+
+ (let* ((date (or date (current-time)))
+ (week (format-time-string "%W" date)))
+ (apply 'svg-lib-box "WEEK" week style args)))
+
+(defun svg-lib-day-date (&optional date style &rest args)
+ "Create a two lines date icon showing given DATE, using given
+STYLE and style elements ARGS."
+
+ (let* ((weekday (upcase (format-time-string "%a" date)))
+ (day (format-time-string "%d" date)))
+ (apply 'svg-lib-box weekday day style args)))
+
+
+(defun svg-lib-box (top bottom &optional style &rest args)
+ "Create a two lines icon showing given TOP and BOTTOM text, using
+given STYLE and style elements ARGS."
+
(let* ((default svg-lib-style-default)
(style (if style (apply #'svg-lib-style nil style) default))
(style (if args (apply #'svg-lib-style style args) style))
- (date (or date (current-time)))
- (month (upcase (format-time-string "%b" date)))
- (day (format-time-string "%d" date))
-
(foreground (plist-get style :foreground))
(background (plist-get style :background))
(alignment (plist-get style :alignment))
@@ -695,7 +721,7 @@ STYLE and style elements ARGS."
(- tag-width stroke)
(- (/ tag-height 2) stroke)
:fill background :rx 0)
- (svg-text svg month
+ (svg-text svg top
:font-family font-family
:font-weight "bold"
:font-size (* font-size 0.9)
@@ -703,7 +729,7 @@ STYLE and style elements ARGS."
:text-anchor "middle"
:x (/ svg-width 2)
:y "+0.95em")
- (svg-text svg day
+ (svg-text svg bottom
:font-family font-family
:font-weight "bold"
:font-size (* font-size 1.7)