@thi.ng/color 5.3.3 → 5.4.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 +39 -1
- package/README.md +22 -19
- package/alpha.d.ts +8 -0
- package/alpha.js +8 -0
- package/analog.d.ts +4 -0
- package/analog.js +5 -1
- package/api.d.ts +13 -2
- package/clamp.d.ts +13 -3
- package/clamp.js +13 -3
- package/color.d.ts +23 -0
- package/color.js +6 -1
- package/convert.d.ts +9 -0
- package/convert.js +9 -0
- package/css/css.d.ts +22 -4
- package/css/css.js +33 -12
- package/css/parse-css.d.ts +25 -0
- package/css/parse-css.js +83 -33
- package/defcolor.js +2 -2
- package/distance.d.ts +8 -3
- package/distance.js +12 -8
- package/hcy/hcy.d.ts +5 -0
- package/hcy/hcy.js +5 -0
- package/hsi/hsi.d.ts +5 -0
- package/hsi/hsi.js +5 -0
- package/hsl/hsl.d.ts +5 -0
- package/hsl/hsl.js +5 -0
- package/hsv/hsv.d.ts +5 -0
- package/hsv/hsv.js +5 -0
- package/index.d.ts +5 -0
- package/index.js +5 -0
- package/internal/css.d.ts +4 -0
- package/internal/css.js +18 -0
- package/invert.d.ts +9 -0
- package/invert.js +9 -0
- package/lab/lab-css.js +2 -10
- package/lch/lch-css.js +2 -11
- package/lch/lch.d.ts +5 -1
- package/lch/lch.js +5 -1
- package/lighten.d.ts +3 -0
- package/lighten.js +3 -0
- package/mix.d.ts +3 -1
- package/mix.js +3 -1
- package/oklab/oklab-css.d.ts +11 -0
- package/oklab/oklab-css.js +10 -0
- package/oklab/oklab-rgb.js +11 -2
- package/oklab/oklab.js +2 -2
- package/oklch/oklab-oklch.d.ts +3 -0
- package/oklch/oklab-oklch.js +15 -0
- package/oklch/oklch-css.d.ts +11 -0
- package/oklch/oklch-css.js +10 -0
- package/oklch/oklch-oklab.d.ts +11 -0
- package/oklch/oklch-oklab.js +13 -0
- package/oklch/oklch.d.ts +37 -0
- package/oklch/oklch.js +26 -0
- package/package.json +32 -14
- package/rgb/rgb-oklab.js +11 -2
- package/rotate.d.ts +33 -0
- package/rotate.js +34 -1
- package/tint.d.ts +47 -0
- package/tint.js +48 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReadonlyColor } from "../api.js";
|
|
2
|
+
/**
|
|
3
|
+
* @remarks
|
|
4
|
+
* Only supported in CSS Color Level 4 onwards
|
|
5
|
+
* - https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch
|
|
6
|
+
* - https://test.csswg.org/harness/results/css-color-4_dev/grouped/ (test reports)
|
|
7
|
+
*
|
|
8
|
+
* @param src -
|
|
9
|
+
*/
|
|
10
|
+
export declare const oklchCss: (src: ReadonlyColor) => string;
|
|
11
|
+
//# sourceMappingURL=oklch-css.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __lchCss } from "../internal/css.js";
|
|
2
|
+
/**
|
|
3
|
+
* @remarks
|
|
4
|
+
* Only supported in CSS Color Level 4 onwards
|
|
5
|
+
* - https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch
|
|
6
|
+
* - https://test.csswg.org/harness/results/css-color-4_dev/grouped/ (test reports)
|
|
7
|
+
*
|
|
8
|
+
* @param src -
|
|
9
|
+
*/
|
|
10
|
+
export const oklchCss = (src) => __lchCss("oklch", src, 1);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ColorOp } from "../api.js";
|
|
2
|
+
/**
|
|
3
|
+
* @remarks
|
|
4
|
+
* Reference:
|
|
5
|
+
* - https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
|
6
|
+
*
|
|
7
|
+
* @param out
|
|
8
|
+
* @param src
|
|
9
|
+
*/
|
|
10
|
+
export declare const oklchOklab: ColorOp;
|
|
11
|
+
//# sourceMappingURL=oklch-oklab.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cossin } from "@thi.ng/math/angle";
|
|
2
|
+
import { TAU } from "@thi.ng/math/api";
|
|
3
|
+
import { setC4 } from "@thi.ng/vectors/setc";
|
|
4
|
+
import { __ensureAlpha } from "../internal/ensure.js";
|
|
5
|
+
/**
|
|
6
|
+
* @remarks
|
|
7
|
+
* Reference:
|
|
8
|
+
* - https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
|
9
|
+
*
|
|
10
|
+
* @param out
|
|
11
|
+
* @param src
|
|
12
|
+
*/
|
|
13
|
+
export const oklchOklab = (out, src) => setC4(out || src, src[0], ...cossin(src[2] * TAU, src[1]), __ensureAlpha(src[3]));
|
package/oklch/oklch.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { NumericArray } from "@thi.ng/api";
|
|
2
|
+
import type { IRandom } from "@thi.ng/random";
|
|
3
|
+
import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api.js";
|
|
4
|
+
export declare class Oklch implements TypedColor<Oklch> {
|
|
5
|
+
buf: NumericArray;
|
|
6
|
+
offset: number;
|
|
7
|
+
stride: number;
|
|
8
|
+
l: number;
|
|
9
|
+
c: number;
|
|
10
|
+
h: number;
|
|
11
|
+
alpha: number;
|
|
12
|
+
[id: number]: number;
|
|
13
|
+
readonly mode: "oklch";
|
|
14
|
+
readonly length: 4;
|
|
15
|
+
readonly range: [ReadonlyColor, ReadonlyColor];
|
|
16
|
+
[Symbol.iterator](): Iterator<number, any, undefined>;
|
|
17
|
+
clamp(): this;
|
|
18
|
+
copy(): Oklch;
|
|
19
|
+
copyView(): Oklch;
|
|
20
|
+
deref(): Color;
|
|
21
|
+
empty(): Oklch;
|
|
22
|
+
eqDelta(o: Oklch, eps?: number): boolean;
|
|
23
|
+
randomize(rnd?: IRandom): this;
|
|
24
|
+
set(src: ReadonlyColor): this;
|
|
25
|
+
toJSON(): number[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Oklch color type aka polar version of {@link oklab}.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Note: As with other hue-based color modes in this package, the hue is stored
|
|
32
|
+
* normalized (in [0..1] interval) and NOT as degrees.
|
|
33
|
+
*
|
|
34
|
+
* Reference: https://bottosson.github.io/posts/oklab/
|
|
35
|
+
*/
|
|
36
|
+
export declare const oklch: ColorFactory<Oklch>;
|
|
37
|
+
//# sourceMappingURL=oklch.d.ts.map
|
package/oklch/oklch.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defColor } from "../defcolor.js";
|
|
2
|
+
import { oklabRgb } from "../oklab/oklab-rgb.js";
|
|
3
|
+
import { rgbOklab } from "../rgb/rgb-oklab.js";
|
|
4
|
+
import { oklabOklch } from "./oklab-oklch.js";
|
|
5
|
+
import { oklchOklab } from "./oklch-oklab.js";
|
|
6
|
+
/**
|
|
7
|
+
* Oklch color type aka polar version of {@link oklab}.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Note: As with other hue-based color modes in this package, the hue is stored
|
|
11
|
+
* normalized (in [0..1] interval) and NOT as degrees.
|
|
12
|
+
*
|
|
13
|
+
* Reference: https://bottosson.github.io/posts/oklab/
|
|
14
|
+
*/
|
|
15
|
+
export const oklch = defColor({
|
|
16
|
+
mode: "oklch",
|
|
17
|
+
channels: {
|
|
18
|
+
c: { range: [0, 0.3225] },
|
|
19
|
+
},
|
|
20
|
+
order: ["l", "c", "h", "alpha"],
|
|
21
|
+
from: {
|
|
22
|
+
oklab: oklabOklch,
|
|
23
|
+
rgb: (out, src) => oklabOklch(null, rgbOklab(out, src)),
|
|
24
|
+
},
|
|
25
|
+
toRgb: [oklchOklab, oklabRgb],
|
|
26
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/color",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.1",
|
|
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",
|
|
@@ -32,23 +32,25 @@
|
|
|
32
32
|
"doc:stats": "tools:module-stats",
|
|
33
33
|
"pub": "yarn npm publish --access public",
|
|
34
34
|
"test": "testament test",
|
|
35
|
+
"tool:limits": "tools:node-esm tools/limits.ts",
|
|
35
36
|
"tool:maxchroma": "tools:node-esm tools/max-chroma.ts",
|
|
37
|
+
"tool:strategies": "tools:node-esm tools/strategies.ts",
|
|
36
38
|
"tool:swatches": "tools:node-esm tools/index.ts"
|
|
37
39
|
},
|
|
38
40
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.7.
|
|
40
|
-
"@thi.ng/arrays": "^2.5.
|
|
41
|
-
"@thi.ng/binary": "^3.3.
|
|
41
|
+
"@thi.ng/api": "^8.7.3",
|
|
42
|
+
"@thi.ng/arrays": "^2.5.6",
|
|
43
|
+
"@thi.ng/binary": "^3.3.20",
|
|
42
44
|
"@thi.ng/checks": "^3.3.9",
|
|
43
|
-
"@thi.ng/compare": "^2.1.
|
|
44
|
-
"@thi.ng/compose": "^2.1.
|
|
45
|
-
"@thi.ng/defmulti": "^2.1.
|
|
46
|
-
"@thi.ng/errors": "^2.2.
|
|
47
|
-
"@thi.ng/math": "^5.4.
|
|
48
|
-
"@thi.ng/random": "^3.3.
|
|
49
|
-
"@thi.ng/strings": "^3.4.
|
|
50
|
-
"@thi.ng/transducers": "^8.3.
|
|
51
|
-
"@thi.ng/vectors": "^7.6.
|
|
45
|
+
"@thi.ng/compare": "^2.1.26",
|
|
46
|
+
"@thi.ng/compose": "^2.1.28",
|
|
47
|
+
"@thi.ng/defmulti": "^2.1.31",
|
|
48
|
+
"@thi.ng/errors": "^2.2.12",
|
|
49
|
+
"@thi.ng/math": "^5.4.4",
|
|
50
|
+
"@thi.ng/random": "^3.3.26",
|
|
51
|
+
"@thi.ng/strings": "^3.4.1",
|
|
52
|
+
"@thi.ng/transducers": "^8.3.35",
|
|
53
|
+
"@thi.ng/vectors": "^7.6.5"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|
|
54
56
|
"@microsoft/api-extractor": "^7.34.2",
|
|
@@ -116,6 +118,7 @@
|
|
|
116
118
|
"lab",
|
|
117
119
|
"lch",
|
|
118
120
|
"oklab",
|
|
121
|
+
"oklch",
|
|
119
122
|
"rgb",
|
|
120
123
|
"srgb",
|
|
121
124
|
"xyy",
|
|
@@ -300,6 +303,9 @@
|
|
|
300
303
|
"./mix": {
|
|
301
304
|
"default": "./mix.js"
|
|
302
305
|
},
|
|
306
|
+
"./oklab/oklab-css": {
|
|
307
|
+
"default": "./oklab/oklab-css.js"
|
|
308
|
+
},
|
|
303
309
|
"./oklab/oklab-rgb": {
|
|
304
310
|
"default": "./oklab/oklab-rgb.js"
|
|
305
311
|
},
|
|
@@ -309,6 +315,18 @@
|
|
|
309
315
|
"./oklab/oklab": {
|
|
310
316
|
"default": "./oklab/oklab.js"
|
|
311
317
|
},
|
|
318
|
+
"./oklch/oklab-oklch": {
|
|
319
|
+
"default": "./oklch/oklab-oklch.js"
|
|
320
|
+
},
|
|
321
|
+
"./oklch/oklch-css": {
|
|
322
|
+
"default": "./oklch/oklch-css.js"
|
|
323
|
+
},
|
|
324
|
+
"./oklch/oklch-oklab": {
|
|
325
|
+
"default": "./oklch/oklch-oklab.js"
|
|
326
|
+
},
|
|
327
|
+
"./oklch/oklch": {
|
|
328
|
+
"default": "./oklch/oklch.js"
|
|
329
|
+
},
|
|
312
330
|
"./rgb/hue-rgb": {
|
|
313
331
|
"default": "./rgb/hue-rgb.js"
|
|
314
332
|
},
|
|
@@ -427,5 +445,5 @@
|
|
|
427
445
|
"vectors"
|
|
428
446
|
]
|
|
429
447
|
},
|
|
430
|
-
"gitHead": "
|
|
448
|
+
"gitHead": "f2df4bbd52e8e78e9e7499d73f974f9a2f70f017\n"
|
|
431
449
|
}
|
package/rgb/rgb-oklab.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { powN3 } from "@thi.ng/vectors/pown";
|
|
2
2
|
import { OKLAB_M2 } from "../api/constants.js";
|
|
3
3
|
import { __mulV33 } from "../internal/matrix-ops.js";
|
|
4
|
+
/**
|
|
5
|
+
* @remarks
|
|
6
|
+
* Reference:
|
|
7
|
+
* - https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
// prettier-ignore
|
|
4
12
|
const CONE_LMS = [
|
|
5
|
-
0.
|
|
6
|
-
0.
|
|
13
|
+
0.4122214708, 0.2119034982, 0.0883024619,
|
|
14
|
+
0.5363325363, 0.6806995451, 0.2817188376,
|
|
15
|
+
0.0514459929, 0.1073969566, 0.6299787005,
|
|
7
16
|
];
|
|
8
17
|
/**
|
|
9
18
|
* @remarks
|
package/rotate.d.ts
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
import type { Color, TypedColor } from "./api.js";
|
|
2
|
+
/**
|
|
3
|
+
* Color rotation. Rotates hue by given `theta` and writes result color into
|
|
4
|
+
* `out`.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* If `out` is null, the resulting will be written back into `src`.
|
|
8
|
+
*
|
|
9
|
+
* As with all hue-based color modes in this package, the hue is stored
|
|
10
|
+
* normalized (in [0..1] interval) and NOT as degrees. The same goes for the
|
|
11
|
+
* rotation angle `theta`.
|
|
12
|
+
*
|
|
13
|
+
* Only supported for hue based color modes:
|
|
14
|
+
*
|
|
15
|
+
* - hcy
|
|
16
|
+
* - hsi
|
|
17
|
+
* - hsl
|
|
18
|
+
* - hsv
|
|
19
|
+
* - lch
|
|
20
|
+
* - oklch
|
|
21
|
+
*
|
|
22
|
+
* @param out
|
|
23
|
+
* @param src
|
|
24
|
+
* @param theta
|
|
25
|
+
*/
|
|
2
26
|
export declare const rotate: import("@thi.ng/defmulti").MultiFn3<import("@thi.ng/vectors").Vec | null, TypedColor<any>, number, import("@thi.ng/vectors").Vec>;
|
|
27
|
+
/**
|
|
28
|
+
* Syntax sugar for {@link rotate} with 180 degree rotation.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* If `out` is null, the resulting color will be written back into `src`.
|
|
32
|
+
*
|
|
33
|
+
* @param out
|
|
34
|
+
* @param src
|
|
35
|
+
*/
|
|
3
36
|
export declare const complementary: (out: Color | null, src: TypedColor<any>) => import("@thi.ng/vectors").Vec;
|
|
4
37
|
//# sourceMappingURL=rotate.d.ts.map
|
package/rotate.js
CHANGED
|
@@ -3,8 +3,41 @@ import { fract } from "@thi.ng/math/prec";
|
|
|
3
3
|
import { setC4 } from "@thi.ng/vectors/setc";
|
|
4
4
|
import { __dispatch1 } from "./internal/dispatch.js";
|
|
5
5
|
import { __ensureAlpha } from "./internal/ensure.js";
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Color rotation. Rotates hue by given `theta` and writes result color into
|
|
8
|
+
* `out`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* If `out` is null, the resulting will be written back into `src`.
|
|
12
|
+
*
|
|
13
|
+
* As with all hue-based color modes in this package, the hue is stored
|
|
14
|
+
* normalized (in [0..1] interval) and NOT as degrees. The same goes for the
|
|
15
|
+
* rotation angle `theta`.
|
|
16
|
+
*
|
|
17
|
+
* Only supported for hue based color modes:
|
|
18
|
+
*
|
|
19
|
+
* - hcy
|
|
20
|
+
* - hsi
|
|
21
|
+
* - hsl
|
|
22
|
+
* - hsv
|
|
23
|
+
* - lch
|
|
24
|
+
* - oklch
|
|
25
|
+
*
|
|
26
|
+
* @param out
|
|
27
|
+
* @param src
|
|
28
|
+
* @param theta
|
|
29
|
+
*/
|
|
30
|
+
export const rotate = defmulti(__dispatch1, { hcy: "hsl", hsi: "hsl", hsv: "hsl", oklch: "lch" }, {
|
|
7
31
|
hsl: (out, src, theta) => setC4(out || src, fract(src[0] + theta), src[1], src[2], __ensureAlpha(src[3])),
|
|
8
32
|
lch: (out, src, theta) => setC4(out || src, src[0], src[1], fract(src[2] + theta), __ensureAlpha(src[3])),
|
|
9
33
|
});
|
|
34
|
+
/**
|
|
35
|
+
* Syntax sugar for {@link rotate} with 180 degree rotation.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* If `out` is null, the resulting color will be written back into `src`.
|
|
39
|
+
*
|
|
40
|
+
* @param out
|
|
41
|
+
* @param src
|
|
42
|
+
*/
|
|
10
43
|
export const complementary = (out, src) => rotate(out, src, 0.5);
|
package/tint.d.ts
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
import type { MultiFn3O } from "@thi.ng/defmulti";
|
|
2
2
|
import type { Color, TypedColor } from "./api.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a tinted version of given `src` color and writes result into `out`.
|
|
5
|
+
* The color is interpolated towards given `target` grayscale level (default: 1
|
|
6
|
+
* aka white).
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Reference: https://www.handprint.com/HP/WCL/color3.html#stt
|
|
10
|
+
*
|
|
11
|
+
* If `out` is null, the resulting color will be written back into `src`.
|
|
12
|
+
*
|
|
13
|
+
* Only supported for the following color modes:
|
|
14
|
+
*
|
|
15
|
+
* - hcy
|
|
16
|
+
* - hsi
|
|
17
|
+
* - hsv
|
|
18
|
+
* - lch
|
|
19
|
+
* - oklch
|
|
20
|
+
*
|
|
21
|
+
* @param out
|
|
22
|
+
* @param src
|
|
23
|
+
* @param amount
|
|
24
|
+
* @param target
|
|
25
|
+
*/
|
|
3
26
|
export declare const tint: MultiFn3O<Color | null, TypedColor<any>, number, number, Color>;
|
|
27
|
+
/**
|
|
28
|
+
* Version of {@link tint} with medium gray as target.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Reference: https://www.handprint.com/HP/WCL/color3.html#stt
|
|
32
|
+
*
|
|
33
|
+
* If `out` is null, the resulting color will be written back into `src`.
|
|
34
|
+
*
|
|
35
|
+
* @param out
|
|
36
|
+
* @param src
|
|
37
|
+
* @param n
|
|
38
|
+
*/
|
|
4
39
|
export declare const tone: (out: Color | null, src: TypedColor<any>, n: number) => import("@thi.ng/vectors").Vec;
|
|
40
|
+
/**
|
|
41
|
+
* Version of {@link tint} with black as target.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Reference: https://www.handprint.com/HP/WCL/color3.html#stt
|
|
45
|
+
*
|
|
46
|
+
* If `out` is null, the resulting color will be written back into `src`.
|
|
47
|
+
*
|
|
48
|
+
* @param out
|
|
49
|
+
* @param src
|
|
50
|
+
* @param n
|
|
51
|
+
*/
|
|
5
52
|
export declare const shade: (out: Color | null, src: TypedColor<any>, n: number) => import("@thi.ng/vectors").Vec;
|
|
6
53
|
//# sourceMappingURL=tint.d.ts.map
|
package/tint.js
CHANGED
|
@@ -3,9 +3,56 @@ import { mix } from "@thi.ng/math/mix";
|
|
|
3
3
|
import { setC4 } from "@thi.ng/vectors";
|
|
4
4
|
import { __dispatch1 } from "./internal/dispatch.js";
|
|
5
5
|
import { __ensureAlpha } from "./internal/ensure.js";
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Creates a tinted version of given `src` color and writes result into `out`.
|
|
8
|
+
* The color is interpolated towards given `target` grayscale level (default: 1
|
|
9
|
+
* aka white).
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* Reference: https://www.handprint.com/HP/WCL/color3.html#stt
|
|
13
|
+
*
|
|
14
|
+
* If `out` is null, the resulting color will be written back into `src`.
|
|
15
|
+
*
|
|
16
|
+
* Only supported for the following color modes:
|
|
17
|
+
*
|
|
18
|
+
* - hcy
|
|
19
|
+
* - hsi
|
|
20
|
+
* - hsv
|
|
21
|
+
* - lch
|
|
22
|
+
* - oklch
|
|
23
|
+
*
|
|
24
|
+
* @param out
|
|
25
|
+
* @param src
|
|
26
|
+
* @param amount
|
|
27
|
+
* @param target
|
|
28
|
+
*/
|
|
29
|
+
export const tint = defmulti(__dispatch1, { hcy: "hsv", hsi: "hsv", hsl: "hsv", oklch: "lch" }, {
|
|
7
30
|
hsv: (out, src, n, l = 1) => setC4(out || src, src[0], src[1] * (1 - n), mix(src[2], l, n), __ensureAlpha(src[3])),
|
|
8
31
|
lch: (out, src, n, l = 1) => setC4(out || src, mix(src[0], l, n), src[1] * (1 - n), src[2], __ensureAlpha(src[3])),
|
|
9
32
|
});
|
|
33
|
+
/**
|
|
34
|
+
* Version of {@link tint} with medium gray as target.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Reference: https://www.handprint.com/HP/WCL/color3.html#stt
|
|
38
|
+
*
|
|
39
|
+
* If `out` is null, the resulting color will be written back into `src`.
|
|
40
|
+
*
|
|
41
|
+
* @param out
|
|
42
|
+
* @param src
|
|
43
|
+
* @param n
|
|
44
|
+
*/
|
|
10
45
|
export const tone = (out, src, n) => tint(out, src, n, 0.5);
|
|
46
|
+
/**
|
|
47
|
+
* Version of {@link tint} with black as target.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* Reference: https://www.handprint.com/HP/WCL/color3.html#stt
|
|
51
|
+
*
|
|
52
|
+
* If `out` is null, the resulting color will be written back into `src`.
|
|
53
|
+
*
|
|
54
|
+
* @param out
|
|
55
|
+
* @param src
|
|
56
|
+
* @param n
|
|
57
|
+
*/
|
|
11
58
|
export const shade = (out, src, n) => tint(out, src, n, 0);
|