@thi.ng/color-palettes 1.1.19 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-08-27T11:20:58Z
3
+ - **Last updated**: 2023-09-25T07:43:28Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [1.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/color-palettes@1.2.0) (2023-09-25)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add opt arg to get theme in reverse order ([4163fda](https://github.com/thi-ng/umbrella/commit/4163fda))
17
+
12
18
  ## [1.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/color-palettes@1.1.0) (2023-04-25)
13
19
 
14
20
  #### 🚀 Features
package/README.md CHANGED
@@ -271,7 +271,7 @@ For Node.js REPL:
271
271
  const colorPalettes = await import("@thi.ng/color-palettes");
272
272
  ```
273
273
 
274
- Package sizes (brotli'd, pre-treeshake): ESM: 4.75 KB
274
+ Package sizes (brotli'd, pre-treeshake): ESM: 4.77 KB
275
275
 
276
276
  ## Dependencies
277
277
 
@@ -290,9 +290,10 @@ directory are using this package.
290
290
 
291
291
  A selection:
292
292
 
293
- | Screenshot | Description | Live demo | Source |
294
- |:---------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------|:----------------------------------------------------|:---------------------------------------------------------------------------------|
295
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/pixel-indexed.jpg" width="240"/> | Image dithering and remapping using indexed palettes | [Demo](https://demo.thi.ng/umbrella/pixel-indexed/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/pixel-indexed) |
293
+ | Screenshot | Description | Live demo | Source |
294
+ |:---------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------|:----------------------------------------------------|:---------------------------------------------------------------------------------|
295
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-sdf-logo.jpg" width="240"/> | (Re)Constructing the thi.ng logo using a 2D signed-distance field | [Demo](https://demo.thi.ng/umbrella/geom-sdf-logo/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-sdf-logo) |
296
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/pixel-indexed.jpg" width="240"/> | Image dithering and remapping using indexed palettes | [Demo](https://demo.thi.ng/umbrella/pixel-indexed/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/pixel-indexed) |
296
297
 
297
298
  ### Usage
298
299
 
@@ -303,6 +304,10 @@ import { asCSS, asRGB } from "@thi.ng/color-palettes";
303
304
  asCSS(7);
304
305
  // ["#2f1864", "#e40302", "#f25c22", "#d987bd", "#44b6e7", "#e3dadd"]
305
306
 
307
+ // get in reverse order
308
+ asCSS(7, true);
309
+ // ["#e3dadd", "#44b6e7", "#d987bd", "#f25c22", "#e40302", "#2f1864"]
310
+
306
311
  asInt(7).map(x => x.toString(16));
307
312
  // [ 'ff2f1864', 'ffe40302', 'fff25c22', 'ffd987bd', 'ff44b6e7', 'ffe3dadd']
308
313
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/color-palettes",
3
- "version": "1.1.19",
3
+ "version": "1.2.1",
4
4
  "description": "Collection of 200+ image based color themes & composable theme query filters",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -39,7 +39,7 @@
39
39
  "@thi.ng/api": "^8.9.5",
40
40
  "@thi.ng/base-n": "^2.5.13",
41
41
  "@thi.ng/checks": "^3.4.5",
42
- "@thi.ng/color": "^5.5.19",
42
+ "@thi.ng/color": "^5.5.20",
43
43
  "@thi.ng/errors": "^2.3.5",
44
44
  "@thi.ng/hex": "^2.3.17"
45
45
  },
@@ -90,5 +90,5 @@
90
90
  "parent": "@thi.ng/color",
91
91
  "year": 2021
92
92
  },
93
- "gitHead": "c22e8996cee284ebe8ea88582beb1ab5fc6ee503\n"
93
+ "gitHead": "10d8b3725e96c5d704c759489a89f132892b181e\n"
94
94
  }
package/theme.d.ts CHANGED
@@ -1,43 +1,51 @@
1
- import type { CSSTheme, IntTheme, LCHTheme, RGBTheme, ThemePredicate } from "./api.js";
1
+ import type { LCHTheme, RGBTheme, ThemePredicate } from "./api.js";
2
2
  /**
3
- * Returns theme for given ID as CSS hex colors.
3
+ * Returns theme for given ID as CSS hex colors. If `reverse` is true (default:
4
+ * false), the theme colors will be returned in reverse order.
4
5
  *
5
6
  * @param id
7
+ * @param reverse
6
8
  */
7
- export declare const asCSS: (id: number) => CSSTheme;
9
+ export declare const asCSS: (id: number, reverse?: boolean) => string[];
8
10
  /**
9
11
  * Returns theme for given ID as packed ARGB integers (alpha channel will always
10
- * be set to 0xff).
12
+ * be set to 0xff). If `reverse` is true (default: false), the theme colors will
13
+ * be returned in reverse order.
11
14
  *
12
15
  * @param id
16
+ * @param reverse
13
17
  */
14
- export declare const asInt: (id: number) => IntTheme;
18
+ export declare const asInt: (id: number, reverse?: boolean) => number[];
15
19
  /**
16
- * Returns theme for given ID as thi.ng/color LCH color vectors.
20
+ * Returns theme for given ID as thi.ng/color LCH color vectors. If `reverse` is
21
+ * true (default: false), the theme colors will be returned in reverse order.
17
22
  *
18
23
  * @param id
24
+ * @param reverse
19
25
  */
20
- export declare const asLCH: (id: number) => LCHTheme;
26
+ export declare const asLCH: (id: number, reverse?: boolean) => LCHTheme;
21
27
  /**
22
- * Returns theme for given ID as thi.ng/color sRGB color vectors.
28
+ * Returns theme for given ID as thi.ng/color sRGB color vectors. If `reverse`
29
+ * is true (default: false), the theme colors will be returned in reverse order.
23
30
  *
24
31
  * @param id
32
+ * @param reverse
25
33
  */
26
- export declare const asRGB: (id: number) => RGBTheme;
34
+ export declare const asRGB: (id: number, reverse?: boolean) => RGBTheme;
27
35
  /**
28
36
  * Yields iterator of CSS themes (via {@link asCSS}). Yields all
29
37
  * themes unless specific theme IDs or filter predicates are provided.
30
38
  *
31
39
  * @param preds
32
40
  */
33
- export declare const cssThemes: (...preds: ThemePredicate[] | number[]) => Generator<CSSTheme, void, unknown>;
41
+ export declare const cssThemes: (...preds: ThemePredicate[] | number[]) => Generator<string[], void, unknown>;
34
42
  /**
35
43
  * Yields iterator of packed ARGB integer themes (via {@link asInt}). Yields all
36
44
  * themes unless specific theme IDs or filter predicates are provided.
37
45
  *
38
46
  * @param preds
39
47
  */
40
- export declare const intThemes: (...preds: ThemePredicate[] | number[]) => Generator<IntTheme, void, unknown>;
48
+ export declare const intThemes: (...preds: ThemePredicate[] | number[]) => Generator<number[], void, unknown>;
41
49
  /**
42
50
  * Yields iterator of LCH themes (via {@link asLCH}). Yields all
43
51
  * themes unless specific theme IDs or filter predicates are provided.
package/theme.js CHANGED
@@ -5,11 +5,13 @@ import { U24 } from "@thi.ng/hex";
5
5
  import { BINARY, NUM_THEMES } from "./binary.js";
6
6
  import { compFilter } from "./filter.js";
7
7
  /**
8
- * Returns theme for given ID as CSS hex colors.
8
+ * Returns theme for given ID as CSS hex colors. If `reverse` is true (default:
9
+ * false), the theme colors will be returned in reverse order.
9
10
  *
10
11
  * @param id
12
+ * @param reverse
11
13
  */
12
- export const asCSS = (id) => {
14
+ export const asCSS = (id, reverse = false) => {
13
15
  __ensureID(id);
14
16
  const theme = [];
15
17
  // (<any>theme).__id = id;
@@ -18,15 +20,17 @@ export const asCSS = (id) => {
18
20
  theme.push("#" +
19
21
  U24((BINARY[id] << 16) | (BINARY[id + 1] << 8) | BINARY[id + 2]));
20
22
  }
21
- return theme;
23
+ return reverse ? theme.reverse() : theme;
22
24
  };
23
25
  /**
24
26
  * Returns theme for given ID as packed ARGB integers (alpha channel will always
25
- * be set to 0xff).
27
+ * be set to 0xff). If `reverse` is true (default: false), the theme colors will
28
+ * be returned in reverse order.
26
29
  *
27
30
  * @param id
31
+ * @param reverse
28
32
  */
29
- export const asInt = (id) => {
33
+ export const asInt = (id, reverse = false) => {
30
34
  __ensureID(id);
31
35
  const theme = [];
32
36
  id *= 18;
@@ -37,20 +41,24 @@ export const asInt = (id) => {
37
41
  BINARY[id + 2]) >>>
38
42
  0);
39
43
  }
40
- return theme;
44
+ return reverse ? theme.reverse() : theme;
41
45
  };
42
46
  /**
43
- * Returns theme for given ID as thi.ng/color LCH color vectors.
47
+ * Returns theme for given ID as thi.ng/color LCH color vectors. If `reverse` is
48
+ * true (default: false), the theme colors will be returned in reverse order.
44
49
  *
45
50
  * @param id
51
+ * @param reverse
46
52
  */
47
- export const asLCH = (id) => asRGB(id).map((x) => lch(x));
53
+ export const asLCH = (id, reverse = false) => asRGB(id, reverse).map((x) => lch(x));
48
54
  /**
49
- * Returns theme for given ID as thi.ng/color sRGB color vectors.
55
+ * Returns theme for given ID as thi.ng/color sRGB color vectors. If `reverse`
56
+ * is true (default: false), the theme colors will be returned in reverse order.
50
57
  *
51
58
  * @param id
59
+ * @param reverse
52
60
  */
53
- export const asRGB = (id) => {
61
+ export const asRGB = (id, reverse = false) => {
54
62
  __ensureID(id);
55
63
  const theme = [];
56
64
  // (<any>theme).__id = id;
@@ -58,7 +66,7 @@ export const asRGB = (id) => {
58
66
  for (let i = 0; i < 6; i++, id += 3) {
59
67
  theme.push(srgb(BINARY[id] / 255, BINARY[id + 1] / 255, BINARY[id + 2] / 255, 1));
60
68
  }
61
- return theme;
69
+ return reverse ? theme.reverse() : theme;
62
70
  };
63
71
  /**
64
72
  * Yields iterator of CSS themes (via {@link asCSS}). Yields all