@thi.ng/color 5.0.4 → 5.1.2
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 +9 -1
- package/README.md +1 -1
- package/color-range.d.ts +1 -1
- package/cosine-gradients.d.ts +1 -1
- package/gradients.d.ts +7 -2
- package/gradients.js +9 -39
- package/package.json +19 -19
- package/strategies.d.ts +7 -7
- package/swatches.d.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-
|
|
3
|
+
- **Last updated**: 2022-06-23T12:16:18Z
|
|
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,14 @@ 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
|
+
## [5.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/color@5.1.0) (2022-06-09)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- update multiColorGradient() ([f47a59d](https://github.com/thi-ng/umbrella/commit/f47a59d))
|
|
17
|
+
- add support for automatic conversion to packed ARGB/ABGR ints
|
|
18
|
+
(for use with indexed color models in [@thi.ng/pixel](https://github.com/thi-ng/umbrella/tree/main/packages/pixel))
|
|
19
|
+
|
|
12
20
|
# [5.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/color@5.0.0) (2022-03-11)
|
|
13
21
|
|
|
14
22
|
#### 🛑 Breaking changes
|
package/README.md
CHANGED
package/color-range.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare const COLOR_RANGES: Record<ColorRangePreset, ColorRange>;
|
|
|
26
26
|
* @param range -
|
|
27
27
|
* @param opts -
|
|
28
28
|
*/
|
|
29
|
-
export declare const colorFromRange: (range: ColorRange | keyof typeof COLOR_RANGES, opts?: Partial<Pick<ColorRangeOpts, "variance" | "eps" | "rnd">>
|
|
29
|
+
export declare const colorFromRange: (range: ColorRange | keyof typeof COLOR_RANGES, opts?: Partial<Pick<ColorRangeOpts, "variance" | "eps" | "rnd">>) => LCH;
|
|
30
30
|
/**
|
|
31
31
|
* Generator version of {@link colorFromRange}, by default yielding an infinite
|
|
32
32
|
* sequence of random colors based on given range, base color (optional) and
|
package/cosine-gradients.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const cosineColor: (spec: CosGradientSpec, t: number) => Color;
|
|
|
32
32
|
* @param spec -
|
|
33
33
|
* @param tx -
|
|
34
34
|
*/
|
|
35
|
-
export declare const cosineGradient: (n: number, spec: CosGradientSpec, tx?: FnU<
|
|
35
|
+
export declare const cosineGradient: (n: number, spec: CosGradientSpec, tx?: FnU<Color>) => Color[];
|
|
36
36
|
/**
|
|
37
37
|
* Similar to {@link cosineGradient}, but writes results into `buffer` from
|
|
38
38
|
* given `offset` and component/element strides. Returns buffer.
|
package/gradients.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ import type { TypedColor } from "./api.js";
|
|
|
3
3
|
import type { GradientOpts } from "./api/gradients.js";
|
|
4
4
|
/**
|
|
5
5
|
* Similar to {@link multiCosineGradient}, but using any number of gradient
|
|
6
|
-
* color stops and isn't limited to RGB, but for arbitrary color types.
|
|
6
|
+
* color stops and isn't limited to RGB, but for arbitrary color types. The
|
|
7
|
+
* optional `isABGR` boolean arg can be used to autoconvert resulting colors
|
|
8
|
+
* into packed ARGB (false) or ABGR (true) integers. If that arg is given, an
|
|
9
|
+
* array of numbers will be returned.
|
|
7
10
|
*
|
|
8
11
|
* @remarks
|
|
9
12
|
* @see {@link @thi.ng/transducers#tween}
|
|
@@ -38,8 +41,10 @@ import type { GradientOpts } from "./api/gradients.js";
|
|
|
38
41
|
* ```
|
|
39
42
|
*
|
|
40
43
|
* @param opts -
|
|
44
|
+
* @param isABGR -
|
|
41
45
|
*/
|
|
42
|
-
export declare
|
|
46
|
+
export declare function multiColorGradient<T extends TypedColor<any>>(opts: GradientOpts<T>): T[];
|
|
47
|
+
export declare function multiColorGradient<T extends TypedColor<any>>(opts: GradientOpts<T>, isABGR: boolean): number[];
|
|
43
48
|
/**
|
|
44
49
|
* Similar to {@link multiColorGradient}, but writes results into `buffer` from
|
|
45
50
|
* given `offset` and component/element strides. Returns buffer.
|
package/gradients.js
CHANGED
|
@@ -1,45 +1,15 @@
|
|
|
1
1
|
import { tween } from "@thi.ng/transducers/tween";
|
|
2
2
|
import { setS4 } from "@thi.ng/vectors/sets";
|
|
3
|
+
import { intArgb32Abgr32 } from "./int/int-int.js";
|
|
4
|
+
import { argb32 } from "./int/int.js";
|
|
3
5
|
import { mix as $mix } from "./mix.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* gradient = multiColorGradient({
|
|
14
|
-
* num: 100,
|
|
15
|
-
* // LAB color stops
|
|
16
|
-
* stops: [
|
|
17
|
-
* // pink red
|
|
18
|
-
* [0, lch(0.8, 0.8, 0)],
|
|
19
|
-
* // green
|
|
20
|
-
* [1 / 3, lch(0.8, 0.8, 1 / 3)],
|
|
21
|
-
* // blue
|
|
22
|
-
* [2 / 3, lch(0.8, 0.8, 2 / 3)],
|
|
23
|
-
* // gray
|
|
24
|
-
* [1, lch(0.8, 0, 1)],
|
|
25
|
-
* ]
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* // write gradient as SVG swatches
|
|
29
|
-
* writeFileSync(
|
|
30
|
-
* `export/lch-multigradient.svg`,
|
|
31
|
-
* serialize(
|
|
32
|
-
* svg(
|
|
33
|
-
* { width: 500, height: 50, convert: true },
|
|
34
|
-
* swatchesH(gradient, 5, 50)
|
|
35
|
-
* )
|
|
36
|
-
* )
|
|
37
|
-
* );
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @param opts -
|
|
41
|
-
*/
|
|
42
|
-
export const multiColorGradient = (opts) => [...gradient(opts)];
|
|
6
|
+
export function multiColorGradient(opts, isABGR) {
|
|
7
|
+
const cols = [...gradient(opts)];
|
|
8
|
+
if (isABGR === undefined)
|
|
9
|
+
return cols;
|
|
10
|
+
const rgba = cols.map((x) => argb32(x)[0]);
|
|
11
|
+
return isABGR ? rgba.map(intArgb32Abgr32) : rgba;
|
|
12
|
+
}
|
|
43
13
|
/**
|
|
44
14
|
* Similar to {@link multiColorGradient}, but writes results into `buffer` from
|
|
45
15
|
* given `offset` and component/element strides. Returns buffer.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/color",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.2",
|
|
4
4
|
"description": "Array-based color types, CSS parsing, conversions, transformations, declarative theme generation, gradients, presets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,27 +36,27 @@
|
|
|
36
36
|
"tool:swatches": "tools:node-esm tools/index.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.3.
|
|
40
|
-
"@thi.ng/arrays": "^2.2.
|
|
41
|
-
"@thi.ng/binary": "^3.2.
|
|
42
|
-
"@thi.ng/checks": "^3.1
|
|
43
|
-
"@thi.ng/compare": "^2.1.
|
|
44
|
-
"@thi.ng/compose": "^2.1.
|
|
45
|
-
"@thi.ng/defmulti": "^2.1.
|
|
46
|
-
"@thi.ng/errors": "^2.1.
|
|
47
|
-
"@thi.ng/math": "^5.3.
|
|
48
|
-
"@thi.ng/random": "^3.3.
|
|
49
|
-
"@thi.ng/strings": "^3.3.
|
|
50
|
-
"@thi.ng/transducers": "^8.3.
|
|
51
|
-
"@thi.ng/vectors": "^7.5.
|
|
39
|
+
"@thi.ng/api": "^8.3.7",
|
|
40
|
+
"@thi.ng/arrays": "^2.2.5",
|
|
41
|
+
"@thi.ng/binary": "^3.2.3",
|
|
42
|
+
"@thi.ng/checks": "^3.2.1",
|
|
43
|
+
"@thi.ng/compare": "^2.1.7",
|
|
44
|
+
"@thi.ng/compose": "^2.1.7",
|
|
45
|
+
"@thi.ng/defmulti": "^2.1.7",
|
|
46
|
+
"@thi.ng/errors": "^2.1.7",
|
|
47
|
+
"@thi.ng/math": "^5.3.3",
|
|
48
|
+
"@thi.ng/random": "^3.3.2",
|
|
49
|
+
"@thi.ng/strings": "^3.3.5",
|
|
50
|
+
"@thi.ng/transducers": "^8.3.5",
|
|
51
|
+
"@thi.ng/vectors": "^7.5.6"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@microsoft/api-extractor": "^7.
|
|
55
|
-
"@thi.ng/testament": "^0.2.
|
|
54
|
+
"@microsoft/api-extractor": "^7.25.0",
|
|
55
|
+
"@thi.ng/testament": "^0.2.8",
|
|
56
56
|
"rimraf": "^3.0.2",
|
|
57
57
|
"tools": "^0.0.1",
|
|
58
|
-
"typedoc": "^0.22.
|
|
59
|
-
"typescript": "^4.
|
|
58
|
+
"typedoc": "^0.22.17",
|
|
59
|
+
"typescript": "^4.7.3"
|
|
60
60
|
},
|
|
61
61
|
"keywords": [
|
|
62
62
|
"color",
|
|
@@ -421,5 +421,5 @@
|
|
|
421
421
|
"vectors"
|
|
422
422
|
]
|
|
423
423
|
},
|
|
424
|
-
"gitHead": "
|
|
424
|
+
"gitHead": "73139849c7b46c0451693d994e14a34bc2434280\n"
|
|
425
425
|
}
|
package/strategies.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { LCH } from "./lch/lch.js";
|
|
|
7
7
|
* @param deltaL -
|
|
8
8
|
* @param deltaC -
|
|
9
9
|
*/
|
|
10
|
-
export declare const complementaryStrategy: (src: LCH, deltaL?: number
|
|
10
|
+
export declare const complementaryStrategy: (src: LCH, deltaL?: number, deltaC?: number) => LCH[];
|
|
11
11
|
/**
|
|
12
12
|
* Returns array of `src` color and 2 neighboring colors, each ±rotated by
|
|
13
13
|
* normalized `theta` and possibly adjusted via optional `deltaL` and `deltaC`
|
|
@@ -18,7 +18,7 @@ export declare const complementaryStrategy: (src: LCH, deltaL?: number | undefin
|
|
|
18
18
|
* @param deltaL -
|
|
19
19
|
* @param deltaC -
|
|
20
20
|
*/
|
|
21
|
-
export declare const analogStrategy: (src: LCH, theta?: number, deltaL?: number
|
|
21
|
+
export declare const analogStrategy: (src: LCH, theta?: number, deltaL?: number, deltaC?: number) => LCH[];
|
|
22
22
|
/**
|
|
23
23
|
* Similar to {@link splitComplementaryStrategy}. Returns array of `src` color,
|
|
24
24
|
* its complementary color and 2 of that colors' neighbors, each ±rotated by
|
|
@@ -30,7 +30,7 @@ export declare const analogStrategy: (src: LCH, theta?: number, deltaL?: number
|
|
|
30
30
|
* @param deltaL -
|
|
31
31
|
* @param deltaC -
|
|
32
32
|
*/
|
|
33
|
-
export declare const splitAnalogStrategy: (src: LCH, theta?: number, deltaL?: number
|
|
33
|
+
export declare const splitAnalogStrategy: (src: LCH, theta?: number, deltaL?: number, deltaC?: number) => LCH[];
|
|
34
34
|
/**
|
|
35
35
|
* Similar to {@link splitAnalogStrategy}. Returns array of `src` color and 2
|
|
36
36
|
* neighbors of its complementary color, each ±rotated by normalized `theta`
|
|
@@ -42,7 +42,7 @@ export declare const splitAnalogStrategy: (src: LCH, theta?: number, deltaL?: nu
|
|
|
42
42
|
* @param deltaL -
|
|
43
43
|
* @param deltaC -
|
|
44
44
|
*/
|
|
45
|
-
export declare const splitComplementaryStrategy: (src: LCH, theta?: number, deltaL?: number
|
|
45
|
+
export declare const splitComplementaryStrategy: (src: LCH, theta?: number, deltaL?: number, deltaC?: number) => LCH[];
|
|
46
46
|
/**
|
|
47
47
|
* Returns array of 5 colors all sharing same hue and chromacity of given `src`
|
|
48
48
|
* color, but with these luminance settings: 0.0, 0.25, 0.5, 0.75, 1.0. Chroma
|
|
@@ -62,7 +62,7 @@ export declare const monochromeStrategy: (src: LCH, deltaC?: number) => LCH[];
|
|
|
62
62
|
* @param deltaL -
|
|
63
63
|
* @param deltaC -
|
|
64
64
|
*/
|
|
65
|
-
export declare const triadicStrategy: (src: LCH, deltaL?: number
|
|
65
|
+
export declare const triadicStrategy: (src: LCH, deltaL?: number, deltaC?: number) => LCH[];
|
|
66
66
|
/**
|
|
67
67
|
* Returns array of `src` color and 3 other colors whose hues form a rectangle,
|
|
68
68
|
* using `theta` to define the angular separation. The hues are at: `src`,
|
|
@@ -75,7 +75,7 @@ export declare const triadicStrategy: (src: LCH, deltaL?: number | undefined, de
|
|
|
75
75
|
* @param deltaL -
|
|
76
76
|
* @param deltaC -
|
|
77
77
|
*/
|
|
78
|
-
export declare const tetradicStrategy: (src: LCH, theta?: number, deltaL?: number
|
|
78
|
+
export declare const tetradicStrategy: (src: LCH, theta?: number, deltaL?: number, deltaC?: number) => LCH[];
|
|
79
79
|
/**
|
|
80
80
|
* Version of {@link tetradicStrategy} with an hardcoded `theta` of 1/4 to
|
|
81
81
|
* produce 4 colors with hues uniformly distributed on the color wheel (possibly
|
|
@@ -86,5 +86,5 @@ export declare const tetradicStrategy: (src: LCH, theta?: number, deltaL?: numbe
|
|
|
86
86
|
* @param deltaL -
|
|
87
87
|
* @param deltaC -
|
|
88
88
|
*/
|
|
89
|
-
export declare const squareStrategy: (src: LCH, deltaL?: number
|
|
89
|
+
export declare const squareStrategy: (src: LCH, deltaL?: number, deltaC?: number) => LCH[];
|
|
90
90
|
//# sourceMappingURL=strategies.d.ts.map
|
package/swatches.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Fn2, IObjectOf } from "@thi.ng/api";
|
|
2
2
|
import type { ReadonlyColor } from "./api.js";
|
|
3
3
|
export declare const swatches: (cols: (ReadonlyColor | string)[], shapeFn: Fn2<ReadonlyColor | string, number, any[]>, attribs?: IObjectOf<any>) => (string | IObjectOf<any>)[];
|
|
4
|
-
export declare const swatchesH: (cols: (ReadonlyColor | string)[], w?: number, h?: number, gap?: number, attribs?: IObjectOf<any>
|
|
5
|
-
export declare const dotsH: (cols: (ReadonlyColor | string)[], r?: number, gap?: number, attribs?: IObjectOf<any>
|
|
4
|
+
export declare const swatchesH: (cols: (ReadonlyColor | string)[], w?: number, h?: number, gap?: number, attribs?: IObjectOf<any>) => (string | IObjectOf<any>)[];
|
|
5
|
+
export declare const dotsH: (cols: (ReadonlyColor | string)[], r?: number, gap?: number, attribs?: IObjectOf<any>) => (string | IObjectOf<any>)[];
|
|
6
6
|
export declare const swatchesV: (cols: (ReadonlyColor | string)[], w?: number, h?: number, gap?: number, attribs?: IObjectOf<any>) => (string | IObjectOf<any>)[];
|
|
7
|
-
export declare const dotsV: (cols: (ReadonlyColor | string)[], r?: number, gap?: number, attribs?: IObjectOf<any>
|
|
7
|
+
export declare const dotsV: (cols: (ReadonlyColor | string)[], r?: number, gap?: number, attribs?: IObjectOf<any>) => (string | IObjectOf<any>)[];
|
|
8
8
|
//# sourceMappingURL=swatches.d.ts.map
|