[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/autothemer 55db54a2ef 08/29: User parameters added for SVG
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/autothemer 55db54a2ef 08/29: User parameters added for SVG generator |
Date: |
Sun, 28 Aug 2022 22:58:42 -0400 (EDT) |
branch: elpa/autothemer
commit 55db54a2efa84cafdc3ca4e195646264b14190a6
Author: Jason Milkins <jasonm23@gmail.com>
Commit: Jason Milkins <jasonm23@gmail.com>
User parameters added for SVG generator
BUGS in page size calculation.
---
autothemer.el | 93 ++++++++++++++++++++++++++++-------------------
tests/autothemer-tests.el | 19 +++++++++-
2 files changed, 73 insertions(+), 39 deletions(-)
diff --git a/autothemer.el b/autothemer.el
index 5f97e60168..83547ec708 100644
--- a/autothemer.el
+++ b/autothemer.el
@@ -433,12 +433,19 @@ Optionally supply OPTIONS, a plist (all keys are
optional):
:swatch-height - px spacing height of a color swatch (default: 150)
:columns - number of columns for each palette row (default: 6)
:page-template - see page-template below
+ :page-top-margin - (default ...)
+ :page-right-margin - (default ...)
+ :page-bottom-margin - (default ...)
+ :page-left-margin - (default ...)
+ :h-space - (default ...)
+ :v-space - (default ...)
:swatch-template - see swatch-template below
:font-family - font name to use in the generated SVG
- :bg-color - background color
- :text-color - text color
- :text-accent-color - text color
- :svg-out-file - SVG output filename
+ :bg-color
+ :text-color
+ :text-accent-color
+ :swatch-border-color
+ :svg-out-file
For advanced customization the :page-template and :swatch-template can be
used to provide customize the SVG templates.
@@ -462,9 +469,10 @@ Swatch Template parameters:
%1$s - x
%2$s - y
- %3$s - swatch-color
- %4$s - text-color
- %5$s - swatch-color-name"
+ %3$s - swatch-border-color
+ %4$s - swatch-color
+ %5$s - text-accent-color
+ %6$s - swatch-color-name"
(interactive)
(autothemer--plist-bind
(theme-file
@@ -476,14 +484,22 @@ Swatch Template parameters:
swatch-height
columns
+ page-top-margin
+ page-right-margin
+ page-bottom-margin
+ page-left-margin
+
page-template
swatch-template
font-family
+
bg-color
text-color
text-accent-color
-
+ swatch-border-color
+ h-space
+ v-space
svg-out-file)
options
(let ((theme-file (or theme-file (read-file-name "Select autothemer theme
.el file: "))))
@@ -528,34 +544,35 @@ Swatch Template parameters:
|")))
(autotheme-name (autothemer--theme-name autothemer--current-theme))
- (theme-name (or theme-name
- (autothemer--theme-name
autothemer--current-theme)))
- (theme-description (or theme-description
- (autothemer--theme-description
autothemer--current-theme)))
- (theme-url (or theme-url
- (lm-homepage theme-file)
- (read-string "Enter theme URL: "
"https://github.com/")))
(colors (autothemer--theme-colors autothemer--current-theme))
- (font-family (or font-family
- (read-string "Font family name: " "Helvetica
Neue")))
- (swatch-width (or swatch-width
- 100))
- (swatch-height (or swatch-height
- 150))
- (columns (or columns
- 6))
- ;; TODO: Width and Height padding (55, 120) parameterized?
- (width (+ 55 (* columns swatch-width)))
- (height (+ 120 (* (/ (length colors) columns) swatch-height)))
- (background-color (or bg-color
- (autothemer--color-value
- (autothemer--select-color "Select
Background color: "))))
- (text-color (or text-color
- (autothemer--color-value
- (autothemer--select-color "Select Text color:
"))))
- (text-accent-color (or text-accent-color
- (autothemer--color-value
- (autothemer--select-color "Select Text
accent color: "))))
+ (theme-name (or theme-name (autothemer--theme-name
autothemer--current-theme)))
+ (theme-description (or theme-description
(autothemer--theme-description autothemer--current-theme)))
+ (theme-url (or theme-url (lm-homepage theme-file)
(read-string "Enter theme URL: " "https://github.com/")))
+
+ (font-family (or font-family (read-string "Font
family name: " "Helvetica Neue")))
+ (swatch-width (or swatch-width (read-number "Swatch
width: " 100)))
+ (swatch-height (or swatch-height (read-number "Swatch
height: " 150)))
+ (columns (or columns (read-number "Number or
columns: " 6)))
+ (page-top-margin (or page-top-margin (read-number "Page Top
margin: " 120)))
+ (page-bottom-margin (or page-bottom-margin (read-number "Page
Bottom margin: " 60)))
+ (page-left-margin (or page-left-margin (read-number "Page Left
margin: " 30)))
+ (page-right-margin (or page-right-margin (read-number "Page
Right margin: " 30)))
+ (h-space (or h-space (read-number "Swatch
horiztonal spacing: " 10)))
+ (v-space (or v-space (read-number "Swatch
vertical spacing: " 10)))
+
+ (rows (/ (length colors) columns))
+ (width (+ page-right-margin page-left-margin
+ (* (- 1 columns) h-space)
+ (* columns swatch-width)))
+ (height (+ page-top-margin page-bottom-margin
+ (* v-space (- 1 rows))
+ (* rows swatch-height)))
+
+ (background-color (or bg-color
(autothemer--color-value (autothemer--select-color "Select Background color:
"))))
+ (text-color (or text-color
(autothemer--color-value (autothemer--select-color "Select Text color: "))))
+ (text-accent-color (or text-accent-color
(autothemer--color-value (autothemer--select-color "Select Text accent color:
"))))
+ (swatch-border-color (or swatch-border-color
(autothemer--color-value (autothemer--select-color "Select swatch border color:
"))))
+
(svg-out-file (or svg-out-file (read-file-name (format "Enter a
Filename to save SVG palette for %s." theme-name))))
(svg-swatches (string-join
(-map-indexed
@@ -565,12 +582,12 @@ Swatch Template parameters:
(replace-regexp-in-string
(concat autotheme-name "-")
""
(format "%s"
(autothemer--color-name it)))))
- (x (+ 20 (* swatch-width (% index
columns))))
- (y (+ 90 (* swatch-height (/ index
columns)))))
+ (x (+ page-left-margin (* (+ h-space
swatch-width) (% index columns))))
+ (y (+ page-top-margin (* (+ v-space
swatch-height) (/ index columns)))))
(format swatch-template
x
y
- background-color
+ swatch-border-color
color
text-accent-color
name)))
diff --git a/tests/autothemer-tests.el b/tests/autothemer-tests.el
index 0462131ba3..60476e2e8c 100644
--- a/tests/autothemer-tests.el
+++ b/tests/autothemer-tests.el
@@ -91,7 +91,24 @@
"Check autothemer-let-palette"
(should (string=
"#781210"
- (autothemer-let-palette example-red)))))
+ (autothemer-let-palette example-red))))
+
+ (ert-deftest autothemer-plist-bind ()
+ "Test plist-bind"
+ (autothemer--plist-bind (a b) '(:a 1 :b 2)
+ (should (eql a 1))
+ (should (eql b 2))))
+
+ (ert-deftest autothemer-colorize-alist ()
+ "Check autothemer-colorize-alist."
+ (should (equal '(("example-red" . "#781210")
+ ("example-green" . "#22881F")
+ ("example-blue" . "#212288")
+ ("example-purple" . "#812FFF")
+ ("example-yellow" . "#EFFE00")
+ ("example-orange" . "#E06500")
+ ("example-cyan" . "#22DDFF"))
+ (autothemer-colorize-alist)))))
;;; Example theme in memory:
'(#s(autothemer--theme
- [nongnu] elpa/autothemer updated (96ca493b9f -> f3a23b4b6d), ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer e0b1c2c0ad 01/29: Add autothemer-let-palette, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer aa63d8cd5e 02/29: Add github test workflow and tests. Fail expected due to display type., ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 04a4fad366 03/29: Make sure package dash is available., ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer b1124883ef 04/29: +x bin/setup, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 0d39a92d90 07/29: Fix naming of README.md, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer a528436677 16/29: 0.2.10, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer b0df7578fc 17/29: Additional parameters for svg generator., ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 5d7ae3a0be 06/29: Rainbow mode: Colorize names from palette, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 55db54a2ef 08/29: User parameters added for SVG generator,
ELPA Syncer <=
- [nongnu] elpa/autothemer 12dbb2e605 15/29: Merge branch 'master' into develop, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 67224c4a4c 21/29: Fix test run, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 726d5b99bb 05/29: Only supporting 26.1 and above, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 2b55532e0a 10/29: Fix test runner, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer f4ab56f44f 13/29: Structural change v-stacking, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 9bde5000f4 19/29: CONTRIBUTING.md, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 0b558a7cab 20/29: Update autothemer.el, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 882fd8f7bb 22/29: Update README, bin/test & SVG swatch sort hue-sat, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 77ad2ec093 23/29: Trigger actions for pushes to master, or PRs, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 1bc52d721d 27/29: Add issue templates, ELPA Syncer, 2022/08/28