chroma-panel 0.1.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/LICENSE +44 -0
- package/README.md +119 -0
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/a11y/contrast.cjs +107 -0
- package/dist/a11y/contrast.d.cts +34 -0
- package/dist/a11y/contrast.d.ts +34 -0
- package/dist/a11y/contrast.js +101 -0
- package/dist/color/convert.cjs +162 -0
- package/dist/color/convert.d.cts +16 -0
- package/dist/color/convert.d.ts +16 -0
- package/dist/color/convert.js +153 -0
- package/dist/color/parse.cjs +153 -0
- package/dist/color/parse.d.cts +7 -0
- package/dist/color/parse.d.ts +7 -0
- package/dist/color/parse.js +151 -0
- package/dist/color/serialize.cjs +79 -0
- package/dist/color/serialize.d.cts +11 -0
- package/dist/color/serialize.d.ts +11 -0
- package/dist/color/serialize.js +73 -0
- package/dist/color/sticky.cjs +20 -0
- package/dist/color/sticky.d.cts +6 -0
- package/dist/color/sticky.d.ts +6 -0
- package/dist/color/sticky.js +19 -0
- package/dist/color/types.d.cts +43 -0
- package/dist/color/types.d.ts +43 -0
- package/dist/components/ChromaPanel.cjs +254 -0
- package/dist/components/ChromaPanel.d.cts +47 -0
- package/dist/components/ChromaPanel.d.ts +47 -0
- package/dist/components/ChromaPanel.js +251 -0
- package/dist/components/ColorInput.cjs +128 -0
- package/dist/components/ColorInput.d.cts +19 -0
- package/dist/components/ColorInput.d.ts +19 -0
- package/dist/components/ColorInput.js +127 -0
- package/dist/components/ModeToolbar.cjs +33 -0
- package/dist/components/ModeToolbar.d.cts +10 -0
- package/dist/components/ModeToolbar.d.ts +10 -0
- package/dist/components/ModeToolbar.js +32 -0
- package/dist/components/PanelFooter.cjs +82 -0
- package/dist/components/PanelFooter.d.cts +5 -0
- package/dist/components/PanelFooter.d.ts +5 -0
- package/dist/components/PanelFooter.js +80 -0
- package/dist/components/Popover.cjs +154 -0
- package/dist/components/Popover.d.cts +13 -0
- package/dist/components/Popover.d.ts +13 -0
- package/dist/components/Popover.js +153 -0
- package/dist/contrast.cjs +10 -0
- package/dist/contrast.d.cts +2 -0
- package/dist/contrast.d.ts +2 -0
- package/dist/contrast.js +2 -0
- package/dist/core/context.cjs +30 -0
- package/dist/core/context.d.cts +43 -0
- package/dist/core/context.d.ts +43 -0
- package/dist/core/context.js +26 -0
- package/dist/core/dev.cjs +11 -0
- package/dist/core/dev.js +11 -0
- package/dist/core/store.cjs +43 -0
- package/dist/core/store.d.cts +17 -0
- package/dist/core/store.d.ts +17 -0
- package/dist/core/store.js +44 -0
- package/dist/core/styleInjector.cjs +38 -0
- package/dist/core/styleInjector.d.cts +4 -0
- package/dist/core/styleInjector.d.ts +4 -0
- package/dist/core/styleInjector.js +38 -0
- package/dist/core/useColorStore.cjs +43 -0
- package/dist/core/useColorStore.d.cts +6 -0
- package/dist/core/useColorStore.d.ts +6 -0
- package/dist/core/useColorStore.js +41 -0
- package/dist/core/useFormControl.cjs +87 -0
- package/dist/core/useFormControl.js +82 -0
- package/dist/core/useMediaQuery.cjs +48 -0
- package/dist/core/useMediaQuery.js +46 -0
- package/dist/core/usePointerDrag.cjs +177 -0
- package/dist/core/usePointerDrag.d.cts +35 -0
- package/dist/core/usePointerDrag.d.ts +35 -0
- package/dist/core/usePointerDrag.js +175 -0
- package/dist/core/useScrollFade.cjs +44 -0
- package/dist/core/useScrollFade.js +43 -0
- package/dist/core.cjs +33 -0
- package/dist/core.d.cts +7 -0
- package/dist/core.d.ts +7 -0
- package/dist/core.js +6 -0
- package/dist/data/defaults.cjs +123 -0
- package/dist/data/defaults.d.cts +6 -0
- package/dist/data/defaults.d.ts +6 -0
- package/dist/data/defaults.js +122 -0
- package/dist/data/namedColors.cjs +11 -0
- package/dist/data/namedColors.d.cts +3 -0
- package/dist/data/namedColors.d.ts +3 -0
- package/dist/data/namedColors.js +12 -0
- package/dist/image/extract.cjs +98 -0
- package/dist/image/extract.d.cts +16 -0
- package/dist/image/extract.d.ts +16 -0
- package/dist/image/extract.js +99 -0
- package/dist/image/mmcq.cjs +182 -0
- package/dist/image/mmcq.d.cts +8 -0
- package/dist/image/mmcq.d.ts +8 -0
- package/dist/image/mmcq.js +183 -0
- package/dist/image-worker.js +202 -0
- package/dist/image.cjs +12 -0
- package/dist/image.d.cts +4 -0
- package/dist/image.d.ts +4 -0
- package/dist/image.js +9 -0
- package/dist/index.cjs +119 -0
- package/dist/index.d.cts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +44 -0
- package/dist/modes/gradients.cjs +48 -0
- package/dist/modes/gradients.js +43 -0
- package/dist/modes/image/index.cjs +193 -0
- package/dist/modes/image/index.d.cts +10 -0
- package/dist/modes/image/index.d.ts +10 -0
- package/dist/modes/image/index.js +191 -0
- package/dist/modes/palettes/index.cjs +76 -0
- package/dist/modes/palettes/index.d.cts +6 -0
- package/dist/modes/palettes/index.d.ts +6 -0
- package/dist/modes/palettes/index.js +74 -0
- package/dist/modes/pencils/index.cjs +36 -0
- package/dist/modes/pencils/index.d.cts +6 -0
- package/dist/modes/pencils/index.d.ts +6 -0
- package/dist/modes/pencils/index.js +34 -0
- package/dist/modes/registry.cjs +26 -0
- package/dist/modes/registry.d.cts +13 -0
- package/dist/modes/registry.d.ts +13 -0
- package/dist/modes/registry.js +25 -0
- package/dist/modes/sliders/index.cjs +300 -0
- package/dist/modes/sliders/index.d.cts +6 -0
- package/dist/modes/sliders/index.d.ts +6 -0
- package/dist/modes/sliders/index.js +298 -0
- package/dist/modes/wheel/index.cjs +62 -0
- package/dist/modes/wheel/index.d.cts +6 -0
- package/dist/modes/wheel/index.d.ts +6 -0
- package/dist/modes/wheel/index.js +60 -0
- package/dist/named-colors.cjs +3 -0
- package/dist/named-colors.d.cts +2 -0
- package/dist/named-colors.d.ts +2 -0
- package/dist/named-colors.js +2 -0
- package/dist/palettes.cjs +8 -0
- package/dist/palettes.d.cts +2 -0
- package/dist/palettes.d.ts +2 -0
- package/dist/palettes.js +7 -0
- package/dist/panel.cjs +80 -0
- package/dist/panel.d.cts +27 -0
- package/dist/panel.d.ts +27 -0
- package/dist/panel.js +27 -0
- package/dist/pencils.cjs +8 -0
- package/dist/pencils.d.cts +2 -0
- package/dist/pencils.d.ts +2 -0
- package/dist/pencils.js +7 -0
- package/dist/primitives/AxisInput.cjs +26 -0
- package/dist/primitives/AxisInput.js +25 -0
- package/dist/primitives/ChannelSlider.cjs +94 -0
- package/dist/primitives/ChannelSlider.d.cts +18 -0
- package/dist/primitives/ChannelSlider.d.ts +18 -0
- package/dist/primitives/ChannelSlider.js +93 -0
- package/dist/primitives/ColorArea.cjs +85 -0
- package/dist/primitives/ColorArea.d.cts +8 -0
- package/dist/primitives/ColorArea.d.ts +8 -0
- package/dist/primitives/ColorArea.js +84 -0
- package/dist/primitives/ColorDisc.cjs +95 -0
- package/dist/primitives/ColorDisc.d.cts +8 -0
- package/dist/primitives/ColorDisc.d.ts +8 -0
- package/dist/primitives/ColorDisc.js +94 -0
- package/dist/primitives/ColorField.cjs +68 -0
- package/dist/primitives/ColorField.d.cts +9 -0
- package/dist/primitives/ColorField.d.ts +9 -0
- package/dist/primitives/ColorField.js +67 -0
- package/dist/primitives/NumberField.cjs +65 -0
- package/dist/primitives/NumberField.d.cts +14 -0
- package/dist/primitives/NumberField.d.ts +14 -0
- package/dist/primitives/NumberField.js +64 -0
- package/dist/primitives/SegmentedControl.cjs +66 -0
- package/dist/primitives/SegmentedControl.d.cts +21 -0
- package/dist/primitives/SegmentedControl.d.ts +21 -0
- package/dist/primitives/SegmentedControl.js +65 -0
- package/dist/primitives/Swatch.cjs +22 -0
- package/dist/primitives/Swatch.d.cts +13 -0
- package/dist/primitives/Swatch.d.ts +13 -0
- package/dist/primitives/Swatch.js +21 -0
- package/dist/primitives/SwatchGrid.cjs +63 -0
- package/dist/primitives/SwatchGrid.d.cts +17 -0
- package/dist/primitives/SwatchGrid.d.ts +17 -0
- package/dist/primitives/SwatchGrid.js +62 -0
- package/dist/primitives/icons.cjs +149 -0
- package/dist/primitives/icons.d.cts +9 -0
- package/dist/primitives/icons.d.ts +9 -0
- package/dist/primitives/icons.js +141 -0
- package/dist/primitives/useEyedropper.cjs +30 -0
- package/dist/primitives/useEyedropper.d.cts +7 -0
- package/dist/primitives/useEyedropper.d.ts +7 -0
- package/dist/primitives/useEyedropper.js +29 -0
- package/dist/sliders.cjs +8 -0
- package/dist/sliders.d.cts +2 -0
- package/dist/sliders.d.ts +2 -0
- package/dist/sliders.js +7 -0
- package/dist/style.css +2 -0
- package/dist/styles/css.cjs +4 -0
- package/dist/styles/css.js +5 -0
- package/dist/wheel.cjs +8 -0
- package/dist/wheel.d.cts +2 -0
- package/dist/wheel.d.ts +2 -0
- package/dist/wheel.js +7 -0
- package/package.json +222 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
//#region src/color/convert.ts
|
|
2
|
+
function clamp(value, min, max) {
|
|
3
|
+
return value < min ? min : value > max ? max : value;
|
|
4
|
+
}
|
|
5
|
+
function normalizeHue(h) {
|
|
6
|
+
const r = h % 360;
|
|
7
|
+
return r < 0 ? r + 360 : r;
|
|
8
|
+
}
|
|
9
|
+
function rgbaToHsva(rgba) {
|
|
10
|
+
const { r, g, b, a } = rgba;
|
|
11
|
+
const max = Math.max(r, g, b);
|
|
12
|
+
const d = max - Math.min(r, g, b);
|
|
13
|
+
let hh;
|
|
14
|
+
if (d === 0) hh = 0;
|
|
15
|
+
else if (max === r) hh = (g - b) / d;
|
|
16
|
+
else if (max === g) hh = 2 + (b - r) / d;
|
|
17
|
+
else hh = 4 + (r - g) / d;
|
|
18
|
+
return {
|
|
19
|
+
h: 60 * (hh < 0 ? hh + 6 : hh),
|
|
20
|
+
s: max === 0 ? 0 : d / max * 100,
|
|
21
|
+
v: max / 255 * 100,
|
|
22
|
+
a
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function hsvaToRgba(hsva) {
|
|
26
|
+
const hh = normalizeHue(hsva.h) / 360 * 6;
|
|
27
|
+
const i = Math.floor(hh);
|
|
28
|
+
const f = hh - i;
|
|
29
|
+
const s = hsva.s;
|
|
30
|
+
const v = hsva.v;
|
|
31
|
+
const p = v * (100 - s) / 100;
|
|
32
|
+
const q = v * (100 - f * s) / 100;
|
|
33
|
+
const t = v * (100 - (1 - f) * s) / 100;
|
|
34
|
+
let r;
|
|
35
|
+
let g;
|
|
36
|
+
let b;
|
|
37
|
+
switch (i % 6) {
|
|
38
|
+
case 0:
|
|
39
|
+
r = v;
|
|
40
|
+
g = t;
|
|
41
|
+
b = p;
|
|
42
|
+
break;
|
|
43
|
+
case 1:
|
|
44
|
+
r = q;
|
|
45
|
+
g = v;
|
|
46
|
+
b = p;
|
|
47
|
+
break;
|
|
48
|
+
case 2:
|
|
49
|
+
r = p;
|
|
50
|
+
g = v;
|
|
51
|
+
b = t;
|
|
52
|
+
break;
|
|
53
|
+
case 3:
|
|
54
|
+
r = p;
|
|
55
|
+
g = q;
|
|
56
|
+
b = v;
|
|
57
|
+
break;
|
|
58
|
+
case 4:
|
|
59
|
+
r = t;
|
|
60
|
+
g = p;
|
|
61
|
+
b = v;
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
r = v;
|
|
65
|
+
g = p;
|
|
66
|
+
b = q;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
r: r * 255 / 100,
|
|
70
|
+
g: g * 255 / 100,
|
|
71
|
+
b: b * 255 / 100,
|
|
72
|
+
a: hsva.a
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function hsvaToHsla(hsva) {
|
|
76
|
+
const { h, s, v, a } = hsva;
|
|
77
|
+
const hh = (200 - s) * v / 100;
|
|
78
|
+
return {
|
|
79
|
+
h,
|
|
80
|
+
s: hh > 0 && hh < 200 ? s * v / 100 / (hh <= 100 ? hh : 200 - hh) * 100 : 0,
|
|
81
|
+
l: hh / 2,
|
|
82
|
+
a
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function hslaToHsva(hsla) {
|
|
86
|
+
const { h, s, l, a } = hsla;
|
|
87
|
+
const ss = s * (l < 50 ? l : 100 - l) / 100;
|
|
88
|
+
return {
|
|
89
|
+
h,
|
|
90
|
+
s: ss > 0 ? 2 * ss / (l + ss) * 100 : 0,
|
|
91
|
+
v: l + ss,
|
|
92
|
+
a
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function hwbaToHsva(hwba) {
|
|
96
|
+
const { h, a } = hwba;
|
|
97
|
+
let { w, b } = hwba;
|
|
98
|
+
const sum = w + b;
|
|
99
|
+
if (sum >= 100) {
|
|
100
|
+
const grey = w / sum * 100;
|
|
101
|
+
w = grey;
|
|
102
|
+
b = 100 - grey;
|
|
103
|
+
return {
|
|
104
|
+
h,
|
|
105
|
+
s: 0,
|
|
106
|
+
v: grey,
|
|
107
|
+
a
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const v = 100 - b;
|
|
111
|
+
return {
|
|
112
|
+
h,
|
|
113
|
+
s: v === 0 ? 0 : (1 - w / v) * 100,
|
|
114
|
+
v,
|
|
115
|
+
a
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function hsvaToHwba(hsva) {
|
|
119
|
+
const { h, s, v, a } = hsva;
|
|
120
|
+
return {
|
|
121
|
+
h,
|
|
122
|
+
w: (100 - s) * v / 100,
|
|
123
|
+
b: 100 - v,
|
|
124
|
+
a
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function hsvaToRgb(hsva) {
|
|
128
|
+
const { r, g, b } = hsvaToRgba(hsva);
|
|
129
|
+
return {
|
|
130
|
+
r,
|
|
131
|
+
g,
|
|
132
|
+
b
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function hsvaToHsl(hsva) {
|
|
136
|
+
const { h, s, l } = hsvaToHsla(hsva);
|
|
137
|
+
return {
|
|
138
|
+
h,
|
|
139
|
+
s,
|
|
140
|
+
l
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function roundRgba(rgba) {
|
|
144
|
+
return {
|
|
145
|
+
r: Math.round(clamp(rgba.r, 0, 255)),
|
|
146
|
+
g: Math.round(clamp(rgba.g, 0, 255)),
|
|
147
|
+
b: Math.round(clamp(rgba.b, 0, 255)),
|
|
148
|
+
a: clamp(rgba.a, 0, 1)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
export { clamp, hslaToHsva, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, normalizeHue, rgbaToHsva, roundRgba };
|
|
153
|
+
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
const require_convert = require("./convert.cjs");
|
|
2
|
+
//#region src/color/parse.ts
|
|
3
|
+
let namedTable = null;
|
|
4
|
+
function registerNamedColors(table) {
|
|
5
|
+
namedTable = namedTable ? {
|
|
6
|
+
...namedTable,
|
|
7
|
+
...table
|
|
8
|
+
} : { ...table };
|
|
9
|
+
}
|
|
10
|
+
function clearNamedColors() {
|
|
11
|
+
namedTable = null;
|
|
12
|
+
}
|
|
13
|
+
const NUM = /^([+-]?(?:\d*\.)?\d+(?:e[+-]?\d+)?)(%?)$/i;
|
|
14
|
+
const ANGLE = /^([+-]?(?:\d*\.)?\d+(?:e[+-]?\d+)?)(deg|grad|rad|turn)?$/i;
|
|
15
|
+
function parseHue(token) {
|
|
16
|
+
const m = ANGLE.exec(token);
|
|
17
|
+
if (!m) return null;
|
|
18
|
+
const n = Number.parseFloat(m[1]);
|
|
19
|
+
if (!Number.isFinite(n)) return null;
|
|
20
|
+
switch ((m[2] ?? "deg").toLowerCase()) {
|
|
21
|
+
case "grad": return n * .9;
|
|
22
|
+
case "rad": return n * 180 / Math.PI;
|
|
23
|
+
case "turn": return n * 360;
|
|
24
|
+
default: return n;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function parseChannel(token) {
|
|
28
|
+
const m = NUM.exec(token);
|
|
29
|
+
if (!m) return null;
|
|
30
|
+
const n = Number.parseFloat(m[1]);
|
|
31
|
+
if (!Number.isFinite(n)) return null;
|
|
32
|
+
return m[2] ? n / 100 * 255 : n;
|
|
33
|
+
}
|
|
34
|
+
function parsePercent(token) {
|
|
35
|
+
const m = NUM.exec(token);
|
|
36
|
+
if (!m) return null;
|
|
37
|
+
const n = Number.parseFloat(m[1]);
|
|
38
|
+
return Number.isFinite(n) ? n : null;
|
|
39
|
+
}
|
|
40
|
+
function parseAlpha(token) {
|
|
41
|
+
if (token === null) return 1;
|
|
42
|
+
if (token.toLowerCase() === "none") return 1;
|
|
43
|
+
const m = NUM.exec(token);
|
|
44
|
+
if (!m) return null;
|
|
45
|
+
const n = Number.parseFloat(m[1]);
|
|
46
|
+
if (!Number.isFinite(n)) return null;
|
|
47
|
+
return require_convert.clamp(m[2] ? n / 100 : n, 0, 1);
|
|
48
|
+
}
|
|
49
|
+
function splitArgs(body) {
|
|
50
|
+
const slash = body.indexOf("/");
|
|
51
|
+
let head = body;
|
|
52
|
+
let alpha = null;
|
|
53
|
+
if (slash !== -1) {
|
|
54
|
+
head = body.slice(0, slash);
|
|
55
|
+
alpha = body.slice(slash + 1).trim() || null;
|
|
56
|
+
}
|
|
57
|
+
const parts = head.split(/[\s,]+/).filter(Boolean);
|
|
58
|
+
if (alpha === null && parts.length === 4) alpha = parts.pop();
|
|
59
|
+
return {
|
|
60
|
+
parts,
|
|
61
|
+
alpha
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const HEX = /^#?([0-9a-f]{3,8})$/i;
|
|
65
|
+
function parseHex(input) {
|
|
66
|
+
const m = HEX.exec(input);
|
|
67
|
+
if (!m) return null;
|
|
68
|
+
const hex = m[1];
|
|
69
|
+
const len = hex.length;
|
|
70
|
+
if (len !== 3 && len !== 4 && len !== 6 && len !== 8) return null;
|
|
71
|
+
const short = len < 6;
|
|
72
|
+
const step = short ? 1 : 2;
|
|
73
|
+
const read = (i) => {
|
|
74
|
+
const slice = hex.slice(i * step, i * step + step);
|
|
75
|
+
return Number.parseInt(short ? slice + slice : slice, 16);
|
|
76
|
+
};
|
|
77
|
+
const hasAlpha = len === 4 || len === 8;
|
|
78
|
+
return require_convert.rgbaToHsva({
|
|
79
|
+
r: read(0),
|
|
80
|
+
g: read(1),
|
|
81
|
+
b: read(2),
|
|
82
|
+
a: hasAlpha ? read(3) / 255 : 1
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const FUNC = /^([a-z]+)\(\s*([^)]*)\)$/i;
|
|
86
|
+
function parse(input) {
|
|
87
|
+
const raw = input.trim();
|
|
88
|
+
if (raw === "") return null;
|
|
89
|
+
const lower = raw.toLowerCase();
|
|
90
|
+
if (lower === "transparent") return {
|
|
91
|
+
h: 0,
|
|
92
|
+
s: 0,
|
|
93
|
+
v: 0,
|
|
94
|
+
a: 0
|
|
95
|
+
};
|
|
96
|
+
if (namedTable !== null) {
|
|
97
|
+
const named = namedTable[lower];
|
|
98
|
+
if (named !== void 0) return parseHex(named);
|
|
99
|
+
}
|
|
100
|
+
if (raw.charCodeAt(0) === 35) return parseHex(raw);
|
|
101
|
+
const fn = FUNC.exec(raw);
|
|
102
|
+
if (fn === null) return parseHex(raw);
|
|
103
|
+
const name = fn[1].toLowerCase();
|
|
104
|
+
const { parts, alpha: alphaToken } = splitArgs(fn[2]);
|
|
105
|
+
if (parts.length !== 3) return null;
|
|
106
|
+
const alpha = parseAlpha(alphaToken);
|
|
107
|
+
if (alpha === null) return null;
|
|
108
|
+
if (name === "rgb" || name === "rgba") {
|
|
109
|
+
const r = parseChannel(parts[0]);
|
|
110
|
+
const g = parseChannel(parts[1]);
|
|
111
|
+
const b = parseChannel(parts[2]);
|
|
112
|
+
if (r === null || g === null || b === null) return null;
|
|
113
|
+
return require_convert.rgbaToHsva({
|
|
114
|
+
r: require_convert.clamp(r, 0, 255),
|
|
115
|
+
g: require_convert.clamp(g, 0, 255),
|
|
116
|
+
b: require_convert.clamp(b, 0, 255),
|
|
117
|
+
a: alpha
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (name === "hsl" || name === "hsla") {
|
|
121
|
+
const h = parseHue(parts[0]);
|
|
122
|
+
const s = parsePercent(parts[1]);
|
|
123
|
+
const l = parsePercent(parts[2]);
|
|
124
|
+
if (h === null || s === null || l === null) return null;
|
|
125
|
+
return require_convert.hslaToHsva({
|
|
126
|
+
h,
|
|
127
|
+
s: require_convert.clamp(s, 0, 100),
|
|
128
|
+
l: require_convert.clamp(l, 0, 100),
|
|
129
|
+
a: alpha
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (name === "hwb") {
|
|
133
|
+
const h = parseHue(parts[0]);
|
|
134
|
+
const w = parsePercent(parts[1]);
|
|
135
|
+
const b = parsePercent(parts[2]);
|
|
136
|
+
if (h === null || w === null || b === null) return null;
|
|
137
|
+
return require_convert.hwbaToHsva({
|
|
138
|
+
h,
|
|
139
|
+
w: require_convert.clamp(w, 0, 100),
|
|
140
|
+
b: require_convert.clamp(b, 0, 100),
|
|
141
|
+
a: alpha
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
function isValidColor(input) {
|
|
147
|
+
return parse(input) !== null;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
exports.clearNamedColors = clearNamedColors;
|
|
151
|
+
exports.isValidColor = isValidColor;
|
|
152
|
+
exports.parse = parse;
|
|
153
|
+
exports.registerNamedColors = registerNamedColors;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Hsva } from "./types.cjs";
|
|
2
|
+
//#region src/color/parse.d.ts
|
|
3
|
+
export declare function registerNamedColors(table: Record<string, string>): void;
|
|
4
|
+
export declare function clearNamedColors(): void;
|
|
5
|
+
export declare function parse(input: string): Hsva | null;
|
|
6
|
+
export declare function isValidColor(input: string): boolean;
|
|
7
|
+
//#endregion
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Hsva } from "./types.js";
|
|
2
|
+
//#region src/color/parse.d.ts
|
|
3
|
+
export declare function registerNamedColors(table: Record<string, string>): void;
|
|
4
|
+
export declare function clearNamedColors(): void;
|
|
5
|
+
export declare function parse(input: string): Hsva | null;
|
|
6
|
+
export declare function isValidColor(input: string): boolean;
|
|
7
|
+
//#endregion
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { clamp, hslaToHsva, hwbaToHsva, rgbaToHsva } from "./convert.js";
|
|
2
|
+
//#region src/color/parse.ts
|
|
3
|
+
let namedTable = null;
|
|
4
|
+
function registerNamedColors(table) {
|
|
5
|
+
namedTable = namedTable ? {
|
|
6
|
+
...namedTable,
|
|
7
|
+
...table
|
|
8
|
+
} : { ...table };
|
|
9
|
+
}
|
|
10
|
+
function clearNamedColors() {
|
|
11
|
+
namedTable = null;
|
|
12
|
+
}
|
|
13
|
+
const NUM = /^([+-]?(?:\d*\.)?\d+(?:e[+-]?\d+)?)(%?)$/i;
|
|
14
|
+
const ANGLE = /^([+-]?(?:\d*\.)?\d+(?:e[+-]?\d+)?)(deg|grad|rad|turn)?$/i;
|
|
15
|
+
function parseHue(token) {
|
|
16
|
+
const m = ANGLE.exec(token);
|
|
17
|
+
if (!m) return null;
|
|
18
|
+
const n = Number.parseFloat(m[1]);
|
|
19
|
+
if (!Number.isFinite(n)) return null;
|
|
20
|
+
switch ((m[2] ?? "deg").toLowerCase()) {
|
|
21
|
+
case "grad": return n * .9;
|
|
22
|
+
case "rad": return n * 180 / Math.PI;
|
|
23
|
+
case "turn": return n * 360;
|
|
24
|
+
default: return n;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function parseChannel(token) {
|
|
28
|
+
const m = NUM.exec(token);
|
|
29
|
+
if (!m) return null;
|
|
30
|
+
const n = Number.parseFloat(m[1]);
|
|
31
|
+
if (!Number.isFinite(n)) return null;
|
|
32
|
+
return m[2] ? n / 100 * 255 : n;
|
|
33
|
+
}
|
|
34
|
+
function parsePercent(token) {
|
|
35
|
+
const m = NUM.exec(token);
|
|
36
|
+
if (!m) return null;
|
|
37
|
+
const n = Number.parseFloat(m[1]);
|
|
38
|
+
return Number.isFinite(n) ? n : null;
|
|
39
|
+
}
|
|
40
|
+
function parseAlpha(token) {
|
|
41
|
+
if (token === null) return 1;
|
|
42
|
+
if (token.toLowerCase() === "none") return 1;
|
|
43
|
+
const m = NUM.exec(token);
|
|
44
|
+
if (!m) return null;
|
|
45
|
+
const n = Number.parseFloat(m[1]);
|
|
46
|
+
if (!Number.isFinite(n)) return null;
|
|
47
|
+
return clamp(m[2] ? n / 100 : n, 0, 1);
|
|
48
|
+
}
|
|
49
|
+
function splitArgs(body) {
|
|
50
|
+
const slash = body.indexOf("/");
|
|
51
|
+
let head = body;
|
|
52
|
+
let alpha = null;
|
|
53
|
+
if (slash !== -1) {
|
|
54
|
+
head = body.slice(0, slash);
|
|
55
|
+
alpha = body.slice(slash + 1).trim() || null;
|
|
56
|
+
}
|
|
57
|
+
const parts = head.split(/[\s,]+/).filter(Boolean);
|
|
58
|
+
if (alpha === null && parts.length === 4) alpha = parts.pop();
|
|
59
|
+
return {
|
|
60
|
+
parts,
|
|
61
|
+
alpha
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const HEX = /^#?([0-9a-f]{3,8})$/i;
|
|
65
|
+
function parseHex(input) {
|
|
66
|
+
const m = HEX.exec(input);
|
|
67
|
+
if (!m) return null;
|
|
68
|
+
const hex = m[1];
|
|
69
|
+
const len = hex.length;
|
|
70
|
+
if (len !== 3 && len !== 4 && len !== 6 && len !== 8) return null;
|
|
71
|
+
const short = len < 6;
|
|
72
|
+
const step = short ? 1 : 2;
|
|
73
|
+
const read = (i) => {
|
|
74
|
+
const slice = hex.slice(i * step, i * step + step);
|
|
75
|
+
return Number.parseInt(short ? slice + slice : slice, 16);
|
|
76
|
+
};
|
|
77
|
+
const hasAlpha = len === 4 || len === 8;
|
|
78
|
+
return rgbaToHsva({
|
|
79
|
+
r: read(0),
|
|
80
|
+
g: read(1),
|
|
81
|
+
b: read(2),
|
|
82
|
+
a: hasAlpha ? read(3) / 255 : 1
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const FUNC = /^([a-z]+)\(\s*([^)]*)\)$/i;
|
|
86
|
+
function parse(input) {
|
|
87
|
+
const raw = input.trim();
|
|
88
|
+
if (raw === "") return null;
|
|
89
|
+
const lower = raw.toLowerCase();
|
|
90
|
+
if (lower === "transparent") return {
|
|
91
|
+
h: 0,
|
|
92
|
+
s: 0,
|
|
93
|
+
v: 0,
|
|
94
|
+
a: 0
|
|
95
|
+
};
|
|
96
|
+
if (namedTable !== null) {
|
|
97
|
+
const named = namedTable[lower];
|
|
98
|
+
if (named !== void 0) return parseHex(named);
|
|
99
|
+
}
|
|
100
|
+
if (raw.charCodeAt(0) === 35) return parseHex(raw);
|
|
101
|
+
const fn = FUNC.exec(raw);
|
|
102
|
+
if (fn === null) return parseHex(raw);
|
|
103
|
+
const name = fn[1].toLowerCase();
|
|
104
|
+
const { parts, alpha: alphaToken } = splitArgs(fn[2]);
|
|
105
|
+
if (parts.length !== 3) return null;
|
|
106
|
+
const alpha = parseAlpha(alphaToken);
|
|
107
|
+
if (alpha === null) return null;
|
|
108
|
+
if (name === "rgb" || name === "rgba") {
|
|
109
|
+
const r = parseChannel(parts[0]);
|
|
110
|
+
const g = parseChannel(parts[1]);
|
|
111
|
+
const b = parseChannel(parts[2]);
|
|
112
|
+
if (r === null || g === null || b === null) return null;
|
|
113
|
+
return rgbaToHsva({
|
|
114
|
+
r: clamp(r, 0, 255),
|
|
115
|
+
g: clamp(g, 0, 255),
|
|
116
|
+
b: clamp(b, 0, 255),
|
|
117
|
+
a: alpha
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (name === "hsl" || name === "hsla") {
|
|
121
|
+
const h = parseHue(parts[0]);
|
|
122
|
+
const s = parsePercent(parts[1]);
|
|
123
|
+
const l = parsePercent(parts[2]);
|
|
124
|
+
if (h === null || s === null || l === null) return null;
|
|
125
|
+
return hslaToHsva({
|
|
126
|
+
h,
|
|
127
|
+
s: clamp(s, 0, 100),
|
|
128
|
+
l: clamp(l, 0, 100),
|
|
129
|
+
a: alpha
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (name === "hwb") {
|
|
133
|
+
const h = parseHue(parts[0]);
|
|
134
|
+
const w = parsePercent(parts[1]);
|
|
135
|
+
const b = parsePercent(parts[2]);
|
|
136
|
+
if (h === null || w === null || b === null) return null;
|
|
137
|
+
return hwbaToHsva({
|
|
138
|
+
h,
|
|
139
|
+
w: clamp(w, 0, 100),
|
|
140
|
+
b: clamp(b, 0, 100),
|
|
141
|
+
a: alpha
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
function isValidColor(input) {
|
|
147
|
+
return parse(input) !== null;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
export { clearNamedColors, isValidColor, parse, registerNamedColors };
|
|
151
|
+
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const require_convert = require("./convert.cjs");
|
|
2
|
+
//#region src/color/serialize.ts
|
|
3
|
+
function hex2(channel) {
|
|
4
|
+
const v = Math.round(require_convert.clamp(channel, 0, 255));
|
|
5
|
+
return v < 16 ? "0" + v.toString(16) : v.toString(16);
|
|
6
|
+
}
|
|
7
|
+
function toHex(hsva) {
|
|
8
|
+
const { r, g, b } = require_convert.hsvaToRgba(hsva);
|
|
9
|
+
return "#" + hex2(r) + hex2(g) + hex2(b);
|
|
10
|
+
}
|
|
11
|
+
function toHexa(hsva) {
|
|
12
|
+
const { r, g, b, a } = require_convert.hsvaToRgba(hsva);
|
|
13
|
+
return "#" + hex2(r) + hex2(g) + hex2(b) + hex2(require_convert.clamp(a, 0, 1) * 255);
|
|
14
|
+
}
|
|
15
|
+
function toRgbString(hsva) {
|
|
16
|
+
const { r, g, b } = require_convert.roundRgba(require_convert.hsvaToRgba(hsva));
|
|
17
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
18
|
+
}
|
|
19
|
+
function toRgbaString(hsva) {
|
|
20
|
+
const { r, g, b, a } = require_convert.roundRgba(require_convert.hsvaToRgba(hsva));
|
|
21
|
+
return `rgba(${r}, ${g}, ${b}, ${round(a, 3)})`;
|
|
22
|
+
}
|
|
23
|
+
function toHslString(hsva) {
|
|
24
|
+
const { h, s, l } = require_convert.hsvaToHsla(hsva);
|
|
25
|
+
return `hsl(${Math.round(require_convert.normalizeHue(h))}, ${Math.round(s)}%, ${Math.round(l)}%)`;
|
|
26
|
+
}
|
|
27
|
+
function toHslaString(hsva) {
|
|
28
|
+
const { h, s, l, a } = require_convert.hsvaToHsla(hsva);
|
|
29
|
+
return `hsla(${Math.round(require_convert.normalizeHue(h))}, ${Math.round(s)}%, ${Math.round(l)}%, ${round(a, 3)})`;
|
|
30
|
+
}
|
|
31
|
+
function round(value, places) {
|
|
32
|
+
const f = 10 ** places;
|
|
33
|
+
return Math.round(value * f) / f;
|
|
34
|
+
}
|
|
35
|
+
function toFormat(hsva, format) {
|
|
36
|
+
switch (format) {
|
|
37
|
+
case "hexa": return toHexa(hsva);
|
|
38
|
+
case "rgb": return toRgbString(hsva);
|
|
39
|
+
case "rgba": return toRgbaString(hsva);
|
|
40
|
+
case "hsl": return toHslString(hsva);
|
|
41
|
+
case "hsla": return toHslaString(hsva);
|
|
42
|
+
default: return toHex(hsva);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function toResult(hsva, format) {
|
|
46
|
+
const rgba = require_convert.roundRgba(require_convert.hsvaToRgba(hsva));
|
|
47
|
+
const hsla = require_convert.hsvaToHsla(hsva);
|
|
48
|
+
const hsl = {
|
|
49
|
+
h: Math.round(require_convert.normalizeHue(hsla.h)),
|
|
50
|
+
s: Math.round(hsla.s),
|
|
51
|
+
l: Math.round(hsla.l)
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
hex: toHex(hsva),
|
|
55
|
+
hexa: toHexa(hsva),
|
|
56
|
+
rgb: {
|
|
57
|
+
r: rgba.r,
|
|
58
|
+
g: rgba.g,
|
|
59
|
+
b: rgba.b
|
|
60
|
+
},
|
|
61
|
+
rgba,
|
|
62
|
+
hsl,
|
|
63
|
+
hsla: {
|
|
64
|
+
...hsl,
|
|
65
|
+
a: round(hsva.a, 3)
|
|
66
|
+
},
|
|
67
|
+
hsva,
|
|
68
|
+
css: toFormat(hsva, format)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
exports.toFormat = toFormat;
|
|
73
|
+
exports.toHex = toHex;
|
|
74
|
+
exports.toHexa = toHexa;
|
|
75
|
+
exports.toHslString = toHslString;
|
|
76
|
+
exports.toHslaString = toHslaString;
|
|
77
|
+
exports.toResult = toResult;
|
|
78
|
+
exports.toRgbString = toRgbString;
|
|
79
|
+
exports.toRgbaString = toRgbaString;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ColorChangeResult, ColorFormat, Hsva } from "./types.cjs";
|
|
2
|
+
//#region src/color/serialize.d.ts
|
|
3
|
+
export declare function toHex(hsva: Hsva): string;
|
|
4
|
+
export declare function toHexa(hsva: Hsva): string;
|
|
5
|
+
export declare function toRgbString(hsva: Hsva): string;
|
|
6
|
+
export declare function toRgbaString(hsva: Hsva): string;
|
|
7
|
+
export declare function toHslString(hsva: Hsva): string;
|
|
8
|
+
export declare function toHslaString(hsva: Hsva): string;
|
|
9
|
+
export declare function toFormat(hsva: Hsva, format: ColorFormat): string;
|
|
10
|
+
export declare function toResult(hsva: Hsva, format: ColorFormat): ColorChangeResult;
|
|
11
|
+
//#endregion
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ColorChangeResult, ColorFormat, Hsva } from "./types.js";
|
|
2
|
+
//#region src/color/serialize.d.ts
|
|
3
|
+
export declare function toHex(hsva: Hsva): string;
|
|
4
|
+
export declare function toHexa(hsva: Hsva): string;
|
|
5
|
+
export declare function toRgbString(hsva: Hsva): string;
|
|
6
|
+
export declare function toRgbaString(hsva: Hsva): string;
|
|
7
|
+
export declare function toHslString(hsva: Hsva): string;
|
|
8
|
+
export declare function toHslaString(hsva: Hsva): string;
|
|
9
|
+
export declare function toFormat(hsva: Hsva, format: ColorFormat): string;
|
|
10
|
+
export declare function toResult(hsva: Hsva, format: ColorFormat): ColorChangeResult;
|
|
11
|
+
//#endregion
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { clamp, hsvaToHsla, hsvaToRgba, normalizeHue, roundRgba } from "./convert.js";
|
|
2
|
+
//#region src/color/serialize.ts
|
|
3
|
+
function hex2(channel) {
|
|
4
|
+
const v = Math.round(clamp(channel, 0, 255));
|
|
5
|
+
return v < 16 ? "0" + v.toString(16) : v.toString(16);
|
|
6
|
+
}
|
|
7
|
+
function toHex(hsva) {
|
|
8
|
+
const { r, g, b } = hsvaToRgba(hsva);
|
|
9
|
+
return "#" + hex2(r) + hex2(g) + hex2(b);
|
|
10
|
+
}
|
|
11
|
+
function toHexa(hsva) {
|
|
12
|
+
const { r, g, b, a } = hsvaToRgba(hsva);
|
|
13
|
+
return "#" + hex2(r) + hex2(g) + hex2(b) + hex2(clamp(a, 0, 1) * 255);
|
|
14
|
+
}
|
|
15
|
+
function toRgbString(hsva) {
|
|
16
|
+
const { r, g, b } = roundRgba(hsvaToRgba(hsva));
|
|
17
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
18
|
+
}
|
|
19
|
+
function toRgbaString(hsva) {
|
|
20
|
+
const { r, g, b, a } = roundRgba(hsvaToRgba(hsva));
|
|
21
|
+
return `rgba(${r}, ${g}, ${b}, ${round(a, 3)})`;
|
|
22
|
+
}
|
|
23
|
+
function toHslString(hsva) {
|
|
24
|
+
const { h, s, l } = hsvaToHsla(hsva);
|
|
25
|
+
return `hsl(${Math.round(normalizeHue(h))}, ${Math.round(s)}%, ${Math.round(l)}%)`;
|
|
26
|
+
}
|
|
27
|
+
function toHslaString(hsva) {
|
|
28
|
+
const { h, s, l, a } = hsvaToHsla(hsva);
|
|
29
|
+
return `hsla(${Math.round(normalizeHue(h))}, ${Math.round(s)}%, ${Math.round(l)}%, ${round(a, 3)})`;
|
|
30
|
+
}
|
|
31
|
+
function round(value, places) {
|
|
32
|
+
const f = 10 ** places;
|
|
33
|
+
return Math.round(value * f) / f;
|
|
34
|
+
}
|
|
35
|
+
function toFormat(hsva, format) {
|
|
36
|
+
switch (format) {
|
|
37
|
+
case "hexa": return toHexa(hsva);
|
|
38
|
+
case "rgb": return toRgbString(hsva);
|
|
39
|
+
case "rgba": return toRgbaString(hsva);
|
|
40
|
+
case "hsl": return toHslString(hsva);
|
|
41
|
+
case "hsla": return toHslaString(hsva);
|
|
42
|
+
default: return toHex(hsva);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function toResult(hsva, format) {
|
|
46
|
+
const rgba = roundRgba(hsvaToRgba(hsva));
|
|
47
|
+
const hsla = hsvaToHsla(hsva);
|
|
48
|
+
const hsl = {
|
|
49
|
+
h: Math.round(normalizeHue(hsla.h)),
|
|
50
|
+
s: Math.round(hsla.s),
|
|
51
|
+
l: Math.round(hsla.l)
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
hex: toHex(hsva),
|
|
55
|
+
hexa: toHexa(hsva),
|
|
56
|
+
rgb: {
|
|
57
|
+
r: rgba.r,
|
|
58
|
+
g: rgba.g,
|
|
59
|
+
b: rgba.b
|
|
60
|
+
},
|
|
61
|
+
rgba,
|
|
62
|
+
hsl,
|
|
63
|
+
hsla: {
|
|
64
|
+
...hsl,
|
|
65
|
+
a: round(hsva.a, 3)
|
|
66
|
+
},
|
|
67
|
+
hsva,
|
|
68
|
+
css: toFormat(hsva, format)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString };
|
|
73
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_serialize = require("./serialize.cjs");
|
|
2
|
+
//#region src/color/sticky.ts
|
|
3
|
+
function ingest(next, prev) {
|
|
4
|
+
return {
|
|
5
|
+
h: next.s > 0 && next.v > 0 ? next.h : prev.h,
|
|
6
|
+
s: next.v > 0 ? next.s : prev.s,
|
|
7
|
+
v: next.v,
|
|
8
|
+
a: next.a
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function sameRendered(a, b) {
|
|
12
|
+
return require_serialize.toHexa(a) === require_serialize.toHexa(b);
|
|
13
|
+
}
|
|
14
|
+
function sameHsva(a, b) {
|
|
15
|
+
return a.h === b.h && a.s === b.s && a.v === b.v && a.a === b.a;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.ingest = ingest;
|
|
19
|
+
exports.sameHsva = sameHsva;
|
|
20
|
+
exports.sameRendered = sameRendered;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Hsva } from "./types.cjs";
|
|
2
|
+
//#region src/color/sticky.d.ts
|
|
3
|
+
export declare function ingest(next: Hsva, prev: Hsva): Hsva;
|
|
4
|
+
export declare function sameRendered(a: Hsva, b: Hsva): boolean;
|
|
5
|
+
export declare function sameHsva(a: Hsva, b: Hsva): boolean;
|
|
6
|
+
//#endregion
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Hsva } from "./types.js";
|
|
2
|
+
//#region src/color/sticky.d.ts
|
|
3
|
+
export declare function ingest(next: Hsva, prev: Hsva): Hsva;
|
|
4
|
+
export declare function sameRendered(a: Hsva, b: Hsva): boolean;
|
|
5
|
+
export declare function sameHsva(a: Hsva, b: Hsva): boolean;
|
|
6
|
+
//#endregion
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { toHexa } from "./serialize.js";
|
|
2
|
+
//#region src/color/sticky.ts
|
|
3
|
+
function ingest(next, prev) {
|
|
4
|
+
return {
|
|
5
|
+
h: next.s > 0 && next.v > 0 ? next.h : prev.h,
|
|
6
|
+
s: next.v > 0 ? next.s : prev.s,
|
|
7
|
+
v: next.v,
|
|
8
|
+
a: next.a
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function sameRendered(a, b) {
|
|
12
|
+
return toHexa(a) === toHexa(b);
|
|
13
|
+
}
|
|
14
|
+
function sameHsva(a, b) {
|
|
15
|
+
return a.h === b.h && a.s === b.s && a.v === b.v && a.a === b.a;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ingest, sameHsva, sameRendered };
|
|
19
|
+
|