color-map 2.2.0 → 2.3.0
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/.claude-plugin/plugin.json +12 -0
- package/.codex-plugin/plugin.json +12 -0
- package/.cursor-plugin/plugin.json +12 -0
- package/CHANGELOG.md +94 -0
- package/README.md +71 -8
- package/bin/cli-CNBftDBE.js +6414 -0
- package/bin/color-map.js +9 -0
- package/bin/index.js +1 -0
- package/cjs/color/index.d.ts +5 -0
- package/cjs/color/index.js +52 -0
- package/cjs/color-wNrkrhC7.js +374 -0
- package/cjs/color-wNrkrhC7.js.map +1 -0
- package/cjs/contrast-XjF5Rwui.js +293 -0
- package/cjs/contrast-XjF5Rwui.js.map +1 -0
- package/cjs/gamut-CG1J2aat.d.ts +158 -0
- package/cjs/gamut-CG1J2aat.d.ts.map +1 -0
- package/cjs/index-BcEqCPHz.d.ts +137 -0
- package/cjs/index-BcEqCPHz.d.ts.map +1 -0
- package/cjs/index-CGKCqRqD.d.ts +111 -0
- package/cjs/index-CGKCqRqD.d.ts.map +1 -0
- package/cjs/index-Cv3iUUYE.d.ts +171 -0
- package/cjs/index-Cv3iUUYE.d.ts.map +1 -0
- package/cjs/index-Dw43Hj4v.d.ts +41 -0
- package/cjs/index-Dw43Hj4v.d.ts.map +1 -0
- package/cjs/index-Dy8UARqO.d.ts +72 -0
- package/cjs/index-Dy8UARqO.d.ts.map +1 -0
- package/cjs/index.d.ts +26 -36
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +83 -62
- package/cjs/index.js.map +1 -1
- package/cjs/legacy/index.d.ts +2 -0
- package/cjs/legacy/index.js +75 -0
- package/cjs/legacy/index.js.map +1 -0
- package/cjs/mix-Cs4owSbW.js +158 -0
- package/cjs/mix-Cs4owSbW.js.map +1 -0
- package/cjs/mix-DGlKoUw4.d.ts +31 -0
- package/cjs/mix-DGlKoUw4.d.ts.map +1 -0
- package/cjs/palette/index.d.ts +3 -0
- package/cjs/palette/index.js +8 -0
- package/cjs/palette-DyFV_KoJ.js +332 -0
- package/cjs/palette-DyFV_KoJ.js.map +1 -0
- package/cjs/parse-8mt2OMKf.js +1508 -0
- package/cjs/parse-8mt2OMKf.js.map +1 -0
- package/cjs/scale/index.d.ts +2 -0
- package/cjs/scale/index.js +11 -0
- package/cjs/scale-Cq9pXrc1.js +318 -0
- package/cjs/scale-Cq9pXrc1.js.map +1 -0
- package/cjs/semantic-CrEIo8tS.d.ts +52 -0
- package/cjs/semantic-CrEIo8tS.d.ts.map +1 -0
- package/cjs/serialize-C69DAmoE.d.ts +25 -0
- package/cjs/serialize-C69DAmoE.d.ts.map +1 -0
- package/cjs/serialize-Ci2X0cPN.js +103 -0
- package/cjs/serialize-Ci2X0cPN.js.map +1 -0
- package/cjs/tokens/index.d.ts +2 -0
- package/cjs/tokens/index.js +6 -0
- package/cjs/tokens-CzXxaMgM.js +168 -0
- package/cjs/tokens-CzXxaMgM.js.map +1 -0
- package/cjs/tone-BAhu-QzQ.js +118 -0
- package/cjs/tone-BAhu-QzQ.js.map +1 -0
- package/dist/color-map.es5.js.map +1 -1
- package/esm/color/a98-rgb.d.ts +7 -0
- package/esm/color/a98-rgb.d.ts.map +1 -0
- package/esm/color/a98-rgb.js +13 -0
- package/esm/color/a98-rgb.js.map +1 -0
- package/esm/color/argb.d.ts +6 -0
- package/esm/color/argb.d.ts.map +1 -0
- package/esm/color/argb.js +25 -0
- package/esm/color/argb.js.map +1 -0
- package/esm/color/calc.js +82 -0
- package/esm/color/calc.js.map +1 -0
- package/esm/color/compare.d.ts +20 -0
- package/esm/color/compare.d.ts.map +1 -0
- package/esm/color/compare.js +46 -0
- package/esm/color/compare.js.map +1 -0
- package/esm/color/contrast.d.ts +107 -0
- package/esm/color/contrast.d.ts.map +1 -0
- package/esm/color/contrast.js +242 -0
- package/esm/color/contrast.js.map +1 -0
- package/esm/color/convert.d.ts +9 -0
- package/esm/color/convert.d.ts.map +1 -0
- package/esm/color/convert.js +45 -0
- package/esm/color/convert.js.map +1 -0
- package/esm/color/display-p3-linear.d.ts +7 -0
- package/esm/color/display-p3-linear.d.ts.map +1 -0
- package/esm/color/display-p3-linear.js +12 -0
- package/esm/color/display-p3-linear.js.map +1 -0
- package/esm/color/display-p3.d.ts +7 -0
- package/esm/color/display-p3.d.ts.map +1 -0
- package/esm/color/display-p3.js +12 -0
- package/esm/color/display-p3.js.map +1 -0
- package/esm/color/expr.d.ts +43 -0
- package/esm/color/expr.d.ts.map +1 -0
- package/esm/color/expr.js +160 -0
- package/esm/color/expr.js.map +1 -0
- package/esm/color/gamut.d.ts +31 -0
- package/esm/color/gamut.d.ts.map +1 -0
- package/esm/color/gamut.js +210 -0
- package/esm/color/gamut.js.map +1 -0
- package/esm/color/hsl.d.ts +7 -0
- package/esm/color/hsl.d.ts.map +1 -0
- package/esm/color/hsl.js +67 -0
- package/esm/color/hsl.js.map +1 -0
- package/esm/color/hwb.d.ts +7 -0
- package/esm/color/hwb.d.ts.map +1 -0
- package/esm/color/hwb.js +40 -0
- package/esm/color/hwb.js.map +1 -0
- package/esm/color/index.d.ts +28 -0
- package/esm/color/index.js +27 -0
- package/esm/color/lab.d.ts +7 -0
- package/esm/color/lab.d.ts.map +1 -0
- package/esm/color/lab.js +33 -0
- package/esm/color/lab.js.map +1 -0
- package/esm/color/lch.d.ts +7 -0
- package/esm/color/lch.d.ts.map +1 -0
- package/esm/color/lch.js +11 -0
- package/esm/color/lch.js.map +1 -0
- package/esm/color/math.js +32 -0
- package/esm/color/math.js.map +1 -0
- package/esm/color/matrices.js +180 -0
- package/esm/color/matrices.js.map +1 -0
- package/esm/color/mix.d.ts +30 -0
- package/esm/color/mix.d.ts.map +1 -0
- package/esm/color/mix.js +152 -0
- package/esm/color/mix.js.map +1 -0
- package/esm/color/named.js +11 -0
- package/esm/color/named.js.map +1 -0
- package/esm/color/oklab.d.ts +7 -0
- package/esm/color/oklab.d.ts.map +1 -0
- package/esm/color/oklab.js +21 -0
- package/esm/color/oklab.js.map +1 -0
- package/esm/color/oklch.d.ts +7 -0
- package/esm/color/oklch.d.ts.map +1 -0
- package/esm/color/oklch.js +11 -0
- package/esm/color/oklch.js.map +1 -0
- package/esm/color/parse.d.ts +9 -0
- package/esm/color/parse.d.ts.map +1 -0
- package/esm/color/parse.js +452 -0
- package/esm/color/parse.js.map +1 -0
- package/esm/color/polar.js +27 -0
- package/esm/color/polar.js.map +1 -0
- package/esm/color/prophoto-rgb.d.ts +7 -0
- package/esm/color/prophoto-rgb.d.ts.map +1 -0
- package/esm/color/prophoto-rgb.js +18 -0
- package/esm/color/prophoto-rgb.js.map +1 -0
- package/esm/color/rec2020.d.ts +7 -0
- package/esm/color/rec2020.d.ts.map +1 -0
- package/esm/color/rec2020.js +13 -0
- package/esm/color/rec2020.js.map +1 -0
- package/esm/color/resolve.d.ts +18 -0
- package/esm/color/resolve.d.ts.map +1 -0
- package/esm/color/resolve.js +98 -0
- package/esm/color/resolve.js.map +1 -0
- package/esm/color/rgb.js +20 -0
- package/esm/color/rgb.js.map +1 -0
- package/esm/color/serialize.d.ts +24 -0
- package/esm/color/serialize.d.ts.map +1 -0
- package/esm/color/serialize.js +88 -0
- package/esm/color/serialize.js.map +1 -0
- package/esm/color/spaces.d.ts +6 -0
- package/esm/color/spaces.d.ts.map +1 -0
- package/esm/color/spaces.js +42 -0
- package/esm/color/spaces.js.map +1 -0
- package/esm/color/srgb-linear.d.ts +7 -0
- package/esm/color/srgb-linear.d.ts.map +1 -0
- package/esm/color/srgb-linear.js +12 -0
- package/esm/color/srgb-linear.js.map +1 -0
- package/esm/color/srgb.d.ts +7 -0
- package/esm/color/srgb.d.ts.map +1 -0
- package/esm/color/srgb.js +12 -0
- package/esm/color/srgb.js.map +1 -0
- package/esm/color/transfer.js +11 -0
- package/esm/color/transfer.js.map +1 -0
- package/esm/color/types.d.ts +23 -0
- package/esm/color/types.d.ts.map +1 -0
- package/esm/color/unknown-name.js +16 -0
- package/esm/color/unknown-name.js.map +1 -0
- package/esm/color/xyz-d50.d.ts +7 -0
- package/esm/color/xyz-d50.d.ts.map +1 -0
- package/esm/color/xyz-d50.js +15 -0
- package/esm/color/xyz-d50.js.map +1 -0
- package/esm/color/xyz-d65.d.ts +4 -0
- package/esm/color/xyz-d65.d.ts.map +1 -0
- package/esm/color/xyz-d65.js +10 -0
- package/esm/color/xyz-d65.js.map +1 -0
- package/esm/index.d.ts +63 -6
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +54 -5
- package/esm/index.js.map +1 -0
- package/esm/legacy/createColors.d.ts +9 -0
- package/esm/legacy/createColors.d.ts.map +1 -0
- package/esm/{createColors.js → legacy/createColors.js} +7 -2
- package/esm/legacy/createColors.js.map +1 -0
- package/esm/legacy/createColorsFromMap.d.ts +9 -0
- package/esm/legacy/createColorsFromMap.d.ts.map +1 -0
- package/esm/{createColorsFromMap.js → legacy/createColorsFromMap.js} +4 -2
- package/esm/legacy/createColorsFromMap.js.map +1 -0
- package/esm/legacy/index.d.ts +6 -0
- package/esm/legacy/index.js +5 -0
- package/esm/legacy/interfaces.d.ts +19 -0
- package/esm/legacy/interfaces.d.ts.map +1 -0
- package/esm/{rgbHex.d.ts → legacy/rgbHex.d.ts} +1 -4
- package/esm/legacy/rgbHex.d.ts.map +1 -0
- package/esm/{rgbHex.js → legacy/rgbHex.js} +1 -2
- package/esm/legacy/rgbHex.js.map +1 -0
- package/esm/legacy/rgbaString.d.ts +4 -0
- package/esm/{rgbaString.d.ts.map → legacy/rgbaString.d.ts.map} +1 -1
- package/esm/legacy/rgbaString.js +8 -0
- package/esm/legacy/rgbaString.js.map +1 -0
- package/esm/palette/dark.d.ts +23 -0
- package/esm/palette/dark.d.ts.map +1 -0
- package/esm/palette/dark.js +54 -0
- package/esm/palette/dark.js.map +1 -0
- package/esm/palette/harmony.d.ts +56 -0
- package/esm/palette/harmony.d.ts.map +1 -0
- package/esm/palette/harmony.js +115 -0
- package/esm/palette/harmony.js.map +1 -0
- package/esm/palette/index.d.ts +5 -0
- package/esm/palette/index.js +5 -0
- package/esm/palette/semantic.d.ts +53 -0
- package/esm/palette/semantic.d.ts.map +1 -0
- package/esm/palette/semantic.js +96 -0
- package/esm/palette/semantic.js.map +1 -0
- package/esm/palette/validate.d.ts +39 -0
- package/esm/palette/validate.d.ts.map +1 -0
- package/esm/palette/validate.js +56 -0
- package/esm/palette/validate.js.map +1 -0
- package/esm/scale/brand.d.ts +21 -0
- package/esm/scale/brand.d.ts.map +1 -0
- package/esm/scale/brand.js +63 -0
- package/esm/scale/brand.js.map +1 -0
- package/esm/scale/contrast-scale.d.ts +33 -0
- package/esm/scale/contrast-scale.d.ts.map +1 -0
- package/esm/scale/contrast-scale.js +26 -0
- package/esm/scale/contrast-scale.js.map +1 -0
- package/esm/scale/gradient.d.ts +38 -0
- package/esm/scale/gradient.d.ts.map +1 -0
- package/esm/scale/gradient.js +73 -0
- package/esm/scale/gradient.js.map +1 -0
- package/esm/scale/index.d.ts +6 -0
- package/esm/scale/index.js +6 -0
- package/esm/scale/scale.d.ts +31 -0
- package/esm/scale/scale.d.ts.map +1 -0
- package/esm/scale/scale.js +152 -0
- package/esm/scale/scale.js.map +1 -0
- package/esm/scale/tone.d.ts +25 -0
- package/esm/scale/tone.d.ts.map +1 -0
- package/esm/scale/tone.js +96 -0
- package/esm/scale/tone.js.map +1 -0
- package/esm/tokens/css.d.ts +18 -0
- package/esm/tokens/css.d.ts.map +1 -0
- package/esm/tokens/css.js +23 -0
- package/esm/tokens/css.js.map +1 -0
- package/esm/tokens/dtcg.d.ts +33 -0
- package/esm/tokens/dtcg.d.ts.map +1 -0
- package/esm/tokens/dtcg.js +42 -0
- package/esm/tokens/dtcg.js.map +1 -0
- package/esm/tokens/index.d.ts +5 -0
- package/esm/tokens/index.js +4 -0
- package/esm/tokens/tailwind.d.ts +19 -0
- package/esm/tokens/tailwind.d.ts.map +1 -0
- package/esm/tokens/tailwind.js +19 -0
- package/esm/tokens/tailwind.js.map +1 -0
- package/esm/tokens/tokens.d.ts +11 -0
- package/esm/tokens/tokens.d.ts.map +1 -0
- package/esm/tokens/tokens.js +77 -0
- package/esm/tokens/tokens.js.map +1 -0
- package/llms.txt +29 -0
- package/package.json +276 -64
- package/plugin.json +18 -0
- package/schemas/contrast.schema.json +24 -0
- package/schemas/convert.schema.json +60 -0
- package/schemas/export.schema.json +106 -0
- package/schemas/find-contrast.schema.json +51 -0
- package/schemas/harmony.schema.json +58 -0
- package/schemas/mix.schema.json +72 -0
- package/schemas/palette.schema.json +56 -0
- package/schemas/scale.schema.json +86 -0
- package/skills/color-map/SKILL.md +38 -0
- package/src/cli/bin.ts +11 -0
- package/src/cli/cli.ts +40 -0
- package/src/cli/commands/contrast.ts +36 -0
- package/src/cli/commands/convert.ts +37 -0
- package/src/cli/commands/export.ts +102 -0
- package/src/cli/commands/find-contrast.ts +37 -0
- package/src/cli/commands/harmony.ts +30 -0
- package/src/cli/commands/mix.ts +29 -0
- package/src/cli/commands/palette.ts +66 -0
- package/src/cli/commands/scale.ts +75 -0
- package/src/cli/index.ts +2 -0
- package/src/cli/schema-command.ts +31 -0
- package/src/cli/schemas.ts +86 -0
- package/src/cli/shared.ts +72 -0
- package/src/cli/testing.ts +27 -0
- package/src/color/a98-rgb.ts +11 -0
- package/src/color/argb.ts +21 -0
- package/src/color/calc.ts +84 -0
- package/src/color/compare.ts +53 -0
- package/src/color/contrast.ts +277 -0
- package/src/color/convert.ts +43 -0
- package/src/color/display-p3-linear.ts +9 -0
- package/src/color/display-p3.ts +9 -0
- package/src/color/expr.ts +158 -0
- package/src/color/gamut.ts +215 -0
- package/src/color/hsl.ts +57 -0
- package/src/color/hwb.ts +26 -0
- package/src/color/index.ts +43 -0
- package/src/color/lab.ts +29 -0
- package/src/color/lch.ts +8 -0
- package/src/color/math.ts +30 -0
- package/src/color/matrices.ts +91 -0
- package/src/color/mix.ts +158 -0
- package/src/color/named.ts +13 -0
- package/src/color/oklab.ts +19 -0
- package/src/color/oklch.ts +8 -0
- package/src/color/parse.ts +355 -0
- package/src/color/polar.ts +17 -0
- package/src/color/prophoto-rgb.ts +18 -0
- package/src/color/rec2020.ts +11 -0
- package/src/color/resolve.ts +87 -0
- package/src/color/rgb.ts +20 -0
- package/src/color/serialize.ts +96 -0
- package/src/color/spaces.ts +42 -0
- package/src/color/srgb-linear.ts +9 -0
- package/src/color/srgb.ts +9 -0
- package/src/color/test-utils.ts +10 -0
- package/src/color/transfer.ts +14 -0
- package/src/color/types.ts +41 -0
- package/src/color/unknown-name.ts +15 -0
- package/src/color/xyz-d50.ts +13 -0
- package/src/color/xyz-d65.ts +8 -0
- package/src/index.ts +37 -0
- package/{ts → src/legacy}/createColors.ts +6 -0
- package/{ts → src/legacy}/createColorsFromMap.ts +3 -0
- package/{ts → src/legacy}/interfaces.ts +4 -0
- package/{ts → src/legacy}/rgbaString.ts +1 -0
- package/src/palette/dark.ts +55 -0
- package/src/palette/harmony.ts +107 -0
- package/src/palette/index.ts +18 -0
- package/src/palette/semantic.ts +120 -0
- package/src/palette/validate.ts +82 -0
- package/src/scale/brand.ts +50 -0
- package/src/scale/contrast-scale.ts +48 -0
- package/src/scale/gradient.ts +91 -0
- package/src/scale/index.ts +5 -0
- package/src/scale/scale.ts +127 -0
- package/src/scale/tone.ts +69 -0
- package/src/tokens/css.ts +32 -0
- package/src/tokens/dtcg.ts +62 -0
- package/src/tokens/index.ts +11 -0
- package/src/tokens/tailwind.ts +24 -0
- package/src/tokens/tokens.ts +82 -0
- package/esm/createColors.d.ts +0 -6
- package/esm/createColors.d.ts.map +0 -1
- package/esm/createColors.js.map +0 -1
- package/esm/createColorsFromMap.d.ts +0 -9
- package/esm/createColorsFromMap.d.ts.map +0 -1
- package/esm/createColorsFromMap.js.map +0 -1
- package/esm/interfaces.d.ts +0 -18
- package/esm/interfaces.d.ts.map +0 -1
- package/esm/rgbHex.d.ts.map +0 -1
- package/esm/rgbHex.js.map +0 -1
- package/esm/rgbaString.d.ts +0 -6
- package/esm/rgbaString.js +0 -8
- package/esm/rgbaString.js.map +0 -1
- /package/{ts → src/legacy}/index.ts +0 -0
- /package/{ts → src/legacy}/rgbHex.ts +0 -0
|
@@ -0,0 +1,1508 @@
|
|
|
1
|
+
// src/color/matrices.ts
|
|
2
|
+
const srgbToXyz = [
|
|
3
|
+
506752 / 1228815,
|
|
4
|
+
87881 / 245763,
|
|
5
|
+
12673 / 70218,
|
|
6
|
+
87098 / 409605,
|
|
7
|
+
175762 / 245763,
|
|
8
|
+
12673 / 175545,
|
|
9
|
+
7918 / 409605,
|
|
10
|
+
87881 / 737289,
|
|
11
|
+
1001167 / 1053270
|
|
12
|
+
];
|
|
13
|
+
const xyzToSrgb = [
|
|
14
|
+
12831 / 3959,
|
|
15
|
+
-329 / 214,
|
|
16
|
+
-1974 / 3959,
|
|
17
|
+
-851781 / 878810,
|
|
18
|
+
1648619 / 878810,
|
|
19
|
+
36519 / 878810,
|
|
20
|
+
705 / 12673,
|
|
21
|
+
-2585 / 12673,
|
|
22
|
+
705 / 667
|
|
23
|
+
];
|
|
24
|
+
const p3ToXyz = [
|
|
25
|
+
608311 / 1250200,
|
|
26
|
+
189793 / 714400,
|
|
27
|
+
198249 / 1000160,
|
|
28
|
+
35783 / 156275,
|
|
29
|
+
247089 / 357200,
|
|
30
|
+
198249 / 2500400,
|
|
31
|
+
0,
|
|
32
|
+
32229 / 714400,
|
|
33
|
+
5220557 / 5000800
|
|
34
|
+
];
|
|
35
|
+
const xyzToP3 = [
|
|
36
|
+
446124 / 178915,
|
|
37
|
+
-333277 / 357830,
|
|
38
|
+
-72051 / 178915,
|
|
39
|
+
-14852 / 17905,
|
|
40
|
+
63121 / 35810,
|
|
41
|
+
423 / 17905,
|
|
42
|
+
11844 / 330415,
|
|
43
|
+
-50337 / 660830,
|
|
44
|
+
316169 / 330415
|
|
45
|
+
];
|
|
46
|
+
const a98ToXyz = [
|
|
47
|
+
573536 / 994567,
|
|
48
|
+
263643 / 1420810,
|
|
49
|
+
187206 / 994567,
|
|
50
|
+
591459 / 1989134,
|
|
51
|
+
6239551 / 9945670,
|
|
52
|
+
374412 / 4972835,
|
|
53
|
+
53769 / 1989134,
|
|
54
|
+
351524 / 4972835,
|
|
55
|
+
4929758 / 4972835
|
|
56
|
+
];
|
|
57
|
+
const xyzToA98 = [
|
|
58
|
+
1829569 / 896150,
|
|
59
|
+
-506331 / 896150,
|
|
60
|
+
-308931 / 896150,
|
|
61
|
+
-851781 / 878810,
|
|
62
|
+
1648619 / 878810,
|
|
63
|
+
36519 / 878810,
|
|
64
|
+
16779 / 1248040,
|
|
65
|
+
-147721 / 1248040,
|
|
66
|
+
1266979 / 1248040
|
|
67
|
+
];
|
|
68
|
+
const prophotoToXyzD50 = [
|
|
69
|
+
.7977666449006423,
|
|
70
|
+
.13518129740053308,
|
|
71
|
+
.0313477341283922,
|
|
72
|
+
.2880748288194013,
|
|
73
|
+
.711835234241873,
|
|
74
|
+
8993693872564e-17,
|
|
75
|
+
0,
|
|
76
|
+
0,
|
|
77
|
+
.8251046025104602
|
|
78
|
+
];
|
|
79
|
+
const xyzD50ToProphoto = [
|
|
80
|
+
1.3457868816471583,
|
|
81
|
+
-.25557208737979464,
|
|
82
|
+
-.05110186497554526,
|
|
83
|
+
-.5446307051249019,
|
|
84
|
+
1.5082477428451468,
|
|
85
|
+
.02052744743642139,
|
|
86
|
+
0,
|
|
87
|
+
0,
|
|
88
|
+
1.2119675456389452
|
|
89
|
+
];
|
|
90
|
+
const rec2020ToXyz = [
|
|
91
|
+
63426534 / 99577255,
|
|
92
|
+
20160776 / 139408157,
|
|
93
|
+
47086771 / 278816314,
|
|
94
|
+
26158966 / 99577255,
|
|
95
|
+
472592308 / 697040785,
|
|
96
|
+
8267143 / 139408157,
|
|
97
|
+
0,
|
|
98
|
+
19567812 / 697040785,
|
|
99
|
+
295819943 / 278816314
|
|
100
|
+
];
|
|
101
|
+
const xyzToRec2020 = [
|
|
102
|
+
30757411 / 17917100,
|
|
103
|
+
-6372589 / 17917100,
|
|
104
|
+
-4539589 / 17917100,
|
|
105
|
+
-19765991 / 29648200,
|
|
106
|
+
47925759 / 29648200,
|
|
107
|
+
467509 / 29648200,
|
|
108
|
+
792561 / 44930125,
|
|
109
|
+
-1921689 / 44930125,
|
|
110
|
+
42328811 / 44930125
|
|
111
|
+
];
|
|
112
|
+
const d65ToD50 = [
|
|
113
|
+
1.0479297925449969,
|
|
114
|
+
.022946870601609652,
|
|
115
|
+
-.05019226628920524,
|
|
116
|
+
.02962780877005599,
|
|
117
|
+
.9904344267538799,
|
|
118
|
+
-.017073799063418826,
|
|
119
|
+
-.009243040646204504,
|
|
120
|
+
.015055191490298152,
|
|
121
|
+
.7518742814281371
|
|
122
|
+
];
|
|
123
|
+
const d50ToD65 = [
|
|
124
|
+
.955473421488075,
|
|
125
|
+
-.02309845494876471,
|
|
126
|
+
.06325924320057072,
|
|
127
|
+
-.0283697093338637,
|
|
128
|
+
1.0099953980813041,
|
|
129
|
+
.021041441191917323,
|
|
130
|
+
.012314014864481998,
|
|
131
|
+
-.020507649298898964,
|
|
132
|
+
1.330365926242124
|
|
133
|
+
];
|
|
134
|
+
const xyzToLms = [
|
|
135
|
+
.819022437996703,
|
|
136
|
+
.3619062600528904,
|
|
137
|
+
-.1288737815209879,
|
|
138
|
+
.0329836539323885,
|
|
139
|
+
.9292868615863434,
|
|
140
|
+
.0361446663506424,
|
|
141
|
+
.0481771893596242,
|
|
142
|
+
.2642395317527308,
|
|
143
|
+
.6335478284694309
|
|
144
|
+
];
|
|
145
|
+
const lmsToOklab = [
|
|
146
|
+
.210454268309314,
|
|
147
|
+
.7936177747023054,
|
|
148
|
+
-.0040720430116193,
|
|
149
|
+
1.9779985324311684,
|
|
150
|
+
-2.42859224204858,
|
|
151
|
+
.450593709617411,
|
|
152
|
+
.0259040424655478,
|
|
153
|
+
.7827717124575296,
|
|
154
|
+
-.8086757549230774
|
|
155
|
+
];
|
|
156
|
+
const lmsToXyz = [
|
|
157
|
+
1.2268798758459243,
|
|
158
|
+
-.5578149944602171,
|
|
159
|
+
.2813910456659647,
|
|
160
|
+
-.0405757452148008,
|
|
161
|
+
1.112286803280317,
|
|
162
|
+
-.0717110580655164,
|
|
163
|
+
-.0763729366746601,
|
|
164
|
+
-.4214933324022432,
|
|
165
|
+
1.5869240198367816
|
|
166
|
+
];
|
|
167
|
+
const oklabToLms = [
|
|
168
|
+
1,
|
|
169
|
+
.3963377773761749,
|
|
170
|
+
.2158037573099136,
|
|
171
|
+
1,
|
|
172
|
+
-.1055613458156586,
|
|
173
|
+
-.0638541728258133,
|
|
174
|
+
1,
|
|
175
|
+
-.0894841775298119,
|
|
176
|
+
-1.2914855480194092
|
|
177
|
+
];
|
|
178
|
+
// src/color/math.ts
|
|
179
|
+
/** `m` times the column vector (x, y, z). Takes numbers rather than a Vec3, so callers need no array. */
|
|
180
|
+
function multiply(m, x, y, z) {
|
|
181
|
+
return [
|
|
182
|
+
m[0] * x + m[1] * y + m[2] * z,
|
|
183
|
+
m[3] * x + m[4] * y + m[5] * z,
|
|
184
|
+
m[6] * x + m[7] * y + m[8] * z
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
/** Keeps the sign, so out-of-gamut values survive the transfer function. */
|
|
188
|
+
function signed(f) {
|
|
189
|
+
return (n) => n < 0 ? -f(-n) : f(n);
|
|
190
|
+
}
|
|
191
|
+
function normalizeHue(h) {
|
|
192
|
+
return (h % 360 + 360) % 360;
|
|
193
|
+
}
|
|
194
|
+
const D50 = [
|
|
195
|
+
.3457 / .3585,
|
|
196
|
+
1,
|
|
197
|
+
.2958 / .3585
|
|
198
|
+
];
|
|
199
|
+
/** The product of 3x3 matrices, left to right: `product(a, b)` applies `b` first. */
|
|
200
|
+
function product(...ms) {
|
|
201
|
+
return ms.reduce((a, b) => {
|
|
202
|
+
const out = [];
|
|
203
|
+
for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) out.push(a[i * 3] * b[j] + a[i * 3 + 1] * b[3 + j] + a[i * 3 + 2] * b[6 + j]);
|
|
204
|
+
return out;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// src/color/rgb.ts
|
|
208
|
+
/** An RGB space: a transfer function, then a matrix to XYZ-D65. */
|
|
209
|
+
function rgbSpace(id, toLinear, toGamma, toXyz, fromXyz) {
|
|
210
|
+
return {
|
|
211
|
+
id,
|
|
212
|
+
toXyz: (c) => multiply(toXyz, toLinear(c[0]), toLinear(c[1]), toLinear(c[2])),
|
|
213
|
+
fromXyz: (xyz) => {
|
|
214
|
+
const v = multiply(fromXyz, xyz[0], xyz[1], xyz[2]);
|
|
215
|
+
return [
|
|
216
|
+
toGamma(v[0]),
|
|
217
|
+
toGamma(v[1]),
|
|
218
|
+
toGamma(v[2])
|
|
219
|
+
];
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
// src/color/transfer.ts
|
|
224
|
+
const identity = (n) => n;
|
|
225
|
+
const srgbToLinear = signed((a) => a <= .04045 ? a / 12.92 : ((a + .055) / 1.055) ** 2.4);
|
|
226
|
+
const srgbToGamma = signed((a) => a > .0031308 ? 1.055 * a ** (1 / 2.4) - .055 : 12.92 * a);
|
|
227
|
+
const power = (gamma) => [signed((a) => a ** gamma), signed((a) => a ** (1 / gamma))];
|
|
228
|
+
const prophotoToLinear = signed((a) => a <= 16 / 512 ? a / 16 : a ** 1.8);
|
|
229
|
+
const prophotoToGamma = signed((a) => a >= 1 / 512 ? a ** (1 / 1.8) : 16 * a);
|
|
230
|
+
// src/color/a98-rgb.ts
|
|
231
|
+
const [toLinear$1, toGamma$1] = power(563 / 256);
|
|
232
|
+
/**
|
|
233
|
+
* The CSS `a98-rgb` space (Adobe RGB 1998). Components are red, green and blue in 0 to 1, with a 563/256 power transfer curve.
|
|
234
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
235
|
+
*/
|
|
236
|
+
const a98Rgb = rgbSpace("a98-rgb", toLinear$1, toGamma$1, a98ToXyz, xyzToA98);
|
|
237
|
+
// src/color/unknown-name.ts
|
|
238
|
+
/**
|
|
239
|
+
* The error for a name a caller wrote that the library does not know: it names
|
|
240
|
+
* the value and lists the valid ones, in the style of `unknown color space`.
|
|
241
|
+
*/
|
|
242
|
+
function unknownName(what, value, valid) {
|
|
243
|
+
return /* @__PURE__ */ new Error(`color-map: unknown ${what} "${String(value)}"${valid.length ? `; use one of ${valid.join(", ")}` : ""}`);
|
|
244
|
+
}
|
|
245
|
+
/** `mode` itself when it is `light` or `dark`; any other value is an unknown mode. */
|
|
246
|
+
function checkMode(mode) {
|
|
247
|
+
if (mode !== "light" && mode !== "dark") throw unknownName("mode", mode, ["light", "dark"]);
|
|
248
|
+
return mode;
|
|
249
|
+
}
|
|
250
|
+
// src/color/convert.ts
|
|
251
|
+
/** Converts bare components between two spaces, through the XYZ-D65 hub. */
|
|
252
|
+
function convertComponents(from, to, c) {
|
|
253
|
+
return from === to ? c : to.fromXyz(from.toXyz(c));
|
|
254
|
+
}
|
|
255
|
+
/** {@link ComponentsIn} over the spaces given. */
|
|
256
|
+
function componentsOver(spaces) {
|
|
257
|
+
const byId = new Map(spaces.map((s) => [s.id, s]));
|
|
258
|
+
const find = (id) => {
|
|
259
|
+
const space = byId.get(id);
|
|
260
|
+
if (!space) throw unknownName("color space", id, [...byId.keys()]);
|
|
261
|
+
return space;
|
|
262
|
+
};
|
|
263
|
+
return (color, to) => {
|
|
264
|
+
if (color.colorSpace === to) return [...color.components];
|
|
265
|
+
const from = find(color.colorSpace);
|
|
266
|
+
const c = color.components;
|
|
267
|
+
return find(to).fromXyz(from.toXyz([
|
|
268
|
+
c[0] ?? 0,
|
|
269
|
+
c[1] ?? 0,
|
|
270
|
+
c[2] ?? 0
|
|
271
|
+
]));
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/** `convert` over the spaces `componentsIn` knows: the color in `to`, keeping its alpha. */
|
|
275
|
+
function convertWith(componentsIn, color, to) {
|
|
276
|
+
const result = {
|
|
277
|
+
colorSpace: to,
|
|
278
|
+
components: componentsIn(color, to)
|
|
279
|
+
};
|
|
280
|
+
if (color.alpha !== void 0) result.alpha = color.alpha;
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Builds `convert` over just the spaces given, so a bundle contains only those.
|
|
285
|
+
* `none` components become 0 when the space changes.
|
|
286
|
+
*/
|
|
287
|
+
function createConverter(...spaces) {
|
|
288
|
+
const componentsIn = componentsOver(spaces);
|
|
289
|
+
return (color, to) => convertWith(componentsIn, color, to);
|
|
290
|
+
}
|
|
291
|
+
// src/color/oklab.ts
|
|
292
|
+
/**
|
|
293
|
+
* The CSS `oklab` space. Components are lightness in 0 to 1, then the a and b axes, which stay within about -0.4 to 0.4 for real colors.
|
|
294
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
295
|
+
*/
|
|
296
|
+
const oklab = {
|
|
297
|
+
id: "oklab",
|
|
298
|
+
toXyz: (c) => {
|
|
299
|
+
const v = multiply(oklabToLms, c[0], c[1], c[2]);
|
|
300
|
+
return multiply(lmsToXyz, v[0] ** 3, v[1] ** 3, v[2] ** 3);
|
|
301
|
+
},
|
|
302
|
+
fromXyz: (xyz) => {
|
|
303
|
+
const v = multiply(xyzToLms, xyz[0], xyz[1], xyz[2]);
|
|
304
|
+
return multiply(lmsToOklab, Math.cbrt(v[0]), Math.cbrt(v[1]), Math.cbrt(v[2]));
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
// src/color/display-p3.ts
|
|
308
|
+
/**
|
|
309
|
+
* The CSS `display-p3` space. Components are red, green and blue in 0 to 1, with the sRGB transfer curve.
|
|
310
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
311
|
+
*/
|
|
312
|
+
const displayP3 = rgbSpace("display-p3", srgbToLinear, srgbToGamma, p3ToXyz, xyzToP3);
|
|
313
|
+
// src/color/display-p3-linear.ts
|
|
314
|
+
/**
|
|
315
|
+
* The CSS `display-p3-linear` space: Display P3 primaries without a transfer curve. Components are red, green and blue in 0 to 1.
|
|
316
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
317
|
+
*/
|
|
318
|
+
const displayP3Linear = rgbSpace("display-p3-linear", identity, identity, p3ToXyz, xyzToP3);
|
|
319
|
+
// src/color/srgb.ts
|
|
320
|
+
/**
|
|
321
|
+
* The CSS `srgb` space. Components are red, green and blue in 0 to 1, with the sRGB transfer curve.
|
|
322
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
323
|
+
*/
|
|
324
|
+
const srgb = rgbSpace("srgb", srgbToLinear, srgbToGamma, srgbToXyz, xyzToSrgb);
|
|
325
|
+
// src/color/hsl.ts
|
|
326
|
+
function channel$1(t1, t2, sextant) {
|
|
327
|
+
const h = (sextant + 6) % 6;
|
|
328
|
+
if (h < 1) return (t2 - t1) * h + t1;
|
|
329
|
+
if (h < 3) return t2;
|
|
330
|
+
if (h < 4) return (t2 - t1) * (4 - h) + t1;
|
|
331
|
+
return t1;
|
|
332
|
+
}
|
|
333
|
+
/** CSS Color 4 hslToRgb. Hue in degrees, s and l in 0 to 1. */
|
|
334
|
+
function hslToSrgb(h, s, l) {
|
|
335
|
+
const t2 = l <= .5 ? l * (s + 1) : l + s - l * s;
|
|
336
|
+
const t1 = l * 2 - t2;
|
|
337
|
+
const hue = normalizeHue(h) / 60;
|
|
338
|
+
return [
|
|
339
|
+
channel$1(t1, t2, hue + 2),
|
|
340
|
+
channel$1(t1, t2, hue),
|
|
341
|
+
channel$1(t1, t2, hue - 2)
|
|
342
|
+
];
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* CSS Color 4 rgbToHsl. Returns hue in degrees, s and l in 0 to 1. For
|
|
346
|
+
* out-of-gamut input the saturation can come out negative; it is made positive
|
|
347
|
+
* and the hue turned by 180 degrees, unless `flipNegative` is false.
|
|
348
|
+
*/
|
|
349
|
+
function srgbToHsl([r, g, b], flipNegative = true) {
|
|
350
|
+
const max = Math.max(r, g, b);
|
|
351
|
+
const min = Math.min(r, g, b);
|
|
352
|
+
const l = (min + max) / 2;
|
|
353
|
+
const d = max - min;
|
|
354
|
+
let h = 0;
|
|
355
|
+
let s = 0;
|
|
356
|
+
if (d > 1e-9) {
|
|
357
|
+
s = l === 0 || l === 1 ? 0 : (max - l) / Math.min(l, 1 - l);
|
|
358
|
+
h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
|
|
359
|
+
h *= 60;
|
|
360
|
+
}
|
|
361
|
+
if (s < 0) {
|
|
362
|
+
if (flipNegative) h += 180;
|
|
363
|
+
s = -s;
|
|
364
|
+
}
|
|
365
|
+
return [
|
|
366
|
+
normalizeHue(h),
|
|
367
|
+
s,
|
|
368
|
+
l
|
|
369
|
+
];
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* The CSS `hsl` space. Components are hue in degrees, then saturation and lightness in 0 to 100.
|
|
373
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
374
|
+
*/
|
|
375
|
+
const hsl = {
|
|
376
|
+
id: "hsl",
|
|
377
|
+
toXyz: ([h, s, l]) => srgb.toXyz(hslToSrgb(h, s / 100, l / 100)),
|
|
378
|
+
fromXyz: (xyz) => {
|
|
379
|
+
const [h, s, l] = srgbToHsl(srgb.fromXyz(xyz));
|
|
380
|
+
return [
|
|
381
|
+
h,
|
|
382
|
+
s * 100,
|
|
383
|
+
l * 100
|
|
384
|
+
];
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
// src/color/hwb.ts
|
|
388
|
+
/**
|
|
389
|
+
* The CSS `hwb` space. Components are hue in degrees, then whiteness and blackness in 0 to 100.
|
|
390
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
391
|
+
*/
|
|
392
|
+
const hwb = {
|
|
393
|
+
id: "hwb",
|
|
394
|
+
toXyz: ([h, w, b]) => {
|
|
395
|
+
const white = w / 100;
|
|
396
|
+
const black = b / 100;
|
|
397
|
+
if (white + black >= 1) {
|
|
398
|
+
const gray = white / (white + black);
|
|
399
|
+
return srgb.toXyz([
|
|
400
|
+
gray,
|
|
401
|
+
gray,
|
|
402
|
+
gray
|
|
403
|
+
]);
|
|
404
|
+
}
|
|
405
|
+
const k = 1 - white - black;
|
|
406
|
+
const [red, green, blue] = hslToSrgb(h, 1, .5);
|
|
407
|
+
return srgb.toXyz([
|
|
408
|
+
red * k + white,
|
|
409
|
+
green * k + white,
|
|
410
|
+
blue * k + white
|
|
411
|
+
]);
|
|
412
|
+
},
|
|
413
|
+
fromXyz: (xyz) => {
|
|
414
|
+
const rgb = srgb.fromXyz(xyz);
|
|
415
|
+
return [
|
|
416
|
+
srgbToHsl(rgb, false)[0],
|
|
417
|
+
Math.min(...rgb) * 100,
|
|
418
|
+
(1 - Math.max(...rgb)) * 100
|
|
419
|
+
];
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
// src/color/lab.ts
|
|
423
|
+
const EPSILON = 216 / 24389;
|
|
424
|
+
const KAPPA = 24389 / 27;
|
|
425
|
+
const finv = (f) => f ** 3 > EPSILON ? f ** 3 : (116 * f - 16) / KAPPA;
|
|
426
|
+
const forward = (v) => v > EPSILON ? Math.cbrt(v) : (KAPPA * v + 16) / 116;
|
|
427
|
+
/**
|
|
428
|
+
* The CSS `lab` space (CIE Lab, D50 white). Components are lightness in 0 to 100, then the a and b axes, which are not bounded but stay near -125 to 125 for real colors.
|
|
429
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
430
|
+
*/
|
|
431
|
+
const lab = {
|
|
432
|
+
id: "lab",
|
|
433
|
+
toXyz: ([l, a, b]) => {
|
|
434
|
+
const fy = (l + 16) / 116;
|
|
435
|
+
const y = l > KAPPA * EPSILON ? fy ** 3 : l / KAPPA;
|
|
436
|
+
const x = finv(fy + a / 500);
|
|
437
|
+
const z = finv(fy - b / 200);
|
|
438
|
+
return multiply(d50ToD65, x * D50[0], y * D50[1], z * D50[2]);
|
|
439
|
+
},
|
|
440
|
+
fromXyz: (xyz) => {
|
|
441
|
+
const [x, y, z] = multiply(d65ToD50, xyz[0], xyz[1], xyz[2]);
|
|
442
|
+
const fy = forward(y / D50[1]);
|
|
443
|
+
return [
|
|
444
|
+
116 * fy - 16,
|
|
445
|
+
500 * (forward(x / D50[0]) - fy),
|
|
446
|
+
200 * (fy - forward(z / D50[2]))
|
|
447
|
+
];
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
// src/color/polar.ts
|
|
451
|
+
/** Wraps a rectangular Lab-like space as its polar (LCH-like) twin. */
|
|
452
|
+
function polarSpace(id, base) {
|
|
453
|
+
return {
|
|
454
|
+
id,
|
|
455
|
+
toXyz: ([l, c, h]) => {
|
|
456
|
+
const r = h * Math.PI / 180;
|
|
457
|
+
return base.toXyz([
|
|
458
|
+
l,
|
|
459
|
+
c * Math.cos(r),
|
|
460
|
+
c * Math.sin(r)
|
|
461
|
+
]);
|
|
462
|
+
},
|
|
463
|
+
fromXyz: (xyz) => {
|
|
464
|
+
const [l, a, b] = base.fromXyz(xyz);
|
|
465
|
+
return [
|
|
466
|
+
l,
|
|
467
|
+
Math.hypot(a, b),
|
|
468
|
+
normalizeHue(Math.atan2(b, a) * 180 / Math.PI)
|
|
469
|
+
];
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
// src/color/lch.ts
|
|
474
|
+
/**
|
|
475
|
+
* The CSS `lch` space, the polar form of `lab`. Components are lightness in 0 to 100, chroma (not bounded, about 0 to 150) and hue in degrees.
|
|
476
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
477
|
+
*/
|
|
478
|
+
const lch = polarSpace("lch", lab);
|
|
479
|
+
// src/color/oklch.ts
|
|
480
|
+
/**
|
|
481
|
+
* The CSS `oklch` space, the polar form of `oklab`. Components are lightness in 0 to 1, chroma (about 0 to 0.4) and hue in degrees.
|
|
482
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
483
|
+
*/
|
|
484
|
+
const oklch = polarSpace("oklch", oklab);
|
|
485
|
+
// src/color/xyz-d50.ts
|
|
486
|
+
/**
|
|
487
|
+
* The CSS `xyz-d50` space (CIE XYZ, D50 white). Components are X, Y and Z, where Y is 1 for white.
|
|
488
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
489
|
+
*/
|
|
490
|
+
const xyzD50 = {
|
|
491
|
+
id: "xyz-d50",
|
|
492
|
+
toXyz: (c) => multiply(d50ToD65, c[0], c[1], c[2]),
|
|
493
|
+
fromXyz: (xyz) => multiply(d65ToD50, xyz[0], xyz[1], xyz[2])
|
|
494
|
+
};
|
|
495
|
+
// src/color/prophoto-rgb.ts
|
|
496
|
+
const d50 = rgbSpace("prophoto-rgb", prophotoToLinear, prophotoToGamma, prophotoToXyzD50, xyzD50ToProphoto);
|
|
497
|
+
/**
|
|
498
|
+
* The CSS `prophoto-rgb` space. Components are red, green and blue in 0 to 1. It is defined against a D50 white and converted through `xyzD50`.
|
|
499
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
500
|
+
*/
|
|
501
|
+
const prophotoRgb = {
|
|
502
|
+
id: "prophoto-rgb",
|
|
503
|
+
toXyz: (c) => xyzD50.toXyz(d50.toXyz(c)),
|
|
504
|
+
fromXyz: (xyz) => d50.fromXyz(xyzD50.fromXyz(xyz))
|
|
505
|
+
};
|
|
506
|
+
// src/color/rec2020.ts
|
|
507
|
+
const [toLinear, toGamma] = power(2.4);
|
|
508
|
+
/**
|
|
509
|
+
* The CSS `rec2020` space. Components are red, green and blue in 0 to 1, with a 2.4 power transfer curve.
|
|
510
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
511
|
+
*/
|
|
512
|
+
const rec2020 = rgbSpace("rec2020", toLinear, toGamma, rec2020ToXyz, xyzToRec2020);
|
|
513
|
+
// src/color/srgb-linear.ts
|
|
514
|
+
/**
|
|
515
|
+
* The CSS `srgb-linear` space: sRGB primaries without a transfer curve. Components are red, green and blue in 0 to 1.
|
|
516
|
+
* Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.
|
|
517
|
+
*/
|
|
518
|
+
const srgbLinear = rgbSpace("srgb-linear", identity, identity, srgbToXyz, xyzToSrgb);
|
|
519
|
+
// src/color/xyz-d65.ts
|
|
520
|
+
/** The hub every other space converts through. */
|
|
521
|
+
const xyzD65 = {
|
|
522
|
+
id: "xyz-d65",
|
|
523
|
+
toXyz: (c) => c,
|
|
524
|
+
fromXyz: (xyz) => xyz
|
|
525
|
+
};
|
|
526
|
+
// src/color/spaces.ts
|
|
527
|
+
/** Every space. Importing this pulls them all in; import single spaces to avoid that. */
|
|
528
|
+
const spaces = {
|
|
529
|
+
srgb,
|
|
530
|
+
"srgb-linear": srgbLinear,
|
|
531
|
+
hsl,
|
|
532
|
+
hwb,
|
|
533
|
+
lab,
|
|
534
|
+
lch,
|
|
535
|
+
oklab,
|
|
536
|
+
oklch,
|
|
537
|
+
"display-p3": displayP3,
|
|
538
|
+
"display-p3-linear": displayP3Linear,
|
|
539
|
+
"a98-rgb": a98Rgb,
|
|
540
|
+
"prophoto-rgb": prophotoRgb,
|
|
541
|
+
rec2020,
|
|
542
|
+
"xyz-d50": xyzD50,
|
|
543
|
+
"xyz-d65": xyzD65
|
|
544
|
+
};
|
|
545
|
+
/** A color's components in any of the 15 spaces, as `convert` gives them, without the color object. */
|
|
546
|
+
const componentsIn = componentsOver(Object.values(spaces));
|
|
547
|
+
/** Converts a color to any of the 15 spaces. */
|
|
548
|
+
const convert = createConverter(...Object.values(spaces));
|
|
549
|
+
// src/color/compare.ts
|
|
550
|
+
/** Euclidean distance in OKLab, the ΔEOK of CSS Color 4 gamut mapping. */
|
|
551
|
+
function deltaEOk(a, b) {
|
|
552
|
+
return deltaEOkWith(componentsIn, a, b);
|
|
553
|
+
}
|
|
554
|
+
/** {@link deltaEOk} over the spaces `componentsIn` knows, which must include `oklab`. */
|
|
555
|
+
function deltaEOkWith(componentsIn, a, b) {
|
|
556
|
+
const [l1, a1, b1] = componentsIn(a, "oklab");
|
|
557
|
+
const [l2, a2, b2] = componentsIn(b, "oklab");
|
|
558
|
+
return Math.hypot(l1 - l2, a1 - a2, b1 - b2);
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Builds {@link deltaEOk} over the spaces given, plus `oklab`, so a bundle
|
|
562
|
+
* contains only those. A color in a space not given throws, naming that space.
|
|
563
|
+
*/
|
|
564
|
+
function createDeltaEOk(...spaces) {
|
|
565
|
+
const over = componentsOver([oklab, ...spaces]);
|
|
566
|
+
return (a, b) => deltaEOkWith(over, a, b);
|
|
567
|
+
}
|
|
568
|
+
const same = (x, y, epsilon) => x === y || x != null && y != null && Math.abs(x - y) <= epsilon;
|
|
569
|
+
/**
|
|
570
|
+
* True when both colors are the same within `epsilon` per component. Colors in
|
|
571
|
+
* different spaces are compared in the first one's space. `none` equals only
|
|
572
|
+
* `none`, and a missing alpha equals 1.
|
|
573
|
+
*/
|
|
574
|
+
function equals(a, b, epsilon = 1e-6) {
|
|
575
|
+
return equalsWith(componentsIn, a, b, epsilon);
|
|
576
|
+
}
|
|
577
|
+
function equalsWith(componentsIn, a, b, epsilon) {
|
|
578
|
+
const other = convertWith(componentsIn, b, a.colorSpace);
|
|
579
|
+
return same(a.alpha ?? 1, other.alpha ?? 1, epsilon) && a.components.every((c, i) => same(c, other.components[i], epsilon));
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Builds {@link equals} over the spaces given, so a bundle contains only those.
|
|
583
|
+
* It needs no space of its own: give the spaces of both colors.
|
|
584
|
+
*/
|
|
585
|
+
function createEquals(...spaces) {
|
|
586
|
+
const over = componentsOver(spaces);
|
|
587
|
+
return (a, b, epsilon = 1e-6) => equalsWith(over, a, b, epsilon);
|
|
588
|
+
}
|
|
589
|
+
// src/color/gamut.ts
|
|
590
|
+
const within = (components, epsilon) => components.every((c) => c >= -epsilon && c <= 1 + epsilon);
|
|
591
|
+
/** True when every channel of `color`, seen in `gamut`, is within 0 to 1 (± `epsilon`). */
|
|
592
|
+
function inGamut(color, gamut = "srgb", epsilon = 1e-6) {
|
|
593
|
+
return within(componentsIn(color, gamut), epsilon);
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Builds {@link inGamut} over the spaces given, plus `srgb`, so a bundle
|
|
597
|
+
* contains only those. Give the gamut too when it is not `srgb`. A color or
|
|
598
|
+
* gamut in a space not given throws, naming that space.
|
|
599
|
+
*/
|
|
600
|
+
function createInGamut(...spaces) {
|
|
601
|
+
const over = componentsOver([srgb, ...spaces]);
|
|
602
|
+
return (color, gamut = "srgb", epsilon = 1e-6) => within(over(color, gamut), epsilon);
|
|
603
|
+
}
|
|
604
|
+
/** `color` with `components`, which are in `gamut`, clamped to 0 to 1: what `convert` then a clamp gives. */
|
|
605
|
+
function clipped(color, gamut, components) {
|
|
606
|
+
return withAlpha({
|
|
607
|
+
colorSpace: gamut,
|
|
608
|
+
components: components.map((c) => Math.min(1, Math.max(0, c)))
|
|
609
|
+
}, color);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Maps a color into a gamut and returns it in its original space. `css` follows
|
|
613
|
+
* CSS Color 4 section 13.2: reduce OKLCH chroma until the clipped color is
|
|
614
|
+
* within a just-noticeable ΔEOK of 0.02.
|
|
615
|
+
*/
|
|
616
|
+
function toGamut(color, options = {}) {
|
|
617
|
+
return toGamutWith(componentsIn, color, options);
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Builds {@link toGamut} over the spaces given, plus `srgb`, `oklch` and
|
|
621
|
+
* `oklab`, which the CSS method works in. Give the gamut too when it is not
|
|
622
|
+
* `srgb`. A color or gamut in a space not given throws, naming that space.
|
|
623
|
+
*/
|
|
624
|
+
function createToGamut(...spaces) {
|
|
625
|
+
const over = componentsOver([
|
|
626
|
+
srgb,
|
|
627
|
+
oklch,
|
|
628
|
+
oklab,
|
|
629
|
+
...spaces
|
|
630
|
+
]);
|
|
631
|
+
return (color, options = {}) => toGamutWith(over, color, options);
|
|
632
|
+
}
|
|
633
|
+
/** {@link toGamut} over the spaces `componentsIn` knows, which must include `oklch` and `oklab`. */
|
|
634
|
+
function toGamutWith(componentsIn, color, options) {
|
|
635
|
+
const { gamut = "srgb", method = "css" } = options;
|
|
636
|
+
const deltaEOk = (a, b) => deltaEOkWith(componentsIn, a, b);
|
|
637
|
+
const back = (c) => convertWith(componentsIn, c, color.colorSpace);
|
|
638
|
+
const fit = componentsIn(color, gamut);
|
|
639
|
+
if (within(fit, 1e-6)) return color;
|
|
640
|
+
if (method === "clip") return back(clipped(color, gamut, fit));
|
|
641
|
+
const origin = convertWith(componentsIn, color, "oklch");
|
|
642
|
+
const [lightness, chroma, hue] = origin.components;
|
|
643
|
+
if (lightness >= 1) return back(withAlpha({
|
|
644
|
+
colorSpace: gamut,
|
|
645
|
+
components: [
|
|
646
|
+
1,
|
|
647
|
+
1,
|
|
648
|
+
1
|
|
649
|
+
]
|
|
650
|
+
}, color));
|
|
651
|
+
if (lightness <= 0) return back(withAlpha({
|
|
652
|
+
colorSpace: gamut,
|
|
653
|
+
components: [
|
|
654
|
+
0,
|
|
655
|
+
0,
|
|
656
|
+
0
|
|
657
|
+
]
|
|
658
|
+
}, color));
|
|
659
|
+
const JND = .02;
|
|
660
|
+
const EPSILON = 1e-4;
|
|
661
|
+
if (gamut === "srgb") return back(reduceChromaInSrgb(origin, lightness, chroma, hue));
|
|
662
|
+
let min = 0;
|
|
663
|
+
let max = chroma;
|
|
664
|
+
let minInGamut = true;
|
|
665
|
+
let clip = clipped(origin, gamut, componentsIn(origin, gamut));
|
|
666
|
+
if (deltaEOk(clip, origin) < JND) return back(clip);
|
|
667
|
+
while (max - min > EPSILON) {
|
|
668
|
+
const mid = (min + max) / 2;
|
|
669
|
+
const current = withAlpha({
|
|
670
|
+
colorSpace: "oklch",
|
|
671
|
+
components: [
|
|
672
|
+
lightness,
|
|
673
|
+
mid,
|
|
674
|
+
hue
|
|
675
|
+
]
|
|
676
|
+
}, origin);
|
|
677
|
+
const inGamutSpace = componentsIn(current, gamut);
|
|
678
|
+
if (minInGamut && within(inGamutSpace, 1e-6)) {
|
|
679
|
+
min = mid;
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
clip = clipped(current, gamut, inGamutSpace);
|
|
683
|
+
const e = deltaEOk(clip, current);
|
|
684
|
+
if (e < JND) {
|
|
685
|
+
if (JND - e < EPSILON) return back(clip);
|
|
686
|
+
minInGamut = false;
|
|
687
|
+
min = mid;
|
|
688
|
+
} else max = mid;
|
|
689
|
+
}
|
|
690
|
+
/* v8 ignore next */
|
|
691
|
+
return back(clip);
|
|
692
|
+
}
|
|
693
|
+
function withAlpha(c, source) {
|
|
694
|
+
if (source.alpha !== void 0) c.alpha = source.alpha;
|
|
695
|
+
return c;
|
|
696
|
+
}
|
|
697
|
+
let lmsToLinear;
|
|
698
|
+
let linearToLms;
|
|
699
|
+
const LOW = -1e-6 / 12.92;
|
|
700
|
+
const HIGH = ((1 + 1e-6 + .055) / 1.055) ** 2.4;
|
|
701
|
+
const encode = (n) => n === 0 || n === 1 ? n : srgbToGamma(n);
|
|
702
|
+
const clamp01 = (n) => Math.min(1, Math.max(0, n));
|
|
703
|
+
/**
|
|
704
|
+
* The CSS Color 4 section 13.2 search of `toGamut` for the `srgb` gamut, done in
|
|
705
|
+
* linear sRGB so the loop has no hub conversion, `**` or trigonometry. Clipping
|
|
706
|
+
* to 0 to 1 commutes with the monotone transfer curve, so it finds what the
|
|
707
|
+
* generic path finds, up to rounding. Returns the mapped color in `srgb`.
|
|
708
|
+
*/
|
|
709
|
+
function reduceChromaInSrgb(origin, lightness, chroma, hue) {
|
|
710
|
+
const m = lmsToLinear ??= product(xyzToSrgb, lmsToXyz);
|
|
711
|
+
const n = linearToLms ??= product(xyzToLms, srgbToXyz);
|
|
712
|
+
const o = oklabToLms;
|
|
713
|
+
const k = lmsToOklab;
|
|
714
|
+
const l = lightness;
|
|
715
|
+
const radians = (hue ?? 0) * Math.PI / 180;
|
|
716
|
+
const cos = Math.cos(radians);
|
|
717
|
+
const sin = Math.sin(radians);
|
|
718
|
+
let r = 0;
|
|
719
|
+
let g = 0;
|
|
720
|
+
let b = 0;
|
|
721
|
+
let inside = false;
|
|
722
|
+
/** Puts the candidate of chroma `c` in linear sRGB into r, g, b (unclipped), and says if it is within the gamut. */
|
|
723
|
+
const place = (c) => {
|
|
724
|
+
const a = c * cos;
|
|
725
|
+
const bb = c * sin;
|
|
726
|
+
const x = l + o[1] * a + o[2] * bb;
|
|
727
|
+
const y = l + o[4] * a + o[5] * bb;
|
|
728
|
+
const z = l + o[7] * a + o[8] * bb;
|
|
729
|
+
const x3 = x * x * x;
|
|
730
|
+
const y3 = y * y * y;
|
|
731
|
+
const z3 = z * z * z;
|
|
732
|
+
r = m[0] * x3 + m[1] * y3 + m[2] * z3;
|
|
733
|
+
g = m[3] * x3 + m[4] * y3 + m[5] * z3;
|
|
734
|
+
b = m[6] * x3 + m[7] * y3 + m[8] * z3;
|
|
735
|
+
inside = r >= LOW && r <= HIGH && g >= LOW && g <= HIGH && b >= LOW && b <= HIGH;
|
|
736
|
+
};
|
|
737
|
+
/** Clips r, g, b and returns its ΔEOK to the candidate of chroma `c`. */
|
|
738
|
+
const clipAndMeasure = (c) => {
|
|
739
|
+
r = clamp01(r);
|
|
740
|
+
g = clamp01(g);
|
|
741
|
+
b = clamp01(b);
|
|
742
|
+
const x = Math.cbrt(n[0] * r + n[1] * g + n[2] * b);
|
|
743
|
+
const y = Math.cbrt(n[3] * r + n[4] * g + n[5] * b);
|
|
744
|
+
const z = Math.cbrt(n[6] * r + n[7] * g + n[8] * b);
|
|
745
|
+
const dl = k[0] * x + k[1] * y + k[2] * z - l;
|
|
746
|
+
const da = k[3] * x + k[4] * y + k[5] * z - c * cos;
|
|
747
|
+
const db = k[6] * x + k[7] * y + k[8] * z - c * sin;
|
|
748
|
+
return Math.sqrt(dl * dl + da * da + db * db);
|
|
749
|
+
};
|
|
750
|
+
const JND = .02;
|
|
751
|
+
const EPSILON = 1e-4;
|
|
752
|
+
let min = 0;
|
|
753
|
+
let max = chroma;
|
|
754
|
+
let minInGamut = true;
|
|
755
|
+
place(chroma ?? 0);
|
|
756
|
+
let clip;
|
|
757
|
+
let e = clipAndMeasure(chroma ?? 0);
|
|
758
|
+
clip = [
|
|
759
|
+
r,
|
|
760
|
+
g,
|
|
761
|
+
b
|
|
762
|
+
];
|
|
763
|
+
if (e >= JND) while (max - min > EPSILON) {
|
|
764
|
+
const mid = (min + max) / 2;
|
|
765
|
+
place(mid);
|
|
766
|
+
if (minInGamut && inside) {
|
|
767
|
+
min = mid;
|
|
768
|
+
continue;
|
|
769
|
+
}
|
|
770
|
+
e = clipAndMeasure(mid);
|
|
771
|
+
clip = [
|
|
772
|
+
r,
|
|
773
|
+
g,
|
|
774
|
+
b
|
|
775
|
+
];
|
|
776
|
+
if (e < JND) {
|
|
777
|
+
if (JND - e < EPSILON) break;
|
|
778
|
+
minInGamut = false;
|
|
779
|
+
min = mid;
|
|
780
|
+
} else max = mid;
|
|
781
|
+
}
|
|
782
|
+
return withAlpha({
|
|
783
|
+
colorSpace: "srgb",
|
|
784
|
+
components: clip.map(encode)
|
|
785
|
+
}, origin);
|
|
786
|
+
}
|
|
787
|
+
// src/color/named.ts
|
|
788
|
+
const DATA = "aliceblue:f0f8ff,antiquewhite:faebd7,aqua:00ffff,aquamarine:7fffd4,azure:f0ffff,beige:f5f5dc,bisque:ffe4c4,black:000000,blanchedalmond:ffebcd,blue:0000ff,blueviolet:8a2be2,brown:a52a2a,burlywood:deb887,cadetblue:5f9ea0,chartreuse:7fff00,chocolate:d2691e,coral:ff7f50,cornflowerblue:6495ed,cornsilk:fff8dc,crimson:dc143c,cyan:00ffff,darkblue:00008b,darkcyan:008b8b,darkgoldenrod:b8860b,darkgray:a9a9a9,darkgreen:006400,darkgrey:a9a9a9,darkkhaki:bdb76b,darkmagenta:8b008b,darkolivegreen:556b2f,darkorange:ff8c00,darkorchid:9932cc,darkred:8b0000,darksalmon:e9967a,darkseagreen:8fbc8f,darkslateblue:483d8b,darkslategray:2f4f4f,darkslategrey:2f4f4f,darkturquoise:00ced1,darkviolet:9400d3,deeppink:ff1493,deepskyblue:00bfff,dimgray:696969,dimgrey:696969,dodgerblue:1e90ff,firebrick:b22222,floralwhite:fffaf0,forestgreen:228b22,fuchsia:ff00ff,gainsboro:dcdcdc,ghostwhite:f8f8ff,gold:ffd700,goldenrod:daa520,gray:808080,green:008000,greenyellow:adff2f,grey:808080,honeydew:f0fff0,hotpink:ff69b4,indianred:cd5c5c,indigo:4b0082,ivory:fffff0,khaki:f0e68c,lavender:e6e6fa,lavenderblush:fff0f5,lawngreen:7cfc00,lemonchiffon:fffacd,lightblue:add8e6,lightcoral:f08080,lightcyan:e0ffff,lightgoldenrodyellow:fafad2,lightgray:d3d3d3,lightgreen:90ee90,lightgrey:d3d3d3,lightpink:ffb6c1,lightsalmon:ffa07a,lightseagreen:20b2aa,lightskyblue:87cefa,lightslategray:778899,lightslategrey:778899,lightsteelblue:b0c4de,lightyellow:ffffe0,lime:00ff00,limegreen:32cd32,linen:faf0e6,magenta:ff00ff,maroon:800000,mediumaquamarine:66cdaa,mediumblue:0000cd,mediumorchid:ba55d3,mediumpurple:9370db,mediumseagreen:3cb371,mediumslateblue:7b68ee,mediumspringgreen:00fa9a,mediumturquoise:48d1cc,mediumvioletred:c71585,midnightblue:191970,mintcream:f5fffa,mistyrose:ffe4e1,moccasin:ffe4b5,navajowhite:ffdead,navy:000080,oldlace:fdf5e6,olive:808000,olivedrab:6b8e23,orange:ffa500,orangered:ff4500,orchid:da70d6,palegoldenrod:eee8aa,palegreen:98fb98,paleturquoise:afeeee,palevioletred:db7093,papayawhip:ffefd5,peachpuff:ffdab9,peru:cd853f,pink:ffc0cb,plum:dda0dd,powderblue:b0e0e6,purple:800080,rebeccapurple:663399,red:ff0000,rosybrown:bc8f8f,royalblue:4169e1,saddlebrown:8b4513,salmon:fa8072,sandybrown:f4a460,seagreen:2e8b57,seashell:fff5ee,sienna:a0522d,silver:c0c0c0,skyblue:87ceeb,slateblue:6a5acd,slategray:708090,slategrey:708090,snow:fffafa,springgreen:00ff7f,steelblue:4682b4,tan:d2b48c,teal:008080,thistle:d8bfd8,tomato:ff6347,turquoise:40e0d0,violet:ee82ee,wheat:f5deb3,white:ffffff,whitesmoke:f5f5f5,yellow:ffff00,yellowgreen:9acd32";
|
|
789
|
+
let table;
|
|
790
|
+
/** The 0xRRGGBB value of a CSS named color, or undefined. Built on first use. */
|
|
791
|
+
function namedColor(name) {
|
|
792
|
+
table ??= new Map(DATA.split(",").map((p) => [p.slice(0, p.indexOf(":")), Number.parseInt(p.slice(p.indexOf(":") + 1), 16)]));
|
|
793
|
+
return table.get(name);
|
|
794
|
+
}
|
|
795
|
+
// src/color/parse.ts
|
|
796
|
+
const NUMBER = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/;
|
|
797
|
+
const UNITS = {
|
|
798
|
+
__proto__: null,
|
|
799
|
+
"": 1,
|
|
800
|
+
deg: 1,
|
|
801
|
+
grad: .9,
|
|
802
|
+
rad: 180 / Math.PI,
|
|
803
|
+
turn: 360
|
|
804
|
+
};
|
|
805
|
+
function fail(input, what, token) {
|
|
806
|
+
throw new Error(`color-map: cannot parse "${input}": ${what}${token === void 0 ? "" : ` "${token}"`}`);
|
|
807
|
+
}
|
|
808
|
+
function channel(token, spec, input) {
|
|
809
|
+
if (token === "none") return null;
|
|
810
|
+
const m = NUMBER.exec(token);
|
|
811
|
+
if (!m) return fail(input, "invalid value", token);
|
|
812
|
+
const n = Number(m[0]);
|
|
813
|
+
const rest = token.slice(m[0].length);
|
|
814
|
+
let value;
|
|
815
|
+
if (spec.hue) {
|
|
816
|
+
const unit = UNITS[rest];
|
|
817
|
+
if (unit === void 0) return fail(input, "invalid angle", token);
|
|
818
|
+
return n * unit;
|
|
819
|
+
}
|
|
820
|
+
if (rest === "%") value = n * spec.pct / 100;
|
|
821
|
+
else if (rest === "") value = n / (spec.div ?? 1);
|
|
822
|
+
else return fail(input, "invalid value", token);
|
|
823
|
+
return Math.min(spec.max ?? Number.POSITIVE_INFINITY, Math.max(spec.min ?? Number.NEGATIVE_INFINITY, value));
|
|
824
|
+
}
|
|
825
|
+
const SRGB = {
|
|
826
|
+
pct: 1,
|
|
827
|
+
div: 255
|
|
828
|
+
};
|
|
829
|
+
const PCT100 = {
|
|
830
|
+
pct: 100,
|
|
831
|
+
min: 0
|
|
832
|
+
};
|
|
833
|
+
const UNIT = { pct: 1 };
|
|
834
|
+
const ALPHA = {
|
|
835
|
+
pct: 1,
|
|
836
|
+
min: 0,
|
|
837
|
+
max: 1
|
|
838
|
+
};
|
|
839
|
+
const HUE = {
|
|
840
|
+
pct: 0,
|
|
841
|
+
hue: true
|
|
842
|
+
};
|
|
843
|
+
const FUNCTIONS = {
|
|
844
|
+
__proto__: null,
|
|
845
|
+
rgb: {
|
|
846
|
+
space: "srgb",
|
|
847
|
+
channels: [
|
|
848
|
+
SRGB,
|
|
849
|
+
SRGB,
|
|
850
|
+
SRGB
|
|
851
|
+
]
|
|
852
|
+
},
|
|
853
|
+
hsl: {
|
|
854
|
+
space: "hsl",
|
|
855
|
+
channels: [
|
|
856
|
+
HUE,
|
|
857
|
+
PCT100,
|
|
858
|
+
PCT100
|
|
859
|
+
]
|
|
860
|
+
},
|
|
861
|
+
hwb: {
|
|
862
|
+
space: "hwb",
|
|
863
|
+
channels: [
|
|
864
|
+
HUE,
|
|
865
|
+
PCT100,
|
|
866
|
+
PCT100
|
|
867
|
+
]
|
|
868
|
+
},
|
|
869
|
+
lab: {
|
|
870
|
+
space: "lab",
|
|
871
|
+
channels: [
|
|
872
|
+
{
|
|
873
|
+
pct: 100,
|
|
874
|
+
min: 0,
|
|
875
|
+
max: 100
|
|
876
|
+
},
|
|
877
|
+
{ pct: 125 },
|
|
878
|
+
{ pct: 125 }
|
|
879
|
+
]
|
|
880
|
+
},
|
|
881
|
+
lch: {
|
|
882
|
+
space: "lch",
|
|
883
|
+
channels: [
|
|
884
|
+
{
|
|
885
|
+
pct: 100,
|
|
886
|
+
min: 0,
|
|
887
|
+
max: 100
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
pct: 150,
|
|
891
|
+
min: 0
|
|
892
|
+
},
|
|
893
|
+
HUE
|
|
894
|
+
]
|
|
895
|
+
},
|
|
896
|
+
oklab: {
|
|
897
|
+
space: "oklab",
|
|
898
|
+
channels: [
|
|
899
|
+
{
|
|
900
|
+
pct: 1,
|
|
901
|
+
min: 0,
|
|
902
|
+
max: 1
|
|
903
|
+
},
|
|
904
|
+
{ pct: .4 },
|
|
905
|
+
{ pct: .4 }
|
|
906
|
+
]
|
|
907
|
+
},
|
|
908
|
+
oklch: {
|
|
909
|
+
space: "oklch",
|
|
910
|
+
channels: [
|
|
911
|
+
{
|
|
912
|
+
pct: 1,
|
|
913
|
+
min: 0,
|
|
914
|
+
max: 1
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
pct: .4,
|
|
918
|
+
min: 0
|
|
919
|
+
},
|
|
920
|
+
HUE
|
|
921
|
+
]
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
/** The spaces `color()` names, by the name it uses: their own, and `xyz` for `xyz-d65`. */
|
|
925
|
+
const COLOR_SPACES = {
|
|
926
|
+
__proto__: null,
|
|
927
|
+
xyz: "xyz-d65"
|
|
928
|
+
};
|
|
929
|
+
for (const id of [
|
|
930
|
+
"srgb",
|
|
931
|
+
"srgb-linear",
|
|
932
|
+
"display-p3",
|
|
933
|
+
"display-p3-linear",
|
|
934
|
+
"a98-rgb",
|
|
935
|
+
"prophoto-rgb",
|
|
936
|
+
"rec2020",
|
|
937
|
+
"xyz-d50",
|
|
938
|
+
"xyz-d65"
|
|
939
|
+
]) COLOR_SPACES[id] = id;
|
|
940
|
+
/** `currentcolor` and the CSS Color 4 system colors (canvas, canvastext, linktext, buttonface, ...). */
|
|
941
|
+
const VALUES_NEEDING_RESOLVE = /^(?:currentcolor|(?:canvas|field|highlight|selecteditem|mark|accentcolor)(?:text)?|(?:link|visited|active|button|gray)text|button(?:face|border))$/;
|
|
942
|
+
function hex(input) {
|
|
943
|
+
const digits = input.slice(1);
|
|
944
|
+
if (!/^(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/.test(digits)) return fail(input, "invalid hex color");
|
|
945
|
+
const full = digits.length < 5 ? [...digits].map((d) => d + d).join("") : digits;
|
|
946
|
+
const byte = (i) => Number.parseInt(full.slice(i * 2, i * 2 + 2), 16) / 255;
|
|
947
|
+
const color = {
|
|
948
|
+
colorSpace: "srgb",
|
|
949
|
+
components: [
|
|
950
|
+
byte(0),
|
|
951
|
+
byte(1),
|
|
952
|
+
byte(2)
|
|
953
|
+
]
|
|
954
|
+
};
|
|
955
|
+
if (full.length === 8) color.alpha = byte(3);
|
|
956
|
+
return color;
|
|
957
|
+
}
|
|
958
|
+
const ALIASES = {
|
|
959
|
+
__proto__: null,
|
|
960
|
+
rgba: "rgb",
|
|
961
|
+
hsla: "hsl"
|
|
962
|
+
};
|
|
963
|
+
function functional(rawName, body, input) {
|
|
964
|
+
const name = ALIASES[rawName] ?? rawName;
|
|
965
|
+
const [main, alphaToken, ...extra] = body.split("/").map((s) => s.trim());
|
|
966
|
+
if (extra.length > 0) return fail(input, "more than one \"/\"");
|
|
967
|
+
const legacy = main.includes(",");
|
|
968
|
+
const tokens = (legacy ? main.split(",") : main.split(/\s+/)).map((s) => s.trim()).filter(Boolean);
|
|
969
|
+
let alpha = alphaToken;
|
|
970
|
+
if (legacy) {
|
|
971
|
+
if (name !== "rgb" && name !== "hsl") return fail(input, "the comma syntax is only for rgb() and hsl()");
|
|
972
|
+
if (alpha !== void 0) return fail(input, "cannot mix \",\" and \"/\"");
|
|
973
|
+
if (tokens.length === 4) alpha = tokens.pop();
|
|
974
|
+
if (tokens.includes("none")) return fail(input, "\"none\" is not allowed in the comma syntax");
|
|
975
|
+
}
|
|
976
|
+
let space;
|
|
977
|
+
let channels;
|
|
978
|
+
if (name === "color") {
|
|
979
|
+
const id = COLOR_SPACES[tokens.shift() ?? ""];
|
|
980
|
+
if (!id) return fail(input, "unknown color space", main.split(/\s+/)[0]);
|
|
981
|
+
space = id;
|
|
982
|
+
channels = [
|
|
983
|
+
UNIT,
|
|
984
|
+
UNIT,
|
|
985
|
+
UNIT
|
|
986
|
+
];
|
|
987
|
+
} else {
|
|
988
|
+
const fn = FUNCTIONS[name];
|
|
989
|
+
if (!fn) return fail(input, "unknown function", rawName);
|
|
990
|
+
({space, channels} = fn);
|
|
991
|
+
}
|
|
992
|
+
if (tokens.length !== 3) return fail(input, `expected 3 components, got ${tokens.length}`);
|
|
993
|
+
if (legacy) {
|
|
994
|
+
const percents = tokens.map((t) => t.endsWith("%"));
|
|
995
|
+
if (!(space === "hsl" ? !percents[0] && percents[1] && percents[2] : percents.every((p) => p === percents[0]))) return fail(input, "mixed numbers and percentages", tokens.join(", "));
|
|
996
|
+
}
|
|
997
|
+
const color = {
|
|
998
|
+
colorSpace: space,
|
|
999
|
+
components: tokens.map((t, i) => channel(t, channels[i], input))
|
|
1000
|
+
};
|
|
1001
|
+
if (alpha !== void 0) color.alpha = channel(alpha, ALPHA, input);
|
|
1002
|
+
return color;
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Parses a CSS Color 4 color: hex, named colors, `transparent`, `rgb()`,
|
|
1006
|
+
* `hsl()`, `hwb()`, `lab()`, `lch()`, `oklab()`, `oklch()` and `color()`.
|
|
1007
|
+
* `none` becomes `null`. Values that need a context (`currentcolor`, system
|
|
1008
|
+
* colors) throw, because nothing here can resolve them.
|
|
1009
|
+
*/
|
|
1010
|
+
function parse(input) {
|
|
1011
|
+
const text = input.trim().toLowerCase();
|
|
1012
|
+
return scan(text) ?? parseGeneric(input, text);
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* The regex-based parser: every accepted form, and every error message. `parse`
|
|
1016
|
+
* tries {@link scan} first, which takes only the plain valid forms and leaves
|
|
1017
|
+
* the rest, including every error, to this.
|
|
1018
|
+
*/
|
|
1019
|
+
function parseGeneric(input, text) {
|
|
1020
|
+
if (text.startsWith("#")) return hex(text);
|
|
1021
|
+
const fn = /^([a-z]+)\((.*)\)$/s.exec(text);
|
|
1022
|
+
if (fn) return functional(fn[1], fn[2], input);
|
|
1023
|
+
if (text === "transparent") return {
|
|
1024
|
+
colorSpace: "srgb",
|
|
1025
|
+
components: [
|
|
1026
|
+
0,
|
|
1027
|
+
0,
|
|
1028
|
+
0
|
|
1029
|
+
],
|
|
1030
|
+
alpha: 0
|
|
1031
|
+
};
|
|
1032
|
+
const named = namedColor(text);
|
|
1033
|
+
if (named !== void 0) return {
|
|
1034
|
+
colorSpace: "srgb",
|
|
1035
|
+
components: [
|
|
1036
|
+
(named >> 16) / 255,
|
|
1037
|
+
(named >> 8 & 255) / 255,
|
|
1038
|
+
(named & 255) / 255
|
|
1039
|
+
]
|
|
1040
|
+
};
|
|
1041
|
+
if (VALUES_NEEDING_RESOLVE.test(text)) return fail(input, "needs a context to resolve", text);
|
|
1042
|
+
return fail(input, "not a color");
|
|
1043
|
+
}
|
|
1044
|
+
/** A color as given, or parsed with {@link parse} when it is a string. */
|
|
1045
|
+
const toColor = (c) => typeof c === "string" ? parse(c) : c;
|
|
1046
|
+
const isSpace = (c) => c === 32 || c === 9 || c === 10 || c === 13 || c === 12;
|
|
1047
|
+
const isDigit = (c) => c >= 48 && c <= 57;
|
|
1048
|
+
const hexValue = (c) => c >= 48 && c <= 57 ? c - 48 : c >= 97 && c <= 102 ? c - 87 : -1;
|
|
1049
|
+
let at = 0;
|
|
1050
|
+
let percent = false;
|
|
1051
|
+
function scanHex(text) {
|
|
1052
|
+
const len = text.length;
|
|
1053
|
+
if (len !== 4 && len !== 5 && len !== 7 && len !== 9) return void 0;
|
|
1054
|
+
const short = len < 6;
|
|
1055
|
+
const count = short ? len - 1 : (len - 1) / 2;
|
|
1056
|
+
const bytes = [];
|
|
1057
|
+
for (let i = 0; i < count; i++) {
|
|
1058
|
+
let value;
|
|
1059
|
+
if (short) {
|
|
1060
|
+
const d = hexValue(text.charCodeAt(1 + i));
|
|
1061
|
+
value = d * 17;
|
|
1062
|
+
if (d < 0) return void 0;
|
|
1063
|
+
} else {
|
|
1064
|
+
const hi = hexValue(text.charCodeAt(1 + i * 2));
|
|
1065
|
+
const lo = hexValue(text.charCodeAt(2 + i * 2));
|
|
1066
|
+
if (hi < 0 || lo < 0) return void 0;
|
|
1067
|
+
value = hi * 16 + lo;
|
|
1068
|
+
}
|
|
1069
|
+
bytes.push(value / 255);
|
|
1070
|
+
}
|
|
1071
|
+
const color = {
|
|
1072
|
+
colorSpace: "srgb",
|
|
1073
|
+
components: [
|
|
1074
|
+
bytes[0],
|
|
1075
|
+
bytes[1],
|
|
1076
|
+
bytes[2]
|
|
1077
|
+
]
|
|
1078
|
+
};
|
|
1079
|
+
if (count === 4) color.alpha = bytes[3];
|
|
1080
|
+
return color;
|
|
1081
|
+
}
|
|
1082
|
+
/** Skips whitespace from `at` up to `end`. */
|
|
1083
|
+
function skip(text, end) {
|
|
1084
|
+
while (at < end && isSpace(text.charCodeAt(at))) at++;
|
|
1085
|
+
}
|
|
1086
|
+
/** The end of the token that starts at `at`: it runs to whitespace, a comma, a slash or `end`. */
|
|
1087
|
+
function tokenEnd(text, end) {
|
|
1088
|
+
let j = at;
|
|
1089
|
+
while (j < end) {
|
|
1090
|
+
const c = text.charCodeAt(j);
|
|
1091
|
+
if (isSpace(c) || c === 44 || c === 47) break;
|
|
1092
|
+
j++;
|
|
1093
|
+
}
|
|
1094
|
+
return j;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Reads the token at `at` as {@link channel} would, or returns `undefined` when
|
|
1098
|
+
* it is anything but a plain valid one. Leaves `at` after the token.
|
|
1099
|
+
*/
|
|
1100
|
+
function scanChannel(text, end, spec) {
|
|
1101
|
+
const s = at;
|
|
1102
|
+
const e = tokenEnd(text, end);
|
|
1103
|
+
at = e;
|
|
1104
|
+
if (e === s) return void 0;
|
|
1105
|
+
if (e - s === 4 && text.startsWith("none", s)) return null;
|
|
1106
|
+
let j = s;
|
|
1107
|
+
let c = text.charCodeAt(j);
|
|
1108
|
+
if (c === 43 || c === 45) c = text.charCodeAt(++j);
|
|
1109
|
+
let digits = 0;
|
|
1110
|
+
while (isDigit(c)) {
|
|
1111
|
+
c = text.charCodeAt(++j);
|
|
1112
|
+
digits++;
|
|
1113
|
+
}
|
|
1114
|
+
if (c === 46) {
|
|
1115
|
+
c = text.charCodeAt(++j);
|
|
1116
|
+
while (isDigit(c)) {
|
|
1117
|
+
c = text.charCodeAt(++j);
|
|
1118
|
+
digits++;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
if (digits === 0) return void 0;
|
|
1122
|
+
if (c === 101) {
|
|
1123
|
+
let k = j + 1;
|
|
1124
|
+
let x = text.charCodeAt(k);
|
|
1125
|
+
if (x === 43 || x === 45) x = text.charCodeAt(++k);
|
|
1126
|
+
if (isDigit(x)) {
|
|
1127
|
+
while (isDigit(text.charCodeAt(k))) k++;
|
|
1128
|
+
j = k;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
const n = Number(text.slice(s, j));
|
|
1132
|
+
if (spec.hue) {
|
|
1133
|
+
const unit = j === e ? 1 : UNITS[text.slice(j, e)];
|
|
1134
|
+
return unit === void 0 ? void 0 : n * unit;
|
|
1135
|
+
}
|
|
1136
|
+
let value;
|
|
1137
|
+
if (j === e) value = n / (spec.div ?? 1);
|
|
1138
|
+
else if (e - j === 1 && text.charCodeAt(j) === 37) {
|
|
1139
|
+
percent = true;
|
|
1140
|
+
value = n * spec.pct / 100;
|
|
1141
|
+
} else return void 0;
|
|
1142
|
+
return Math.min(spec.max ?? Number.POSITIVE_INFINITY, Math.max(spec.min ?? Number.NEGATIVE_INFINITY, value));
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Parses the plain valid forms (hex, and the comma or space forms of the
|
|
1146
|
+
* functions) by char code, with no regex, split or per-token array. Anything
|
|
1147
|
+
* else returns `undefined`, so that {@link parseGeneric} handles it and says
|
|
1148
|
+
* why it is wrong.
|
|
1149
|
+
*/
|
|
1150
|
+
function scan(text) {
|
|
1151
|
+
if (text.charCodeAt(0) === 35) return scanHex(text);
|
|
1152
|
+
const end = text.length - 1;
|
|
1153
|
+
if (text.charCodeAt(end) !== 41) return void 0;
|
|
1154
|
+
let open = 0;
|
|
1155
|
+
while (open < end) {
|
|
1156
|
+
const c = text.charCodeAt(open);
|
|
1157
|
+
if (c < 97 || c > 122) break;
|
|
1158
|
+
open++;
|
|
1159
|
+
}
|
|
1160
|
+
if (open === 0 || text.charCodeAt(open) !== 40) return void 0;
|
|
1161
|
+
const rawName = text.slice(0, open);
|
|
1162
|
+
const name = ALIASES[rawName] ?? rawName;
|
|
1163
|
+
let space;
|
|
1164
|
+
let channels;
|
|
1165
|
+
at = open + 1;
|
|
1166
|
+
skip(text, end);
|
|
1167
|
+
if (name === "color") {
|
|
1168
|
+
const s = at;
|
|
1169
|
+
while (at < end && !isSpace(text.charCodeAt(at))) at++;
|
|
1170
|
+
const id = COLOR_SPACES[text.slice(s, at)];
|
|
1171
|
+
if (!id) return void 0;
|
|
1172
|
+
space = id;
|
|
1173
|
+
channels = [
|
|
1174
|
+
UNIT,
|
|
1175
|
+
UNIT,
|
|
1176
|
+
UNIT
|
|
1177
|
+
];
|
|
1178
|
+
skip(text, end);
|
|
1179
|
+
} else {
|
|
1180
|
+
const fn = FUNCTIONS[name];
|
|
1181
|
+
if (!fn) return void 0;
|
|
1182
|
+
({space, channels} = fn);
|
|
1183
|
+
}
|
|
1184
|
+
percent = false;
|
|
1185
|
+
const c0 = scanChannel(text, end, channels[0]);
|
|
1186
|
+
if (c0 === void 0) return void 0;
|
|
1187
|
+
const p0 = percent;
|
|
1188
|
+
skip(text, end);
|
|
1189
|
+
const comma = text.charCodeAt(at) === 44;
|
|
1190
|
+
if (comma && name !== "rgb" && name !== "hsl") return void 0;
|
|
1191
|
+
let alpha;
|
|
1192
|
+
let c1;
|
|
1193
|
+
let c2;
|
|
1194
|
+
let p1 = false;
|
|
1195
|
+
let p2 = false;
|
|
1196
|
+
if (comma) {
|
|
1197
|
+
at++;
|
|
1198
|
+
skip(text, end);
|
|
1199
|
+
percent = false;
|
|
1200
|
+
c1 = scanChannel(text, end, channels[1]);
|
|
1201
|
+
p1 = percent;
|
|
1202
|
+
skip(text, end);
|
|
1203
|
+
if (text.charCodeAt(at++) !== 44) return void 0;
|
|
1204
|
+
skip(text, end);
|
|
1205
|
+
percent = false;
|
|
1206
|
+
c2 = scanChannel(text, end, channels[2]);
|
|
1207
|
+
p2 = percent;
|
|
1208
|
+
skip(text, end);
|
|
1209
|
+
if (c0 === null || c1 === void 0 || c1 === null || c2 === void 0 || c2 === null) return void 0;
|
|
1210
|
+
if (!(space === "hsl" ? !p0 && p1 && p2 : p0 === p1 && p1 === p2)) return void 0;
|
|
1211
|
+
if (at < end) {
|
|
1212
|
+
if (text.charCodeAt(at++) !== 44) return void 0;
|
|
1213
|
+
skip(text, end);
|
|
1214
|
+
alpha = scanChannel(text, end, ALPHA);
|
|
1215
|
+
if (alpha === void 0 || alpha === null) return void 0;
|
|
1216
|
+
skip(text, end);
|
|
1217
|
+
}
|
|
1218
|
+
} else {
|
|
1219
|
+
c1 = scanChannel(text, end, channels[1]);
|
|
1220
|
+
skip(text, end);
|
|
1221
|
+
c2 = scanChannel(text, end, channels[2]);
|
|
1222
|
+
skip(text, end);
|
|
1223
|
+
if (at < end) {
|
|
1224
|
+
if (text.charCodeAt(at++) !== 47) return void 0;
|
|
1225
|
+
skip(text, end);
|
|
1226
|
+
alpha = scanChannel(text, end, ALPHA);
|
|
1227
|
+
if (alpha === void 0) return void 0;
|
|
1228
|
+
skip(text, end);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
if (at !== end || c1 === void 0 || c2 === void 0) return void 0;
|
|
1232
|
+
const color = {
|
|
1233
|
+
colorSpace: space,
|
|
1234
|
+
components: [
|
|
1235
|
+
c0,
|
|
1236
|
+
c1,
|
|
1237
|
+
c2
|
|
1238
|
+
]
|
|
1239
|
+
};
|
|
1240
|
+
if (alpha !== void 0) color.alpha = alpha;
|
|
1241
|
+
return color;
|
|
1242
|
+
}
|
|
1243
|
+
Object.defineProperty(exports, "ALPHA", {
|
|
1244
|
+
enumerable: true,
|
|
1245
|
+
get: function() {
|
|
1246
|
+
return ALPHA;
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
Object.defineProperty(exports, "COLOR_SPACES", {
|
|
1250
|
+
enumerable: true,
|
|
1251
|
+
get: function() {
|
|
1252
|
+
return COLOR_SPACES;
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
Object.defineProperty(exports, "FUNCTIONS", {
|
|
1256
|
+
enumerable: true,
|
|
1257
|
+
get: function() {
|
|
1258
|
+
return FUNCTIONS;
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
Object.defineProperty(exports, "UNIT", {
|
|
1262
|
+
enumerable: true,
|
|
1263
|
+
get: function() {
|
|
1264
|
+
return UNIT;
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
Object.defineProperty(exports, "UNITS", {
|
|
1268
|
+
enumerable: true,
|
|
1269
|
+
get: function() {
|
|
1270
|
+
return UNITS;
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
Object.defineProperty(exports, "VALUES_NEEDING_RESOLVE", {
|
|
1274
|
+
enumerable: true,
|
|
1275
|
+
get: function() {
|
|
1276
|
+
return VALUES_NEEDING_RESOLVE;
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1279
|
+
Object.defineProperty(exports, "a98Rgb", {
|
|
1280
|
+
enumerable: true,
|
|
1281
|
+
get: function() {
|
|
1282
|
+
return a98Rgb;
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
Object.defineProperty(exports, "channel", {
|
|
1286
|
+
enumerable: true,
|
|
1287
|
+
get: function() {
|
|
1288
|
+
return channel;
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
Object.defineProperty(exports, "checkMode", {
|
|
1292
|
+
enumerable: true,
|
|
1293
|
+
get: function() {
|
|
1294
|
+
return checkMode;
|
|
1295
|
+
}
|
|
1296
|
+
});
|
|
1297
|
+
Object.defineProperty(exports, "componentsIn", {
|
|
1298
|
+
enumerable: true,
|
|
1299
|
+
get: function() {
|
|
1300
|
+
return componentsIn;
|
|
1301
|
+
}
|
|
1302
|
+
});
|
|
1303
|
+
Object.defineProperty(exports, "componentsOver", {
|
|
1304
|
+
enumerable: true,
|
|
1305
|
+
get: function() {
|
|
1306
|
+
return componentsOver;
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
Object.defineProperty(exports, "convert", {
|
|
1310
|
+
enumerable: true,
|
|
1311
|
+
get: function() {
|
|
1312
|
+
return convert;
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
Object.defineProperty(exports, "convertComponents", {
|
|
1316
|
+
enumerable: true,
|
|
1317
|
+
get: function() {
|
|
1318
|
+
return convertComponents;
|
|
1319
|
+
}
|
|
1320
|
+
});
|
|
1321
|
+
Object.defineProperty(exports, "convertWith", {
|
|
1322
|
+
enumerable: true,
|
|
1323
|
+
get: function() {
|
|
1324
|
+
return convertWith;
|
|
1325
|
+
}
|
|
1326
|
+
});
|
|
1327
|
+
Object.defineProperty(exports, "createConverter", {
|
|
1328
|
+
enumerable: true,
|
|
1329
|
+
get: function() {
|
|
1330
|
+
return createConverter;
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
Object.defineProperty(exports, "createDeltaEOk", {
|
|
1334
|
+
enumerable: true,
|
|
1335
|
+
get: function() {
|
|
1336
|
+
return createDeltaEOk;
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
Object.defineProperty(exports, "createEquals", {
|
|
1340
|
+
enumerable: true,
|
|
1341
|
+
get: function() {
|
|
1342
|
+
return createEquals;
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
Object.defineProperty(exports, "createInGamut", {
|
|
1346
|
+
enumerable: true,
|
|
1347
|
+
get: function() {
|
|
1348
|
+
return createInGamut;
|
|
1349
|
+
}
|
|
1350
|
+
});
|
|
1351
|
+
Object.defineProperty(exports, "createToGamut", {
|
|
1352
|
+
enumerable: true,
|
|
1353
|
+
get: function() {
|
|
1354
|
+
return createToGamut;
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
Object.defineProperty(exports, "deltaEOk", {
|
|
1358
|
+
enumerable: true,
|
|
1359
|
+
get: function() {
|
|
1360
|
+
return deltaEOk;
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
Object.defineProperty(exports, "displayP3", {
|
|
1364
|
+
enumerable: true,
|
|
1365
|
+
get: function() {
|
|
1366
|
+
return displayP3;
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
Object.defineProperty(exports, "displayP3Linear", {
|
|
1370
|
+
enumerable: true,
|
|
1371
|
+
get: function() {
|
|
1372
|
+
return displayP3Linear;
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
Object.defineProperty(exports, "equals", {
|
|
1376
|
+
enumerable: true,
|
|
1377
|
+
get: function() {
|
|
1378
|
+
return equals;
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
Object.defineProperty(exports, "fail", {
|
|
1382
|
+
enumerable: true,
|
|
1383
|
+
get: function() {
|
|
1384
|
+
return fail;
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1387
|
+
Object.defineProperty(exports, "hsl", {
|
|
1388
|
+
enumerable: true,
|
|
1389
|
+
get: function() {
|
|
1390
|
+
return hsl;
|
|
1391
|
+
}
|
|
1392
|
+
});
|
|
1393
|
+
Object.defineProperty(exports, "hwb", {
|
|
1394
|
+
enumerable: true,
|
|
1395
|
+
get: function() {
|
|
1396
|
+
return hwb;
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1399
|
+
Object.defineProperty(exports, "inGamut", {
|
|
1400
|
+
enumerable: true,
|
|
1401
|
+
get: function() {
|
|
1402
|
+
return inGamut;
|
|
1403
|
+
}
|
|
1404
|
+
});
|
|
1405
|
+
Object.defineProperty(exports, "lab", {
|
|
1406
|
+
enumerable: true,
|
|
1407
|
+
get: function() {
|
|
1408
|
+
return lab;
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
Object.defineProperty(exports, "lch", {
|
|
1412
|
+
enumerable: true,
|
|
1413
|
+
get: function() {
|
|
1414
|
+
return lch;
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
Object.defineProperty(exports, "normalizeHue", {
|
|
1418
|
+
enumerable: true,
|
|
1419
|
+
get: function() {
|
|
1420
|
+
return normalizeHue;
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1423
|
+
Object.defineProperty(exports, "oklab", {
|
|
1424
|
+
enumerable: true,
|
|
1425
|
+
get: function() {
|
|
1426
|
+
return oklab;
|
|
1427
|
+
}
|
|
1428
|
+
});
|
|
1429
|
+
Object.defineProperty(exports, "oklch", {
|
|
1430
|
+
enumerable: true,
|
|
1431
|
+
get: function() {
|
|
1432
|
+
return oklch;
|
|
1433
|
+
}
|
|
1434
|
+
});
|
|
1435
|
+
Object.defineProperty(exports, "parse", {
|
|
1436
|
+
enumerable: true,
|
|
1437
|
+
get: function() {
|
|
1438
|
+
return parse;
|
|
1439
|
+
}
|
|
1440
|
+
});
|
|
1441
|
+
Object.defineProperty(exports, "prophotoRgb", {
|
|
1442
|
+
enumerable: true,
|
|
1443
|
+
get: function() {
|
|
1444
|
+
return prophotoRgb;
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
Object.defineProperty(exports, "rec2020", {
|
|
1448
|
+
enumerable: true,
|
|
1449
|
+
get: function() {
|
|
1450
|
+
return rec2020;
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
Object.defineProperty(exports, "spaces", {
|
|
1454
|
+
enumerable: true,
|
|
1455
|
+
get: function() {
|
|
1456
|
+
return spaces;
|
|
1457
|
+
}
|
|
1458
|
+
});
|
|
1459
|
+
Object.defineProperty(exports, "srgb", {
|
|
1460
|
+
enumerable: true,
|
|
1461
|
+
get: function() {
|
|
1462
|
+
return srgb;
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
Object.defineProperty(exports, "srgbLinear", {
|
|
1466
|
+
enumerable: true,
|
|
1467
|
+
get: function() {
|
|
1468
|
+
return srgbLinear;
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1471
|
+
Object.defineProperty(exports, "toColor", {
|
|
1472
|
+
enumerable: true,
|
|
1473
|
+
get: function() {
|
|
1474
|
+
return toColor;
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
Object.defineProperty(exports, "toGamut", {
|
|
1478
|
+
enumerable: true,
|
|
1479
|
+
get: function() {
|
|
1480
|
+
return toGamut;
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
Object.defineProperty(exports, "toGamutWith", {
|
|
1484
|
+
enumerable: true,
|
|
1485
|
+
get: function() {
|
|
1486
|
+
return toGamutWith;
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
Object.defineProperty(exports, "unknownName", {
|
|
1490
|
+
enumerable: true,
|
|
1491
|
+
get: function() {
|
|
1492
|
+
return unknownName;
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1495
|
+
Object.defineProperty(exports, "xyzD50", {
|
|
1496
|
+
enumerable: true,
|
|
1497
|
+
get: function() {
|
|
1498
|
+
return xyzD50;
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
Object.defineProperty(exports, "xyzD65", {
|
|
1502
|
+
enumerable: true,
|
|
1503
|
+
get: function() {
|
|
1504
|
+
return xyzD65;
|
|
1505
|
+
}
|
|
1506
|
+
});
|
|
1507
|
+
|
|
1508
|
+
//# sourceMappingURL=parse-8mt2OMKf.js.map
|