[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/autothemer 64d855aee8 1/2: Select sort, grouping functions
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/autothemer 64d855aee8 1/2: Select sort, grouping functions/ranges + iterate on docs (#26) |
Date: |
Sun, 4 Sep 2022 10:58:08 -0400 (EDT) |
branch: elpa/autothemer
commit 64d855aee8b0a98183ac3cb2ec70857447dd6497
Author: Jason Milkins <jasonm23@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Select sort, grouping functions/ranges + iterate on docs (#26)
* Swatch sorting/grouping | update docs
* Function-reference regenerated tables added
* Cleanup docstrings
---
README.md | 162 ++++++++++++++-------
autothemer.el | 202 ++++++++++++++------------
function-reference.md | 351 +++++++++++++++++++++++++++-------------------
tests/autothemer-tests.el | 147 +++++++++++--------
4 files changed, 525 insertions(+), 337 deletions(-)
diff --git a/README.md b/README.md
index 2fca846fb3..f8e98c94c4 100644
--- a/README.md
+++ b/README.md
@@ -286,8 +286,8 @@ For example:
```lisp
(autothemer-generate-palette-svg
-'(:theme-file "orangey-bits-theme.el"
- :svg-out-file "test.svg"
+'(:theme-file "path/folder/my-autotheme.el"
+ :svg-out-file "path/folder/my-autotheme-palette.svg"
:bg-color "#190700"
:text-color "#FFE0C0"
:text-accent-color "#90776C"
@@ -299,22 +299,31 @@ For example:
#### autothemer-generate-palette-svg options
-| Option | Description
|
-|----------------------|-------------------------------------------------------|
-| `:theme-file` | Theme filename
|
-| `:theme-name` | Override the title found in `:theme-file`
|
-| `:theme-description` | Override the description found in `:theme-file`
|
-| `:theme-url` | Override the url found in `:theme-file`
|
-| `:swatch-width` | px width of a color swatch (default: `100`)
|
-| `:swatch-height` | px height of a color swatch (default: `150`)
|
-| `:columns` | Number of columns for each palette row (default: `6`)
|
-| `:page-template` | See page-template below
|
-| `: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 accent color
|
-| `:svg-out-file` | SVG output filename
|
+| Option | Description
|
+|-----------------------|-------------------------------------------------------|
+| `theme-file` | Theme filename
|
+| `theme-name` | Override the title found in `:theme-file`
|
+| `theme-description` | Override the description found in `:theme-file`
|
+| `theme-url` | Override the url found in `:theme-file`
|
+| `font-family` | Font name to use in the generated SVG
|
+| `columns` | Number of columns for each palette row (default:
`6`) |
+| `bg-color` | Page background color
|
+| `text-color` | Main text color
|
+| `text-accent-color` | Accent text color
|
+| `page-template` | See page-template below
|
+| `page-top-margin` | Top margin of page (Default: `120`)
|
+| `page-right-margin` | Right margin of page (Default: `30`)
|
+| `page-bottom-margin` | Bottom margin of page (Default: `60`)
|
+| `page-left-margin` | Left margin of page (Default: `30`)
|
+| `swatch-template` | See swatch-template below
|
+| `swatch-border-color` | The border color of a color swatch
|
+| `swatch-width` | Px spacing width of a color swatch (default: `100`)
|
+| `swatch-height` | Px spacing height of a color swatch (default: `150`)
|
+| `swatch-rotate` | Degrees of rotation for swatch (default: `45`)
|
+| `h-space` | Horizontal-space between swatches (default: `10`)
|
+| `v-space` | Vertical-space between swatches (default: `10`)
|
+| `sort-palette` | Arrange palette using a function see below
|
+| `svg-out-file` | The file/pathname to save SVG output
|
##### :page-template and :swatch-template
@@ -343,51 +352,108 @@ The builtin page template
```svg
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
-"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="%1$spx" height="%2$spx"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
- <style>
- text {
- font-family: "%3$s";
- fill: %4$s;
- }
- </style>
- <rect x="0" y="0" rx="10" width="%1$spx" height="%2$spx"
id="background-panel" fill="%6$s"/>
- <g transform="translate(14,10)">
- <a xlink:href="%9$s">
- <text style="font-size:42pt;" font-weight="bold" x="3%%" y="50"
id="theme-name">%7$s</text>
- <text style="font-size:12pt;" x="4%%" y="75"
id="theme-description">%8$s</text>
- <text style="font-size:8pt;fill: %5$s" text-anchor="end" x="95%%" y="20"
id="theme-url">%9$s</text>
- </a>
- </g>
- <g transform="translate(70,-40)">
- %10$s
- </g>
+ <style>
+ text {
+ font-family: "%3$s";
+ fill: %4$s;
+ }
+ </style>
+ <rect x="0" y="0" rx="10" width="%1$spx" height="%2$spx"
id="background-panel" fill="%6$s"/>
+ <g transform="translate(14,10)">
+ <a xlink:href="%9$s">
+ <text style="font-size:42pt;" font-weight="bold" x="3%%" y="50"
id="theme-name">%7$s</text>
+ <text style="font-size:12pt;" x="4%%" y="75"
id="theme-description">%8$s</text>
+ <text style="font-size:8pt;fill: %5$s" text-anchor="end" x="95%%"
y="20" id="theme-url">%9$s</text>
+ </a>
+ </g>
+ <g transform="translate(70,-40)">
+ %10$s
+ </g>
</svg>
```
###### Swatch Template parameters
-| Param | Description |
-|--------|---------------------|
-| `%1$s` | `x` |
-| `%2$s` | `y` |
-| `%3$s` | `swatch-color` |
-| `%4$s` | `text-color` |
-| `%5$s` | `swatch-color-name` |
+| Param | Description |
+|--------|-----------------------|
+| `%1$s` | `x` |
+| `%2$s` | `y` |
+| `%3$s` | `swatch-border-color` |
+| `%4$s` | `color` |
+| `%5$s` | `text-accent-color` |
+| `%6$s` | `name` |
+| `%7$s` | `swatch-width` |
+| `%8$s` | `swatch-height` |
+| `%9$s` | `swatch-rotate` |
The builtin swatch template:
``` svg
-<g transform="translate(%1$s,%2$s),rotate(45)">
- <ellipse cx="70" cy="70" rx="45" ry="45" id="background-color" fill="%3$s"/>
- <ellipse cx="70" cy="70" rx="42" ry="42" id="color" fill="%4$s"/>
- <text style="font-size:7pt" font-weight="bold" x="52" y="125"
id="color-name">%6$s</text>
- <text style="font-size:7pt; fill:%5$s;" font-weight="bold" x="52" y="134"
id="color">%4$s</text>
+<g transform="translate(%1$s,%2$s),rotate(%9$s)">
+ <ellipse cx="70" cy="70" rx="45" ry="45" id="background-color"
fill="%3$s"/>
+ <ellipse cx="70" cy="70" rx="42" ry="42" id="color" fill="%4$s"/>
+ <text style="font-size:7pt" font-weight="bold" x="52" y="125"
id="color-name">%6$s</text>
+ <text style="font-size:7pt; fill:%5$s;" font-weight="bold" x="52" y="134"
id="color">%4$s</text>
+ <!-- Rect below is for debug set stroke width to be visible -->
+ <rect x="0" y="0" width="%7$spx" height="%8$spx" class="debug-rect"
fill-opacity="0.0" stroke-width="0.0mm" stroke="#FF8000"/>
</g>
```
+###### Sorting / Grouping palette colors
+
+The option `sort-palette` can be a `sort function`, or a `plist`.
+
+Options is a plist of:
+
+ :group-fn - mandatory group function
+ :group-args - optional group args (to use a non-default group)
+ :sort-fn - optional sort function
+
+###### Sorting:
+
+The sort/ordering functions take args A and B, which are expected
+to be `autothemer--color` structs.
+
+- Darkest to lightest: `autothemer-darkest-order`
+- Lightest to darkest: `autothemer-lightest-order`
+- Hue: `autothemer-hue-order`
+- Saturated to desaturated: `autothemer-saturated-order`
+- Desaturated to saturated: `autothemer-desaturated-order`
+
+###### Grouping
+
+Hue grouping:
+
+ autothemer-hue-group
+
+Builtin hue groups:
+
+ autothemer-hue-groups
+ autothemer-simple-hue-groups
+
+Brightness grouping:
+
+ autothemer-brightness-group
+
+Builtin brightness groups:
+
+ autothemer-dark-mid-light-brightness-groups
+ autothemer-10-percent-brightness-groups
+ autothemer-20-percent-brightness-groups
+
+Saturation grouping:
+
+ autothemer-saturation-group
+
+Builtin saturation groups:
+
+ autothemer-low-mid-high-saturation-groups
+ autothemer-10-percent-saturation-groups
+ autothemer-20-percent-saturation-groups
#### SVG palette templates in the Wiki
diff --git a/autothemer.el b/autothemer.el
index 174f60394e..2aa6480bf0 100644
--- a/autothemer.el
+++ b/autothemer.el
@@ -7,7 +7,7 @@
;; Maintainer: Jason Milkins <jasonm23@gmail.com>
;;
;; URL: https://github.com/jasonm23/autothemer
-;; Version: 0.2.11
+;; Version: 0.2.12
;; Package-Requires: ((dash "2.10.0") (emacs "26.1"))
;;
;;; License:
@@ -42,9 +42,6 @@
;; - Colorize/font-lock palette color names in the buffer
;; - `autothemer-colorize' (requires `rainbow-mode' during development.)
;;
-;;
-;; Note in the function reference, the fucntion prefix `autothemer--'
indicates internal
-;; functions.
;;; Code:
(require 'cl-lib)
(require 'dash)
@@ -519,13 +516,15 @@ Colors are from `autothemer-current-theme'."
(defvar autothemer--colors-font-lock-keywords nil)
(defun autothemer-colorize ()
- "Colorize using rainbow-mode."
+ "In the current buffer, colorize palette color names, from the last
evaluated theme, by their color value."
(interactive)
(setq autothemer--colors-font-lock-keywords
`((,(regexp-opt (mapcar 'car (autothemer--colorize-alist)) 'words)
(0 (rainbow-colorize-by-assoc (autothemer--colorize-alist))))))
(font-lock-add-keywords nil autothemer--colors-font-lock-keywords t))
+;;; Color conversion
+
(defun autothemer--color-to-hsv (rgb)
"Convert RGB, a list of `(r g b)' to list `(h s v)'.
The `r' `g' `b' values can range between `0..65535'.
@@ -563,17 +562,20 @@ In `(h s v)' `h', `s' and `v' are `0.0..1.0'."
(* #x101 (ash (logand #xFF00 rgb) -8))
(* #x101 (logand #xFF rgb)))))
-(defun autothemer-color-hue (hex-color)
- "Return the HSV hue of HEX-COLOR."
- (car (autothemer--color-to-hsv (autothemer-hex-to-rgb hex-color))))
+(defun autothemer-color-hue (color)
+ "Return the HSV hue of COLOR (hex color or autothemer--color struct)."
+ (cond ((stringp color) (car (autothemer--color-to-hsv (autothemer-hex-to-rgb
color))))
+ ((autothemer--color-p color) (autothemer-color-hue
(autothemer--color-value color)))))
-(defun autothemer-color-sat (hex-color)
- "Return the HSV sat of HEX-COLOR."
- (cadr (autothemer--color-to-hsv (autothemer-hex-to-rgb hex-color))))
+(defun autothemer-color-sat (color)
+ "Return the HSV saturation of COLOR (hex color or autothemer--color struct)."
+ (cond ((stringp color) (cadr (autothemer--color-to-hsv
(autothemer-hex-to-rgb color))))
+ ((autothemer--color-p color) (autothemer-color-sat
(autothemer--color-value color)))))
-(defun autothemer-color-brightness (hex-color)
- "Return the HSV brightness of HEX-COLOR."
- (caddr (autothemer--color-to-hsv (autothemer-hex-to-rgb hex-color))))
+(defun autothemer-color-brightness (color)
+ "Return the HSV brightness of COLOR (hex color or autothemer--color struct)."
+ (cond ((stringp color) (caddr (autothemer--color-to-hsv
(autothemer-hex-to-rgb color))))
+ ((autothemer--color-p color) (autothemer-color-brightness
(autothemer--color-value color)))))
;;; Sort/Order of autothemer--color structs.
@@ -595,32 +597,27 @@ In `(h s v)' `h', `s' and `v' are `0.0..1.0'."
(b (autothemer-color-sat (autothemer--color-value b))))
(> a b)))
+(defun autothemer-desaturated-order (a b)
+ "Return t if the saturation of A < B."
+ (let ((a (autothemer-color-sat (autothemer--color-value a)))
+ (b (autothemer-color-sat (autothemer--color-value b))))
+ (< a b)))
+
(defun autothemer-hue-order (a b)
"Return t if the hue of A > B."
(let ((a (autothemer-color-hue (autothemer--color-value a)))
(b (autothemer-color-hue (autothemer--color-value b))))
(> a b)))
-(defun autothemer-hue-sat-order (a b)
- "Return t if the hue and sat of A > B."
- (let ((a-hue (autothemer-color-hue (autothemer--color-value a)))
- (b-hue (autothemer-color-hue (autothemer--color-value b)))
- (a-sat (autothemer-color-sat (autothemer--color-value a)))
- (b-sat (autothemer-color-sat (autothemer--color-value b)))
- (sort-hash-fmt "%016s-%016s"))
- (string> (format sort-hash-fmt a-hue a-sat)
- (format sort-hash-fmt b-hue b-sat))))
-
-(defun autothemer-sort-palette (theme-colors &optional fn)
- "Produce a list of sorted THEME-COLORS using FN.
+(defun autothemer-sort-palette (theme-colors &optional sort-fn group-fn
group-args)
+ "Produce a list of sorted THEME-COLORS using SORT-FN.
+If SORT-FN is nil, sort by default `autothemer-darkest-order'.
+Grouping is supported via GROUP-FN & GROUP-ARGS.
-If FN is nil, sort by default FN `autothemer-darkest-order'.
-
-`autothemer-lightest-order' is available to balance the force.
-
-There are also `autothemer-hue-order' and `autothemer-saturated-order'"
- (let ((fn (or fn 'autothemer-darkest-order)))
- (-sort fn theme-colors)))
+See `autothemer-group-and-sort' for a full list."
+ (let ((sort-fn (or sort-fn 'autothemer-darkest-order))
+ (sorted (-sort sort-fn theme-colors)))
+ sorted))
;; Color Grouping
@@ -740,41 +737,48 @@ GROUPS are produced by `autothemer-group-colors'."
Options is a plist of:
+#TABLE Option - Description #
:group-fn - mandatory group function
:group-args - optional group args (to use a non-default group)
:sort-fn - optional sort function
+#TABLE#
See color grouping functions and group lists:
Hue grouping:
- autothemer-hue-group
-
-Builtin hue groups:
+#TABLE Function - Description #
+ autothemer-hue-group - color hue group for COLOR
+#TABLE#
- autothemer-hue-groups
- autothemer-simple-hue-groups
+#TABLE Hue Groups - Description #
+ autothemer-hue-groups - group colors into major hue groups (default)
+ autothemer-simple-hue-groups - group colors into broad hue groups
+#TABLE#
Brightness grouping:
- autothemer-brightness-group
+#TABLE Function - Description #
+ autothemer-brightness-group - brightness group for COLOR
+#TABLE#
-Builtin brightness groups:
-
- autothemer-dark-mid-light-brightness-groups
- autothemer-10-percent-brightness-groups
- autothemer-20-percent-brightness-groups
+#TABLE Brightness Groups - Description #
+ autothemer-dark-mid-light-brightness-groups - 3 brightness groups
+ autothemer-10-percent-brightness-groups - 10 brightness groups
+ autothemer-20-percent-brightness-groups - 5 brightness groups (default)
+#TABLE#
Saturation grouping:
- autothemer-saturation-group
-
-Builtin saturation groups:
-
- autothemer-low-mid-high-saturation-groups
- autothemer-10-percent-saturation-groups
- autothemer-20-percent-saturation-groups
+#TABLE Function - Description #
+ autothemer-saturation-group - saturation group for COLOR
+#TABLE#
+#TABLE Saturation Groups - Description #
+ autothemer-low-mid-high-saturation-groups - 3 saturation groups
+ autothemer-10-percent-saturation-groups - 10 saturation groups
+ autothemer-20-percent-saturation-groups - 5 saturation groups (default)
+#TABLE#
- - -
Sorting:
@@ -782,11 +786,13 @@ Sorting:
The sort/ordering functions take args A and B, which are expected
to be `autothemer--color' structs.
-Darkest to lightest: `(autothemer-darkest-order a b)'
-Lightest to darkest: `(autothemer-lightest-order a b)'
-Hue: `(autothemer-hue-order a b)'
-Saturated to desaturated: `(autothemer-saturated-order a b)'
-Desaturated to saturated: `(autothemer-desaturated-order a b)'"
+#TABLE Sort Functions - Description#
+ autothemer-darkest-order - darkest to lightest
+ autothemer-lightest-order - lightest to darkest
+ autothemer-hue-order - sort by hue
+ autothemer-saturated-order - sort by most saturated to least
+ autothemer-desaturated-order - sort by least saturated to most
+#TABLE#"
(autothemer--plist-bind
(group-fn
group-args
@@ -801,37 +807,44 @@ Desaturated to saturated: `(autothemer-desaturated-order
a b)'"
sort-fn)))
sorted-groups)))
+(defun autothemer-groups-to-palette (grouped-palette)
+ "Flatten a GROUPED-PALETTE from `autothemer-group-and-sort' to a single
list."
+ (-flatten (--map (cdr it) grouped-palette)))
+
;;; SVG Palette generator...
(defun autothemer-generate-palette-svg (&optional options)
"Create an SVG palette image for a theme.
-Optionally supply OPTIONS (a plist, all keys are optional,
-required values will default or prompt interactively.):
+Optional parameter `options` (a plist). Any required values not
+supplied in OPTIONS will use defaults or prompt interactively.
+#TABLE Option - Description #
:theme-file - theme filename
:theme-name - override the title found in :theme-file
:theme-description - override the description found in :theme-file
:theme-url - override the url found in :theme-file
- :swatch-width - px spacing width of a color swatch (default: 100)
- :swatch-height - px spacing height of a color swatch (default: 150)
- :swatch-rotate - degrees of rotation for swatch (default: 45)
+ :font-family - font name to use in the generated SVG
:columns - number of columns for each palette row (default: 6)
+ :bg-color - Page background color
+ :text-color - Main text color
+ :text-accent-color - Text accent color
:page-template - see page-template below
- :page-top-margin - (default 120)
- :page-right-margin - (default 30)
- :page-bottom-margin - (default 60)
- :page-left-margin - (default 30)
- :h-space - (default 10)
- :v-space - (default 10)
+ :page-top-margin - (default: 120)
+ :page-right-margin - (default: 30)
+ :page-bottom-margin - (default: 60)
+ :page-left-margin - (default: 30)
:swatch-template - see swatch-template below
- :font-family - font name to use in the generated SVG
- :bg-color
- :text-color
- :text-accent-color
- :swatch-border-color
- :sort-palette
- :svg-out-file
+ :swatch-border-color - the border color of a color swatch
+ :swatch-width - px spacing width of a color swatch (default: 100)
+ :swatch-height - px spacing height of a color swatch (default: 150)
+ :swatch-rotate - degrees of rotation for swatch (default: 45)
+ :h-space - horizontal-space between swatches (default: 10)
+ :v-space - vertical-space between swatches (default: 10)
+ :sort-palette - arrange palette using a function name
+ :group-swatches - boolean
+ :svg-out-file - the file/pathname to save SVG output
+#TABLE#
For advanced customization the :page-template and :swatch-template can be
used to provide customize the SVG templates.
@@ -840,6 +853,7 @@ Note: Template parameters are filled by `format' so we mark
them as follows:
Page Template parameters:
+#TABLE Parameter - Description#
%1$s - width
%2$s - height
%3$s - font-family
@@ -850,44 +864,42 @@ Page Template parameters:
%8$s - theme-description
%9$s - theme-url
%10$s - color swatches
+#TABLE#
Swatch Template parameters:
+#TABLE Parameter - Description#
%1$s - x
%2$s - y
%3$s - swatch-border-color
%4$s - swatch-color
%5$s - text-accent-color
- %6$s - swatch-color-name"
+ %6$s - swatch-color-name
+#TABLE#"
(interactive)
(autothemer--plist-bind
(theme-file
theme-name
theme-description
theme-url
-
- sort-palette
- swatch-width
- swatch-height
- swatch-rotate
+ font-family
columns
-
+ bg-color
+ text-color
+ text-accent-color
+ page-template
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
+ swatch-width
+ swatch-height
+ swatch-rotate
h-space
v-space
+ sort-palette
svg-out-file)
options
(let ((theme-file (or theme-file (read-file-name "Select autothemer theme
.el file: "))))
@@ -963,6 +975,11 @@ Swatch Template parameters:
(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:
"))))
+ (sort-palette (or sort-palette
+ (list
+ :sort-fn (read--expression "Sort
function (TAB completion, enter nil to skip): " "'autothemer-")
+ :group-fn (read--expression "Group
function (TAB completion, enter nil to skip): " "'autothemer-")
+ :group-args (read--expression "Group
list (TAB completion, enter nil to skip): " "autothemer-"))))
(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
@@ -983,10 +1000,9 @@ Swatch Template parameters:
text-accent-color
name swatch-width swatch-height
swatch-rotate)))
(if sort-palette
- (if (eql t sort-palette)
- (autothemer-sort-palette colors)
- (autothemer-sort-palette colors (intern
sort-palette)))
- colors))
+ (autothemer-groups-to-palette
+ (autothemer-group-and-sort colors
sort-palette))
+ colors))
"\n")))
(with-temp-file svg-out-file
(insert
diff --git a/function-reference.md b/function-reference.md
index 457f130594..8c6886c8bf 100644
--- a/function-reference.md
+++ b/function-reference.md
@@ -16,15 +16,59 @@ assist with theme building, here are a few highlights...
- Colorize/font-lock palette color names in the buffer
- `autothemer-colorize` (requires `rainbow-mode` during development.)
-
-Note in the function reference, the fucntion prefix `autothemer--` indicates
internal
-functions.
- - -
-## Functions
-
-### autothemer-colorize [command]
-
-Colorize using rainbow-mode.
+# Function reference
+
+### Commands
+- [autothemer-colorize](#autothemer-colorize-)
+- [autothemer-generate-palette-svg](#autothemer-generate-palette-svg---options)
+- [autothemer-generate-templates](#autothemer-generate-templates---regexp)
+-
[autothemer-generate-templates-filtered](#autothemer-generate-templates-filtered--regexp)
+- [autothemer-insert-color](#autothemer-insert-color-)
+- [autothemer-insert-color-name](#autothemer-insert-color-name-)
+### User Functions
+-
[autothemer-brightness-group](#autothemer-brightness-group--color--brightness-groups)
+- [autothemer-color-brightness](#autothemer-color-brightness--color)
+- [autothemer-color-hue](#autothemer-color-hue--color)
+- [autothemer-color-sat](#autothemer-color-sat--color)
+- [autothemer-color-to-group](#autothemer-color-to-group--color-fn-groups)
+- [autothemer-darkest-order](#autothemer-darkest-order--a-b)
+- [autothemer-desaturated-order](#autothemer-desaturated-order--a-b)
+- [autothemer-group-and-sort](#autothemer-group-and-sort--palette-options)
+- [autothemer-group-colors](#autothemer-group-colors--palette-options)
+- [autothemer-group-sort](#autothemer-group-sort--groups-sort-fn)
+-
[autothemer-groups-to-palette](#autothemer-groups-to-palette--grouped-palette)
+- [autothemer-hex-to-rgb](#autothemer-hex-to-rgb--hex)
+- [autothemer-hue-group](#autothemer-hue-group--color--hue-groups)
+- [autothemer-hue-order](#autothemer-hue-order--a-b)
+- [autothemer-lightest-order](#autothemer-lightest-order--a-b)
+- [autothemer-saturated-order](#autothemer-saturated-order--a-b)
+-
[autothemer-saturation-group](#autothemer-saturation-group--color--saturation-groups)
+-
[autothemer-sort-palette](#autothemer-sort-palette--theme-colors--sort-fn-group-fn-group-args)
+### Internal Functions
+-
[autothemer--alist-to-reduced-spec](#autothemer--alist-to-reduced-spec--facename-alist)
+-
[autothemer--approximate-spec](#autothemer--approximate-spec--reduced-spec-theme)
+-
[autothemer--color-distance](#autothemer--color-distance--color-autothemer-color)
+- [autothemer--color-to-hsv](#autothemer--color-to-hsv--rgb)
+- [autothemer--colorize-alist](#autothemer--colorize-alist-)
+- [autothemer--cons-to-tree](#autothemer--cons-to-tree--the-cons)
+- [autothemer--current-theme-guard](#autothemer--current-theme-guard-)
+- [autothemer--demote-heads](#autothemer--demote-heads--expr)
+- [autothemer--extract-display](#autothemer--extract-display--palette-n)
+- [autothemer--extract-let-block](#autothemer--extract-let-block--palette-n)
+- [autothemer--face-to-alist](#autothemer--face-to-alist--face)
+-
[autothemer--fill-empty-palette-slots](#autothemer--fill-empty-palette-slots--palette)
+-
[autothemer--find-closest-color](#autothemer--find-closest-color--colors-color)
+- [autothemer--get-color](#autothemer--get-color--color-name)
+-
[autothemer--pad-with-nil](#autothemer--pad-with-nil--row-min-number-of-elements)
+-
[autothemer--reduced-spec-to-facespec](#autothemer--reduced-spec-to-facespec--display-reduced-specs)
+-
[autothemer--replace-nil-by-precursor](#autothemer--replace-nil-by-precursor--palette-row)
+- [autothemer--select-color](#autothemer--select-color---prompt)
+- [autothemer--unindent](#autothemer--unindent--s)
+- [autothemer--unthemed-faces](#autothemer--unthemed-faces-)
+### <a id="autothemer-colorize-" aria-hidden="true"></a>autothemer-colorize
command
+
+In the current buffer, colorize palette color names, from the last evaluated
theme, by their color value.
<sup>function signature</sup>
```lisp
@@ -33,36 +77,39 @@ Colorize using rainbow-mode.
- - -
-### autothemer-generate-palette-svg [command]
+### <a id="autothemer-generate-palette-svg---options"
aria-hidden="true"></a>autothemer-generate-palette-svg command
Create an SVG palette image for a theme.
-Optionally supply `options` (a plist, all keys are optional,
-required values will default or prompt interactively.):
-
- :theme-file - theme filename
- :theme-name - override the title found in :theme-file
- :theme-description - override the description found in :theme-file
- :theme-url - override the url found in :theme-file
- :swatch-width - px spacing width of a color swatch (default: 100)
- :swatch-height - px spacing height of a color swatch (default: 150)
- :swatch-rotate - degrees of rotation for swatch (default: 45)
- :columns - number of columns for each palette row (default: 6)
- :page-template - see page-template below
- :page-top-margin - (default 120)
- :page-right-margin - (default 30)
- :page-bottom-margin - (default 60)
- :page-left-margin - (default 30)
- :h-space - (default 10)
- :v-space - (default 10)
- :swatch-template - see swatch-template below
- :font-family - font name to use in the generated SVG
- :bg-color
- :text-color
- :text-accent-color
- :swatch-border-color
- :sort-palette
- :svg-out-file
+Optional parameter `options` (a plist). Any required values not
+supplied in `options` will use defaults or prompt interactively.
+
+| Option | Description
|
+|------------------------|-----------------------------------------------------|
+| `:theme-file` | theme filename
|
+| `:theme-name` | override the title found in :theme-file
|
+| `:theme-description` | override the description found in :theme-file
|
+| `:theme-url` | override the url found in :theme-file
|
+| `:font-family` | font name to use in the generated SVG
|
+| `:columns` | number of columns for each palette row (default: 6)
|
+| `:bg-color` | Page background color
|
+| `:text-color` | Main text color
|
+| `:text-accent-color` | Text accent color
|
+| `:page-template` | see page-template below
|
+| `:page-top-margin` | (default: 120)
|
+| `:page-right-margin` | (default: 30)
|
+| `:page-bottom-margin` | (default: 60)
|
+| `:page-left-margin` | (default: 30)
|
+| `:swatch-template` | see swatch-template below
|
+| `:swatch-border-color` | the border color of a color swatch
|
+| `:swatch-width` | px spacing width of a color swatch (default: 100)
|
+| `:swatch-height` | px spacing height of a color swatch (default: 150)
|
+| `:swatch-rotate` | degrees of rotation for swatch (default: 45)
|
+| `:h-space` | horizontal-space between swatches (default: 10)
|
+| `:v-space` | vertical-space between swatches (default: 10)
|
+| `:sort-palette` | arrange palette using a function name
|
+| `:group-swatches` | boolean
|
+| `:svg-out-file` | the file/pathname to save SVG output
|
For advanced customization the :page-template and :swatch-template can be
used to provide customize the SVG templates.
@@ -71,25 +118,29 @@ Note: Template parameters are filled by `format` so we
mark them as follows:
Page Template parameters:
- %1$s - width
- %2$s - height
- %3$s - font-family
- %4$s - text-color
- %5$s - text-accent-color
- %6$s - bg-color
- %7$s - theme-name
- %8$s - theme-description
- %9$s - theme-url
- %10$s - color swatches
+| Parameter | Description |
+|-----------|-------------------|
+| `%1$s` | width |
+| `%2$s` | height |
+| `%3$s` | font-family |
+| `%4$s` | text-color |
+| `%5$s` | text-accent-color |
+| `%6$s` | bg-color |
+| `%7$s` | theme-name |
+| `%8$s` | theme-description |
+| `%9$s` | theme-url |
+| `%10$s` | color swatches |
Swatch Template parameters:
- %1$s - x
- %2$s - y
- %3$s - swatch-border-color
- %4$s - swatch-color
- %5$s - text-accent-color
- %6$s - swatch-color-name
+| Parameter | Description |
+|-----------|---------------------|
+| `%1$s` | x |
+| `%2$s` | y |
+| `%3$s` | swatch-border-color |
+| `%4$s` | swatch-color |
+| `%5$s` | text-accent-color |
+| `%6$s` | swatch-color-name |
<sup>function signature</sup>
```lisp
@@ -98,7 +149,7 @@ Swatch Template parameters:
- - -
-### autothemer-generate-templates [command]
+### <a id="autothemer-generate-templates---regexp"
aria-hidden="true"></a>autothemer-generate-templates command
Autogenerate customizations for unthemed faces (optionally by `regexp`).
@@ -114,7 +165,7 @@ An error is shown when no current theme is available.
- - -
-### autothemer-generate-templates-filtered [command]
+### <a id="autothemer-generate-templates-filtered--regexp"
aria-hidden="true"></a>autothemer-generate-templates-filtered command
Autogenerate customizations for unthemed faces matching `regexp`.
@@ -127,7 +178,7 @@ Calls `autothemer-generate-templates` after user provides
`regexp` interactively
- - -
-### autothemer-insert-color [command]
+### <a id="autothemer-insert-color-"
aria-hidden="true"></a>autothemer-insert-color command
Select and insert a color from the current autotheme palette.
@@ -138,7 +189,7 @@ Select and insert a color from the current autotheme
palette.
- - -
-### autothemer-insert-color-name [command]
+### <a id="autothemer-insert-color-name-"
aria-hidden="true"></a>autothemer-insert-color-name command
Select and insert a color name from the current autotheme palette.
@@ -149,7 +200,7 @@ Select and insert a color name from the current autotheme
palette.
- - -
-### autothemer-brightness-group
+### <a id="autothemer-brightness-group--color--brightness-groups"
aria-hidden="true"></a>autothemer-brightness-group
Return the brightness group of `color`.
Functionally identical to `autothemer-hue-groups` for brightness.
@@ -163,40 +214,40 @@ The default is `autothemer-20-percent-brightness-groups`.
- - -
-### autothemer-color-brightness
+### <a id="autothemer-color-brightness--color"
aria-hidden="true"></a>autothemer-color-brightness
-Return the HSV brightness of `hex-color`.
+Return the HSV brightness of `color` (hex color or autothemer--color struct).
<sup>function signature</sup>
```lisp
-(autothemer-color-brightness (hex-color))
+(autothemer-color-brightness (color))
```
- - -
-### autothemer-color-hue
+### <a id="autothemer-color-hue--color"
aria-hidden="true"></a>autothemer-color-hue
-Return the HSV hue of `hex-color`.
+Return the HSV hue of `color` (hex color or autothemer--color struct).
<sup>function signature</sup>
```lisp
-(autothemer-color-hue (hex-color))
+(autothemer-color-hue (color))
```
- - -
-### autothemer-color-sat
+### <a id="autothemer-color-sat--color"
aria-hidden="true"></a>autothemer-color-sat
-Return the HSV sat of `hex-color`.
+Return the HSV saturation of `color` (hex color or autothemer--color struct).
<sup>function signature</sup>
```lisp
-(autothemer-color-sat (hex-color))
+(autothemer-color-sat (color))
```
- - -
-### autothemer-color-to-group
+### <a id="autothemer-color-to-group--color-fn-groups"
aria-hidden="true"></a>autothemer-color-to-group
Group `color` using `fn`, in `groups`.
@@ -207,7 +258,7 @@ Group `color` using `fn`, in `groups`.
- - -
-### autothemer-darkest-order
+### <a id="autothemer-darkest-order--a-b"
aria-hidden="true"></a>autothemer-darkest-order
Return t if the darkness of `a` > `b`.
@@ -218,47 +269,65 @@ Return t if the darkness of `a` > `b`.
- - -
-### autothemer-group-and-sort
+### <a id="autothemer-desaturated-order--a-b"
aria-hidden="true"></a>autothemer-desaturated-order
+
+Return t if the saturation of `a` < `b`.
+
+<sup>function signature</sup>
+```lisp
+(autothemer-desaturated-order (a b))
+```
+
+- - -
+
+### <a id="autothemer-group-and-sort--palette-options"
aria-hidden="true"></a>autothemer-group-and-sort
Group and sort `palette` using `options`.
Options is a plist of:
- :group-fn - mandatory group function
- :group-args - optional group args (to use a non-default group)
- :sort-fn - optional sort function
+| Option | Description |
+|---------------|--------------------------------------------------|
+| `:group-fn` | mandatory group function |
+| `:group-args` | optional group args (to use a non-default group) |
+| `:sort-fn` | optional sort function |
See color grouping functions and group lists:
Hue grouping:
- autothemer-hue-group
+| Function | Description |
+|------------------------|---------------------------|
+| `autothemer-hue-group` | color hue group for COLOR |
-Builtin hue groups:
-
- autothemer-hue-groups
- autothemer-simple-hue-groups
+| Hue Groups | Description
|
+|--------------------------------|----------------------------------------------|
+| `autothemer-hue-groups` | group colors into major hue groups
(default) |
+| `autothemer-simple-hue-groups` | group colors into broad hue groups
|
Brightness grouping:
- autothemer-brightness-group
-
-Builtin brightness groups:
+| Function | Description |
+|-------------------------------|----------------------------|
+| `autothemer-brightness-group` | brightness group for COLOR |
- autothemer-dark-mid-light-brightness-groups
- autothemer-10-percent-brightness-groups
- autothemer-20-percent-brightness-groups
+| Brightness Groups | Description
|
+|-----------------------------------------------|-------------------------------|
+| `autothemer-dark-mid-light-brightness-groups` | 3 brightness groups
|
+| `autothemer-10-percent-brightness-groups` | 10 brightness groups
|
+| `autothemer-20-percent-brightness-groups` | 5 brightness groups
(default) |
Saturation grouping:
- autothemer-saturation-group
-
-Builtin saturation groups:
-
- autothemer-low-mid-high-saturation-groups
- autothemer-10-percent-saturation-groups
- autothemer-20-percent-saturation-groups
+| Function | Description |
+|-------------------------------|----------------------------|
+| `autothemer-saturation-group` | saturation group for COLOR |
+| Saturation Groups | Description |
+|---------------------------------------------|-------------------------------|
+| `autothemer-low-mid-high-saturation-groups` | 3 saturation groups |
+| `autothemer-10-percent-saturation-groups` | 10 saturation groups |
+| `autothemer-20-percent-saturation-groups` | 5 saturation groups (default) |
- - -
Sorting:
@@ -266,11 +335,13 @@ Sorting:
The sort/ordering functions take args A and B, which are expected
to be `autothemer--color` structs.
-Darkest to lightest: `(autothemer-darkest-order a b)`
-Lightest to darkest: `(autothemer-lightest-order a b)`
-Hue: `(autothemer-hue-order a b)`
-Saturated to desaturated: `(autothemer-saturated-order a b)`
-Desaturated to saturated: `(autothemer-desaturated-order a b)`
+| Sort Functions | Description |
+|--------------------------------|---------------------------------|
+| `autothemer-darkest-order` | darkest to lightest |
+| `autothemer-lightest-order` | lightest to darkest |
+| `autothemer-hue-order` | sort by hue |
+| `autothemer-saturated-order` | sort by most saturated to least |
+| `autothemer-desaturated-order` | sort by least saturated to most |
<sup>function signature</sup>
```lisp
@@ -279,7 +350,7 @@ Desaturated to saturated: `(autothemer-desaturated-order a
b)`
- - -
-### autothemer-group-colors
+### <a id="autothemer-group-colors--palette-options"
aria-hidden="true"></a>autothemer-group-colors
Group `palette` colors into groups as defined in plist `options`:
`:group-fn` - mandatory group function
@@ -292,7 +363,7 @@ Group `palette` colors into groups as defined in plist
`options`:
- - -
-### autothemer-group-sort
+### <a id="autothemer-group-sort--groups-sort-fn"
aria-hidden="true"></a>autothemer-group-sort
Sort `groups` of colors using `sort-fn`.
`groups` are produced by `autothemer-group-colors`.
@@ -304,7 +375,18 @@ Sort `groups` of colors using `sort-fn`.
- - -
-### autothemer-hex-to-rgb
+### <a id="autothemer-groups-to-palette--grouped-palette"
aria-hidden="true"></a>autothemer-groups-to-palette
+
+Flatten a `grouped-palette` from `autothemer-group-and-sort` to a single list.
+
+<sup>function signature</sup>
+```lisp
+(autothemer-groups-to-palette (grouped-palette))
+```
+
+- - -
+
+### <a id="autothemer-hex-to-rgb--hex"
aria-hidden="true"></a>autothemer-hex-to-rgb
Convert `hex` to `(r g b)`.
`r`, `g`, `b` will be values `0..65535`
@@ -316,7 +398,7 @@ Convert `hex` to `(r g b)`.
- - -
-### autothemer-hue-group
+### <a id="autothemer-hue-group--color--hue-groups"
aria-hidden="true"></a>autothemer-hue-group
Return the color hue group for `color`.
@@ -345,7 +427,7 @@ A hue range which crosses the apex (i.e. `360°..0°`) is
permitted.
- - -
-### autothemer-hue-order
+### <a id="autothemer-hue-order--a-b"
aria-hidden="true"></a>autothemer-hue-order
Return t if the hue of `a` > `b`.
@@ -356,18 +438,7 @@ Return t if the hue of `a` > `b`.
- - -
-### autothemer-hue-sat-order
-
-Return t if the hue and sat of `a` > `b`.
-
-<sup>function signature</sup>
-```lisp
-(autothemer-hue-sat-order (a b))
-```
-
-- - -
-
-### autothemer-lightest-order
+### <a id="autothemer-lightest-order--a-b"
aria-hidden="true"></a>autothemer-lightest-order
Return t if the lightness of `a` > `b`.
@@ -378,7 +449,7 @@ Return t if the lightness of `a` > `b`.
- - -
-### autothemer-saturated-order
+### <a id="autothemer-saturated-order--a-b"
aria-hidden="true"></a>autothemer-saturated-order
Return t if the saturation of `a` > `b`.
@@ -389,7 +460,7 @@ Return t if the saturation of `a` > `b`.
- - -
-### autothemer-saturation-group
+### <a id="autothemer-saturation-group--color--saturation-groups"
aria-hidden="true"></a>autothemer-saturation-group
Return the saturation group of `color`.
Functionally identical to `autothemer-hue-groups` for saturation.
@@ -403,24 +474,22 @@ The default is `autothemer-20-percent-saturation-groups`.
- - -
-### autothemer-sort-palette
-
-Produce a list of sorted `theme-colors` using `fn`.
-
-If `fn` is nil, sort by default `fn` `autothemer-darkest-order`.
+### <a id="autothemer-sort-palette--theme-colors--sort-fn-group-fn-group-args"
aria-hidden="true"></a>autothemer-sort-palette
-`autothemer-lightest-order` is available to balance the force.
+Produce a list of sorted `theme-colors` using `sort-fn`.
+If `sort-fn` is nil, sort by default `autothemer-darkest-order`.
+Grouping is supported via `group-fn` & `group-args`.
-There are also `autothemer-hue-order` and `autothemer-saturated-order`
+See `autothemer-group-and-sort` for a full list.
<sup>function signature</sup>
```lisp
-(autothemer-sort-palette (theme-colors &optional fn))
+(autothemer-sort-palette (theme-colors &optional sort-fn group-fn group-args))
```
- - -
-### autothemer--alist-to-reduced-spec [internal]
+### <a id="autothemer--alist-to-reduced-spec--facename-alist"
aria-hidden="true"></a>autothemer--alist-to-reduced-spec internal
Generate a reduced-spec for `facename`, based on the face attribute `alist`.
@@ -431,7 +500,7 @@ Generate a reduced-spec for `facename`, based on the face
attribute `alist`.
- - -
-### autothemer--approximate-spec [internal]
+### <a id="autothemer--approximate-spec--reduced-spec-theme"
aria-hidden="true"></a>autothemer--approximate-spec internal
Replace colors in `reduced-spec` by their closest approximations in `theme`.
Replace every expression in `reduced-spec` that passes
@@ -446,7 +515,7 @@ unbound symbols, such as `normal` or `demibold`.
- - -
-### autothemer--color-distance [internal]
+### <a id="autothemer--color-distance--color-autothemer-color"
aria-hidden="true"></a>autothemer--color-distance internal
Return the distance in rgb space between `color` and AUTOTHEMER-`color`.
Here, `color` is an Emacs color specification and AUTOTHEMER-`color` is of
@@ -459,7 +528,7 @@ type `autothemer--color`.
- - -
-### autothemer--color-to-hsv [internal]
+### <a id="autothemer--color-to-hsv--rgb"
aria-hidden="true"></a>autothemer--color-to-hsv internal
Convert `rgb`, a list of `(r g b)` to list `(h s v)`.
The `r` `g` `b` values can range between `0..65535`.
@@ -473,7 +542,7 @@ In `(h s v)` `h`, `s` and `v` are `0.0..1.0`.
- - -
-### autothemer--colorize-alist [internal]
+### <a id="autothemer--colorize-alist-"
aria-hidden="true"></a>autothemer--colorize-alist internal
Generate an alist for use with rainbow-mode.
@@ -490,7 +559,7 @@ Colors are from `autothemer-current-theme`.
- - -
-### autothemer--cons-to-tree [internal]
+### <a id="autothemer--cons-to-tree--the-cons"
aria-hidden="true"></a>autothemer--cons-to-tree internal
Turn `the-cons` into a list, unless its cdr is `unspecified`.
@@ -501,7 +570,7 @@ Turn `the-cons` into a list, unless its cdr is
`unspecified`.
- - -
-### autothemer--current-theme-guard [internal]
+### <a id="autothemer--current-theme-guard-"
aria-hidden="true"></a>autothemer--current-theme-guard internal
Guard functions from executing when there's no current theme.
@@ -512,7 +581,7 @@ Guard functions from executing when there's no current
theme.
- - -
-### autothemer--demote-heads [internal]
+### <a id="autothemer--demote-heads--expr"
aria-hidden="true"></a>autothemer--demote-heads internal
Demote every list head within `expr` by one element.
E.g., (a (b c d) e (f g)) -> (list a (list b c d) e (list f g)).
@@ -524,7 +593,7 @@ E.g., (a (b c d) e (f g)) -> (list a (list b c d) e (list f
g)).
- - -
-### autothemer--extract-display [internal]
+### <a id="autothemer--extract-display--palette-n"
aria-hidden="true"></a>autothemer--extract-display internal
Extract from `palette` display specification #`n`.
@@ -535,7 +604,7 @@ Extract from `palette` display specification #`n`.
- - -
-### autothemer--extract-let-block [internal]
+### <a id="autothemer--extract-let-block--palette-n"
aria-hidden="true"></a>autothemer--extract-let-block internal
Extract a variable definition block from `palette` for display type `n`.
@@ -546,7 +615,7 @@ Extract a variable definition block from `palette` for
display type `n`.
- - -
-### autothemer--face-to-alist [internal]
+### <a id="autothemer--face-to-alist--face"
aria-hidden="true"></a>autothemer--face-to-alist internal
Return the attribute alist for `face` in frame (selected-frame).
@@ -557,7 +626,7 @@ Return the attribute alist for `face` in frame
(selected-frame).
- - -
-### autothemer--fill-empty-palette-slots [internal]
+### <a id="autothemer--fill-empty-palette-slots--palette"
aria-hidden="true"></a>autothemer--fill-empty-palette-slots internal
Fill empty `palette` slots so each display has all color-definitions.
@@ -568,7 +637,7 @@ Fill empty `palette` slots so each display has all
color-definitions.
- - -
-### autothemer--find-closest-color [internal]
+### <a id="autothemer--find-closest-color--colors-color"
aria-hidden="true"></a>autothemer--find-closest-color internal
Return the element of `colors` that is closest in rgb space to `color`.
Here, `color` is an Emacs color specification and `colors` is a list
@@ -581,7 +650,7 @@ of `autothemer--color` structs.
- - -
-### autothemer--get-color [internal]
+### <a id="autothemer--get-color--color-name"
aria-hidden="true"></a>autothemer--get-color internal
Return color palette object for (string) `color-name`.
@@ -599,7 +668,7 @@ See also `autothemer--color-p`,
- - -
-### autothemer--pad-with-nil [internal]
+### <a id="autothemer--pad-with-nil--row-min-number-of-elements"
aria-hidden="true"></a>autothemer--pad-with-nil internal
Make sure that `row` has at least `min-number-of-elements`.
Pad with nil if necessary.
@@ -611,7 +680,7 @@ Pad with nil if necessary.
- - -
-### autothemer--reduced-spec-to-facespec [internal]
+### <a id="autothemer--reduced-spec-to-facespec--display-reduced-specs"
aria-hidden="true"></a>autothemer--reduced-spec-to-facespec internal
Create a face spec for `display`, with specs `reduced-specs`.
@@ -627,7 +696,7 @@ For example:
- - -
-### autothemer--replace-nil-by-precursor [internal]
+### <a id="autothemer--replace-nil-by-precursor--palette-row"
aria-hidden="true"></a>autothemer--replace-nil-by-precursor internal
Replace nil colors in `palette-row` with their precursor.
@@ -652,7 +721,7 @@ Will become:
- - -
-### autothemer--select-color [internal]
+### <a id="autothemer--select-color---prompt"
aria-hidden="true"></a>autothemer--select-color internal
Select a color from the current palette, optionally use `prompt`.
Current palette is read from `autothemer-current-theme`.
@@ -670,7 +739,7 @@ See also `autothemer--color-p`,
- - -
-### autothemer--unindent [internal]
+### <a id="autothemer--unindent--s"
aria-hidden="true"></a>autothemer--unindent internal
Unindent string `s` marked with | chars.
@@ -681,7 +750,7 @@ Unindent string `s` marked with | chars.
- - -
-### autothemer--unthemed-faces [internal]
+### <a id="autothemer--unthemed-faces-"
aria-hidden="true"></a>autothemer--unthemed-faces internal
Find uncustomized faces.
Iterate through all currently defined faces and return those that
diff --git a/tests/autothemer-tests.el b/tests/autothemer-tests.el
index e120ff686d..bea4071f46 100644
--- a/tests/autothemer-tests.el
+++ b/tests/autothemer-tests.el
@@ -1,6 +1,6 @@
;; autothemer-tests.el
-;; Version: 0.2.11
+;; Version: 0.2.12
;;; Code:
@@ -157,6 +157,7 @@
(ert-deftest autothemer-color-hue ()
"Test get hue of hex-color."
+ (should (= (autothemer-color-hue #s(autothemer--color example-color-020
"#2391CB")) 0.5575396825396826))
(should (= (autothemer-color-hue "#FF0000") 0))
(should (= (autothemer-color-hue "#FFFF00") 0.16666666666666666))
(should (= (autothemer-color-hue "#00FF00") 0.33333333333333333))
@@ -164,6 +165,7 @@
(ert-deftest autothemer-color-sat ()
"Test get sat of hex-color."
+ (should (= (autothemer-color-sat #s(autothemer--color example-color-020
"#2391CB")) 0.8275862068965516))
(should (= (autothemer-color-sat "#0000FF") 1.0))
(should (= (autothemer-color-sat "#FF00FF") 1.0))
(should (= (autothemer-color-sat "#778822") 0.75))
@@ -172,6 +174,7 @@
(ert-deftest autothemer-color-brightness ()
"Test get brightness of hex-color."
+ (should (= (autothemer-color-brightness #s(autothemer--color
example-color-020 "#2391CB")) 0.796078431372549))
(should (= (autothemer-color-brightness "#0000FF") 1.0))
(should (= (autothemer-color-brightness "#00FF00") 1.0))
(should (= (autothemer-color-brightness "#FF00FF") 1.0))
@@ -249,24 +252,27 @@
(ert-deftest autothemer-group-colors ()
"Group colors into a plist of color lists, with group names as keys."
(should (equal
- (autothemer-group-colors
- (list
- (make-autothemer--color :name 'example-color-005 :value
"#112063")
- (make-autothemer--color :name 'example-color-006 :value
"#88DDCC")
- (make-autothemer--color :name 'example-color-006 :value
"#99DDCC")
- (make-autothemer--color :name 'example-color-006 :value
"#FFDDCC")
- (make-autothemer--color :name 'example-color-006 :value
"#FFEECC")
- (make-autothemer--color :name 'example-color-007 :value
"#281993")
- (make-autothemer--color :name 'example-color-010 :value
"#240933"))
- (list :group-fn 'autothemer-saturation-group
- :group-args autothemer-low-mid-high-saturation-groups))
- '((high #s(autothemer--color example-color-005 "#112063")
- #s(autothemer--color example-color-007 "#281993")
- #s(autothemer--color example-color-010 "#240933"))
- (mid #s(autothemer--color example-color-006 "#88DDCC"))
- (low #s(autothemer--color example-color-006 "#99DDCC")
- #s(autothemer--color example-color-006 "#FFDDCC")
- #s(autothemer--color example-color-006 "#FFEECC"))))))
+ (autothemer-group-colors
+ (list
+ (make-autothemer--color :name 'example-color-005 :value
"#112063")
+ (make-autothemer--color :name 'example-color-006 :value
"#88DDCC")
+ (make-autothemer--color :name 'example-color-006 :value
"#99DDCC")
+ (make-autothemer--color :name 'example-color-006 :value
"#FFDDCC")
+ (make-autothemer--color :name 'example-color-006 :value
"#FFEECC")
+ (make-autothemer--color :name 'example-color-007 :value
"#281993")
+ (make-autothemer--color :name 'example-color-010 :value
"#240933"))
+ (list :group-fn 'autothemer-saturation-group
+ :group-args autothemer-low-mid-high-saturation-groups))
+ '((high
+ #s(autothemer--color example-color-005 "#112063")
+ #s(autothemer--color example-color-007 "#281993")
+ #s(autothemer--color example-color-010 "#240933"))
+ (mid
+ #s(autothemer--color example-color-006 "#88DDCC"))
+ (low
+ #s(autothemer--color example-color-006 "#99DDCC")
+ #s(autothemer--color example-color-006 "#FFDDCC")
+ #s(autothemer--color example-color-006 "#FFEECC"))))))
(ert-deftest autothemer-group-and-sort ()
"Group and sort a palette of `autothemer--color' structs."
@@ -313,42 +319,73 @@
:group-args autothemer-simple-hue-groups
:sort-fn autothemer-darkest-order))
- '((red #s(autothemer--color example-color-005 "#181818")
- #s(autothemer--color example-color-002 "#642C12")
- #s(autothemer--color example-color-001 "#702414")
- #s(autothemer--color example-color-035 "#B11D37")
- #s(autothemer--color example-color-036 "#E52929"))
- (orange #s(autothemer--color example-color-004 "#191204")
- #s(autothemer--color example-color-003 "#583410"))
- (green #s(autothemer--color example-color-006 "#191904")
- #s(autothemer--color example-color-009 "#162506")
- #s(autothemer--color example-color-008 "#243108")
- #s(autothemer--color example-color-007 "#373D0A")
- #s(autothemer--color example-color-010 "#224C0E")
- #s(autothemer--color example-color-012 "#0E4C0E")
- #s(autothemer--color example-color-014 "#0E4C22")
- #s(autothemer--color example-color-013 "#147024")
- #s(autothemer--color example-color-011 "#287C16"))
- (cyan #s(autothemer--color example-color-021 "#13416F")
- #s(autothemer--color example-color-015 "#167C49")
- #s(autothemer--color example-color-019 "#178297")
- #s(autothemer--color example-color-018 "#1AA4A4")
- #s(autothemer--color example-color-016 "#20BE87")
- #s(autothemer--color example-color-020 "#2391CB")
- #s(autothemer--color example-color-017 "#28E4C4"))
- (blue #s(autothemer--color example-color-026 "#170933")
- #s(autothemer--color example-color-028 "#240933")
- #s(autothemer--color example-color-024 "#0D0D4B")
- #s(autothemer--color example-color-023 "#112063")
- #s(autothemer--color example-color-022 "#13306F")
- #s(autothemer--color example-color-025 "#281993")
- #s(autothemer--color example-color-027 "#620FA9"))
- (magenta #s(autothemer--color example-color-030 "#330933")
- #s(autothemer--color example-color-029 "#63136F")
- #s(autothemer--color example-color-031 "#971782")
- #s(autothemer--color example-color-033 "#A41A5F")
- #s(autothemer--color example-color-032 "#D62499")
- #s(autothemer--color example-color-034
"#D82662")))))))
+ '((red
+ #s(autothemer--color example-color-005 "#181818")
+ #s(autothemer--color example-color-002 "#642C12")
+ #s(autothemer--color example-color-001 "#702414")
+ #s(autothemer--color example-color-035 "#B11D37")
+ #s(autothemer--color example-color-036 "#E52929"))
+ (orange
+ #s(autothemer--color example-color-004 "#191204")
+ #s(autothemer--color example-color-003 "#583410"))
+ (green
+ #s(autothemer--color example-color-006 "#191904")
+ #s(autothemer--color example-color-009 "#162506")
+ #s(autothemer--color example-color-008 "#243108")
+ #s(autothemer--color example-color-007 "#373D0A")
+ #s(autothemer--color example-color-010 "#224C0E")
+ #s(autothemer--color example-color-012 "#0E4C0E")
+ #s(autothemer--color example-color-014 "#0E4C22")
+ #s(autothemer--color example-color-013 "#147024")
+ #s(autothemer--color example-color-011 "#287C16"))
+ (cyan
+ #s(autothemer--color example-color-021 "#13416F")
+ #s(autothemer--color example-color-015 "#167C49")
+ #s(autothemer--color example-color-019 "#178297")
+ #s(autothemer--color example-color-018 "#1AA4A4")
+ #s(autothemer--color example-color-016 "#20BE87")
+ #s(autothemer--color example-color-020 "#2391CB")
+ #s(autothemer--color example-color-017 "#28E4C4"))
+ (blue
+ #s(autothemer--color example-color-026 "#170933")
+ #s(autothemer--color example-color-028 "#240933")
+ #s(autothemer--color example-color-024 "#0D0D4B")
+ #s(autothemer--color example-color-023 "#112063")
+ #s(autothemer--color example-color-022 "#13306F")
+ #s(autothemer--color example-color-025 "#281993")
+ #s(autothemer--color example-color-027 "#620FA9"))
+ (magenta
+ #s(autothemer--color example-color-030 "#330933")
+ #s(autothemer--color example-color-029 "#63136F")
+ #s(autothemer--color example-color-031 "#971782")
+ #s(autothemer--color example-color-033 "#A41A5F")
+ #s(autothemer--color example-color-032 "#D62499")
+ #s(autothemer--color example-color-034 "#D82662"))))))
+
+ (ert-deftest autothemer-groups-to-palette ()
+ "Flatten a grouped palette (keeping order)."
+ (should (equal (autothemer-groups-to-palette '((high
+ #s(autothemer--color
example-color-005 "#112063")
+ #s(autothemer--color
example-color-007 "#281993")
+ #s(autothemer--color
example-color-010 "#240933"))
+ (mid
+ #s(autothemer--color
example-color-006 "#88DDCC"))
+ (low
+ #s(autothemer--color
example-color-006 "#99DDCC")
+ #s(autothemer--color
example-color-006 "#FFDDCC")
+ #s(autothemer--color
example-color-006 "#FFEECC"))))
+ '( #s(autothemer--color example-color-005 "#112063")
+ #s(autothemer--color example-color-007 "#281993")
+ #s(autothemer--color example-color-010 "#240933")
+ #s(autothemer--color example-color-006 "#88DDCC")
+ #s(autothemer--color example-color-006 "#99DDCC")
+ #s(autothemer--color example-color-006 "#FFDDCC")
+ #s(autothemer--color example-color-006 "#FFEECC"))))))
+
+(defun autothemer-groups-to-palette (grouped-palette)
+ "Flatten a GROUPED-PALETTE from `autothemer-group-and-sort' to a single
list."
+ (-flatten (--map (cdr it) grouped-palette)))
+(autothemer-color-hue #s(autothemer--color example-color-020 "#2391CB"))
;;; autothemer-tests.el ends here