@pixerate/editor 0.249.0 → 0.251.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/dist/agent/index.cjs +40 -41
- package/dist/agent/index.js +9 -10
- package/dist/animation/index.cjs +6 -7
- package/dist/animation/index.js +5 -6
- package/dist/animation-editor/index.cjs +124 -123
- package/dist/animation-editor/index.js +15 -14
- package/dist/brushes/index.cjs +1406 -0
- package/dist/brushes/index.d.cts +12 -0
- package/dist/brushes/index.d.ts +12 -0
- package/dist/brushes/index.js +1406 -0
- package/dist/brushes/migrate.d.cts +17 -0
- package/dist/brushes/migrate.d.ts +17 -0
- package/dist/brushes/normalize.d.cts +15 -0
- package/dist/brushes/normalize.d.ts +15 -0
- package/dist/brushes/presets.d.cts +12 -0
- package/dist/brushes/presets.d.ts +12 -0
- package/dist/brushes/resolve.d.cts +56 -0
- package/dist/brushes/resolve.d.ts +56 -0
- package/dist/brushes/schema.d.cts +29 -0
- package/dist/brushes/schema.d.ts +29 -0
- package/dist/brushes/types.d.cts +323 -0
- package/dist/brushes/types.d.ts +323 -0
- package/dist/{brushstrokeRender-T3JZST44.js → brushstrokeRender-5PYSKZIJ.js} +9 -8
- package/dist/{brushstrokeRender-GCKK7V2I.cjs → brushstrokeRender-7FLLSQEC.cjs} +15 -14
- package/dist/canvas/index.cjs +120 -65
- package/dist/canvas/index.d.cts +1 -0
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.js +88 -33
- package/dist/canvas/stickers.d.cts +35 -0
- package/dist/canvas/stickers.d.ts +35 -0
- package/dist/chart/index.cjs +159 -160
- package/dist/chart/index.js +9 -10
- package/dist/{chunk-RXZL4NG5.js → chunk-226QDRO3.js} +1 -1
- package/dist/{chunk-DOIU7VJG.js → chunk-2ZJ4DT3M.js} +1 -1
- package/dist/{chunk-XZNU4DUX.cjs → chunk-3NS5C7FB.cjs} +76 -76
- package/dist/{chunk-UTI5IITZ.cjs → chunk-4ZC5QJE2.cjs} +3 -3
- package/dist/{chunk-L3JFOTBQ.js → chunk-5E2Q7ZHI.js} +1 -1
- package/dist/{chunk-6BIDVPED.js → chunk-5JNA6LLY.js} +1 -1
- package/dist/{chunk-RD7RX52G.cjs → chunk-5UEFBM2M.cjs} +207 -18
- package/dist/{chunk-WA44NKPF.js → chunk-62Z5WLRA.js} +1 -1
- package/dist/{chunk-BVRRIW7F.js → chunk-6GRUVGKU.js} +3 -3
- package/dist/{chunk-QARCM66V.js → chunk-6ZZKRH7R.js} +3 -3
- package/dist/{chunk-BP6KSGVD.js → chunk-7272D3K2.js} +4 -6
- package/dist/{chunk-O75V4ZS3.js → chunk-7P6VF3FG.js} +2 -2
- package/dist/{chunk-AU6MWQKZ.js → chunk-ABL7IWFZ.js} +1 -1
- package/dist/{chunk-5RH3VXAK.js → chunk-APX63ILU.js} +4 -100
- package/dist/{chunk-W7L4HUT2.cjs → chunk-CJ6TBL2N.cjs} +16 -16
- package/dist/{chunk-7PT4RJL5.cjs → chunk-EUIDTZNQ.cjs} +111 -113
- package/dist/{chunk-CXXXAZ7H.js → chunk-F6R67I3A.js} +1 -1
- package/dist/{chunk-I7NJPHWV.cjs → chunk-FQPUF2W2.cjs} +35 -606
- package/dist/{chunk-D5KGAO4Z.js → chunk-GCVFEPJG.js} +2 -573
- package/dist/{chunk-LEQKZGQI.js → chunk-GOBOCZZI.js} +1 -1
- package/dist/{chunk-PZP2SZIZ.js → chunk-GYMMNCFT.js} +3 -3
- package/dist/{chunk-NUTMINJZ.cjs → chunk-H7ET2ISK.cjs} +52 -52
- package/dist/chunk-HS6QDWDF.cjs +1029 -0
- package/dist/{chunk-T7KQEMAE.cjs → chunk-HUAISCUX.cjs} +18 -18
- package/dist/{chunk-YGQVCQTG.js → chunk-ILP77UD6.js} +1 -1
- package/dist/{chunk-GHCSC2WP.cjs → chunk-ISIO63Q5.cjs} +21 -15
- package/dist/{chunk-S6OT6CTS.cjs → chunk-IWEVV63O.cjs} +31 -33
- package/dist/{chunk-OFH6Q67U.js → chunk-JA57JIT5.js} +9 -3
- package/dist/{chunk-LP2MCSBE.cjs → chunk-JFHBXNR2.cjs} +88 -88
- package/dist/{chunk-IOFVM3L3.cjs → chunk-JPEHXIB5.cjs} +10 -10
- package/dist/chunk-JSDND7DF.cjs +173 -0
- package/dist/{chunk-36ZTV7WO.js → chunk-L6Y7TSQ4.js} +1 -1
- package/dist/{chunk-KYX7NZ5V.cjs → chunk-LFMKWGFL.cjs} +1 -1
- package/dist/{chunk-V6DT2CDH.js → chunk-M2TPMYJE.js} +1 -1
- package/dist/{chunk-LJZRHVZV.cjs → chunk-M5GLQQWG.cjs} +2 -2
- package/dist/{chunk-JEGJP4OW.js → chunk-MHLU6GRJ.js} +196 -7
- package/dist/{chunk-KMPM5JM5.js → chunk-MONXNVZK.js} +4 -6
- package/dist/chunk-MTKY6K3Q.js +1029 -0
- package/dist/{chunk-MOW3JMNG.cjs → chunk-N76AMOKE.cjs} +42 -42
- package/dist/{chunk-75K3W4D6.cjs → chunk-NKGB64CW.cjs} +16 -16
- package/dist/{chunk-SGPIVHJB.js → chunk-P3K2JCJA.js} +3 -3
- package/dist/chunk-PXDIAYB6.cjs +594 -0
- package/dist/{chunk-UBRJOIR5.js → chunk-QC3OXRE4.js} +9 -9
- package/dist/{chunk-QOBCBGGI.cjs → chunk-QKXO6JPP.cjs} +14 -14
- package/dist/{chunk-WLJZZHUZ.cjs → chunk-QLSGTCYT.cjs} +23 -23
- package/dist/{chunk-7YW7T5TJ.js → chunk-RHPSE2YR.js} +2 -2
- package/dist/{chunk-44BMJJVA.cjs → chunk-RUONPPMC.cjs} +8 -8
- package/dist/{chunk-LJRCU3BJ.cjs → chunk-SABJMH6M.cjs} +150 -15
- package/dist/{chunk-XWOLPNBW.cjs → chunk-SOSBOS5T.cjs} +22 -22
- package/dist/chunk-SZTI6EER.js +13 -0
- package/dist/{chunk-PPFJHTW5.cjs → chunk-TFF2GTGN.cjs} +22 -24
- package/dist/{chunk-2SMMZDMG.cjs → chunk-TLOGFIIV.cjs} +37 -37
- package/dist/chunk-TXFWZ5ZJ.js +594 -0
- package/dist/chunk-U67EN7GG.cjs +13 -0
- package/dist/{chunk-GXAK6Q5J.js → chunk-UFEDHACQ.js} +2 -2
- package/dist/{chunk-GA4EU4P3.cjs → chunk-UXETV2NC.cjs} +4 -4
- package/dist/{chunk-N4DFDI73.js → chunk-WKMUBATU.js} +1 -1
- package/dist/{chunk-3R5P3DVY.cjs → chunk-WRZ6C4TU.cjs} +6 -6
- package/dist/{chunk-EJLRBS5Q.js → chunk-WZOGDKCQ.js} +137 -2
- package/dist/{chunk-6ADHGQ73.js → chunk-YBAPT7NL.js} +2 -4
- package/dist/{chunk-K5DS2JTA.cjs → chunk-Z3BRH4JK.cjs} +6 -6
- package/dist/{chunk-XNZFVYC2.cjs → chunk-ZBCT5MEA.cjs} +7 -7
- package/dist/color/index.cjs +4 -6
- package/dist/color/index.js +7 -9
- package/dist/effects/helpers.d.cts +6 -0
- package/dist/effects/helpers.d.ts +6 -0
- package/dist/effects/index.cjs +62 -60
- package/dist/effects/index.js +5 -3
- package/dist/effects/tools.d.cts +6 -0
- package/dist/effects/tools.d.ts +6 -0
- package/dist/export/index.cjs +7 -8
- package/dist/export/index.js +6 -7
- package/dist/extensions/index.cjs +10 -11
- package/dist/extensions/index.js +9 -10
- package/dist/gradient/index.cjs +33 -34
- package/dist/gradient/index.js +4 -5
- package/dist/image-editor/effects.d.cts +1 -1
- package/dist/image-editor/effects.d.ts +1 -1
- package/dist/image-editor/index.cjs +887 -863
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +69 -45
- package/dist/image-editor/stickers.d.cts +9 -0
- package/dist/image-editor/stickers.d.ts +9 -0
- package/dist/index.cjs +16 -17
- package/dist/index.js +10 -11
- package/dist/paint/index.cjs +6 -4
- package/dist/paint/index.js +21 -19
- package/dist/paint-editor/brushes.d.cts +1 -2
- package/dist/paint-editor/brushes.d.ts +1 -2
- package/dist/paint-editor/index.cjs +2199 -699
- package/dist/paint-editor/index.js +1577 -77
- package/dist/paint-editor/mark-settings.d.cts +104 -0
- package/dist/paint-editor/mark-settings.d.ts +104 -0
- package/dist/paint-editor/procedural.d.cts +2 -75
- package/dist/paint-editor/procedural.d.ts +2 -75
- package/dist/paint-editor/stickers.d.cts +1 -22
- package/dist/paint-editor/stickers.d.ts +1 -22
- package/dist/raster/index.cjs +2 -2
- package/dist/raster/index.js +9 -9
- package/dist/stickers/index.cjs +22 -16
- package/dist/stickers/index.d.cts +1 -1
- package/dist/stickers/index.d.ts +1 -1
- package/dist/stickers/index.js +14 -8
- package/dist/stickers/tools.d.cts +57 -1
- package/dist/stickers/tools.d.ts +57 -1
- package/dist/tokens/index.cjs +3 -4
- package/dist/tokens/index.js +2 -3
- package/dist/typography/index.cjs +7 -8
- package/dist/typography/index.js +2 -3
- package/dist/vector/index.cjs +1011 -977
- package/dist/vector/index.d.cts +1 -0
- package/dist/vector/index.d.ts +1 -0
- package/dist/vector/index.js +47 -13
- package/dist/vector/stickers.d.cts +11 -0
- package/dist/vector/stickers.d.ts +11 -0
- package/dist/video-editor/index.cjs +349 -350
- package/dist/video-editor/index.js +9 -10
- package/package.json +11 -1
- package/skills/pixerate-image-editor/SKILL.md +1 -1
- package/skills/pixerate-stickers/SKILL.md +13 -1
- package/dist/chunk-7AHBW2CQ.cjs +0 -200
- package/dist/chunk-F67XMVDI.js +0 -200
- package/dist/chunk-H4AOUUBE.cjs +0 -2635
- package/dist/chunk-J7T5QZ45.js +0 -2635
- package/dist/chunk-ZEYMKDYS.cjs +0 -269
|
@@ -6,13 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkTFF2GTGNcjs = require('./chunk-TFF2GTGN.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var _chunkRD7RX52Gcjs = require('./chunk-RD7RX52G.cjs');
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
|
|
@@ -23,8 +22,7 @@ var _chunkRD7RX52Gcjs = require('./chunk-RD7RX52G.cjs');
|
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
var _chunk7AHBW2CQcjs = require('./chunk-7AHBW2CQ.cjs');
|
|
25
|
+
var _chunk5UEFBM2Mcjs = require('./chunk-5UEFBM2M.cjs');
|
|
28
26
|
|
|
29
27
|
// src/color/vision.ts
|
|
30
28
|
var CVD = {
|
|
@@ -47,13 +45,13 @@ var CVD = {
|
|
|
47
45
|
var clamp01 = (v) => Math.max(0, Math.min(1, v));
|
|
48
46
|
function simulateColorVision(c, vision) {
|
|
49
47
|
if (vision === "normal") return c;
|
|
50
|
-
const lr =
|
|
51
|
-
const lg =
|
|
52
|
-
const lb =
|
|
48
|
+
const lr = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c.r);
|
|
49
|
+
const lg = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c.g);
|
|
50
|
+
const lb = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c.b);
|
|
53
51
|
const m = CVD[vision];
|
|
54
|
-
const r =
|
|
55
|
-
const g =
|
|
56
|
-
const b =
|
|
52
|
+
const r = _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, clamp01(m[0][0] * lr + m[0][1] * lg + m[0][2] * lb));
|
|
53
|
+
const g = _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, clamp01(m[1][0] * lr + m[1][1] * lg + m[1][2] * lb));
|
|
54
|
+
const b = _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, clamp01(m[2][0] * lr + m[2][1] * lg + m[2][2] * lb));
|
|
57
55
|
return { r, g, b, a: c.a };
|
|
58
56
|
}
|
|
59
57
|
function checkPaletteColors(colors, options = {}) {
|
|
@@ -61,8 +59,8 @@ function checkPaletteColors(colors, options = {}) {
|
|
|
61
59
|
const minDistance = _nullishCoalesce(options.minDistance, () => ( 0.08));
|
|
62
60
|
const minContrast = _nullishCoalesce(options.minContrast, () => ( 1.5));
|
|
63
61
|
const visions = _nullishCoalesce(options.visions, () => ( ["normal", "protanopia", "deuteranopia", "tritanopia"]));
|
|
64
|
-
const parsed = colors.map((c) =>
|
|
65
|
-
const surfaceParsed =
|
|
62
|
+
const parsed = colors.map((c) => _chunk5UEFBM2Mcjs.parseColor.call(void 0, c));
|
|
63
|
+
const surfaceParsed = _chunk5UEFBM2Mcjs.parseColor.call(void 0, surfaceStr);
|
|
66
64
|
const skipped = colors.filter((_, i) => !parsed[i]);
|
|
67
65
|
const issues = [];
|
|
68
66
|
const closest = {};
|
|
@@ -72,7 +70,7 @@ function checkPaletteColors(colors, options = {}) {
|
|
|
72
70
|
for (let a = 0; a < seen.length; a++) {
|
|
73
71
|
for (let b = a + 1; b < seen.length; b++) {
|
|
74
72
|
if (!seen[a] || !seen[b]) continue;
|
|
75
|
-
const distance =
|
|
73
|
+
const distance = _chunkTFF2GTGNcjs.deltaEOK.call(void 0, seen[a], seen[b]);
|
|
76
74
|
if (!best || distance < best.distance) {
|
|
77
75
|
best = {
|
|
78
76
|
a,
|
|
@@ -96,7 +94,7 @@ function checkPaletteColors(colors, options = {}) {
|
|
|
96
94
|
const contrast = colors.map((_, i) => {
|
|
97
95
|
const c = parsed[i];
|
|
98
96
|
if (!c || !surfaceParsed) return null;
|
|
99
|
-
const ratio =
|
|
97
|
+
const ratio = _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, c, surfaceParsed);
|
|
100
98
|
return Math.round(ratio * 100) / 100;
|
|
101
99
|
});
|
|
102
100
|
contrast.forEach((ratio, i) => {
|
|
@@ -157,11 +155,11 @@ function hueToWheel(hue, wheel) {
|
|
|
157
155
|
function colorHarmony(base, kind, options = {}) {
|
|
158
156
|
const wheel = _nullishCoalesce(options.wheel, () => ( "ryb"));
|
|
159
157
|
const rgb = parseHex(base, "base");
|
|
160
|
-
const hsv =
|
|
158
|
+
const hsv = _chunk5UEFBM2Mcjs.rgbToHsv.call(void 0, rgb);
|
|
161
159
|
const start = hueToWheel(hsv.h, wheel);
|
|
162
160
|
const at = (angle) => {
|
|
163
161
|
const a = (angle % 360 + 360) % 360;
|
|
164
|
-
return { color: toHex(
|
|
162
|
+
return { color: toHex(_chunk5UEFBM2Mcjs.hsvToRgb.call(void 0, { ...hsv, h: wheelToHue(a, wheel) })), angle: Math.round(a * 10) / 10 };
|
|
165
163
|
};
|
|
166
164
|
const spread = _nullishCoalesce(options.spread, () => ( 30));
|
|
167
165
|
const offsets = {
|
|
@@ -173,10 +171,10 @@ function colorHarmony(base, kind, options = {}) {
|
|
|
173
171
|
square: [0, 90, 180, 270]
|
|
174
172
|
};
|
|
175
173
|
if (kind === "monochromatic") {
|
|
176
|
-
const hsl =
|
|
174
|
+
const hsl = _chunk5UEFBM2Mcjs.rgbToHsl.call(void 0, rgb);
|
|
177
175
|
const steps = [0, -0.3, -0.15, 0.15, 0.3];
|
|
178
176
|
return steps.map((d) => {
|
|
179
|
-
const c = d === 0 ? rgb :
|
|
177
|
+
const c = d === 0 ? rgb : _chunk5UEFBM2Mcjs.hslToRgb.call(void 0, { ...hsl, l: Math.min(0.97, Math.max(0.03, hsl.l + d)) });
|
|
180
178
|
return { color: toHex(c), angle: Math.round(start * 10) / 10 };
|
|
181
179
|
});
|
|
182
180
|
}
|
|
@@ -187,17 +185,17 @@ function colorHarmony(base, kind, options = {}) {
|
|
|
187
185
|
|
|
188
186
|
// src/color/mix.ts
|
|
189
187
|
function mixColors(from, to, t, options = {}) {
|
|
190
|
-
const c1 =
|
|
191
|
-
const c2 =
|
|
188
|
+
const c1 = _chunk5UEFBM2Mcjs.parseColor.call(void 0, from);
|
|
189
|
+
const c2 = _chunk5UEFBM2Mcjs.parseColor.call(void 0, to);
|
|
192
190
|
if (!c1 || !c2) return null;
|
|
193
191
|
const space = _nullishCoalesce(options.space, () => ( "oklab"));
|
|
194
192
|
const alpha = c1.a + (c2.a - c1.a) * t;
|
|
195
193
|
if (space === "oklab") {
|
|
196
|
-
const lab1 =
|
|
197
|
-
const lab2 =
|
|
194
|
+
const lab1 = _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, c1);
|
|
195
|
+
const lab2 = _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, c2);
|
|
198
196
|
if (alpha <= 1e-9) {
|
|
199
197
|
const lab3 = { l: lab1.l + (lab2.l - lab1.l) * t, a: 0, b: 0, alpha: 0 };
|
|
200
|
-
return
|
|
198
|
+
return _chunkTFF2GTGNcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, lab3));
|
|
201
199
|
}
|
|
202
200
|
const premul = (k) => lab1[k] * lab1.alpha + (lab2[k] * lab2.alpha - lab1[k] * lab1.alpha) * t;
|
|
203
201
|
const lab = {
|
|
@@ -206,11 +204,11 @@ function mixColors(from, to, t, options = {}) {
|
|
|
206
204
|
b: premul("b") / alpha,
|
|
207
205
|
alpha
|
|
208
206
|
};
|
|
209
|
-
return
|
|
207
|
+
return _chunkTFF2GTGNcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, lab));
|
|
210
208
|
}
|
|
211
209
|
if (space === "oklch") {
|
|
212
|
-
const lch1 =
|
|
213
|
-
const lch2 =
|
|
210
|
+
const lch1 = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, c1));
|
|
211
|
+
const lch2 = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, c2));
|
|
214
212
|
let h1 = lch1.h;
|
|
215
213
|
let h2 = lch2.h;
|
|
216
214
|
const diff = h2 - h1;
|
|
@@ -219,41 +217,41 @@ function mixColors(from, to, t, options = {}) {
|
|
|
219
217
|
const h = ((h1 + (h2 - h1) * t) % 360 + 360) % 360;
|
|
220
218
|
if (alpha <= 1e-9) {
|
|
221
219
|
const l2 = lch1.l + (lch2.l - lch1.l) * t;
|
|
222
|
-
return
|
|
220
|
+
return _chunkTFF2GTGNcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: l2, c: 0, h: 0, alpha: 0 })));
|
|
223
221
|
}
|
|
224
222
|
const lPremul = lch1.l * lch1.alpha + (lch2.l * lch2.alpha - lch1.l * lch1.alpha) * t;
|
|
225
223
|
const cPremul = lch1.c * lch1.alpha + (lch2.c * lch2.alpha - lch1.c * lch1.alpha) * t;
|
|
226
224
|
const l = lPremul / alpha;
|
|
227
225
|
const c = cPremul / alpha;
|
|
228
|
-
return
|
|
226
|
+
return _chunkTFF2GTGNcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l, c, h, alpha })));
|
|
229
227
|
}
|
|
230
228
|
if (space === "srgb-linear") {
|
|
231
|
-
const lr1 =
|
|
232
|
-
const lg1 =
|
|
233
|
-
const lb1 =
|
|
234
|
-
const lr2 =
|
|
235
|
-
const lg2 =
|
|
236
|
-
const lb2 =
|
|
229
|
+
const lr1 = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c1.r);
|
|
230
|
+
const lg1 = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c1.g);
|
|
231
|
+
const lb1 = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c1.b);
|
|
232
|
+
const lr2 = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c2.r);
|
|
233
|
+
const lg2 = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c2.g);
|
|
234
|
+
const lb2 = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c2.b);
|
|
237
235
|
if (alpha <= 1e-9) {
|
|
238
|
-
return
|
|
239
|
-
r:
|
|
240
|
-
g:
|
|
241
|
-
b:
|
|
236
|
+
return _chunkTFF2GTGNcjs.formatHex.call(void 0, {
|
|
237
|
+
r: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, lr1 + (lr2 - lr1) * t),
|
|
238
|
+
g: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, lg1 + (lg2 - lg1) * t),
|
|
239
|
+
b: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, lb1 + (lb2 - lb1) * t),
|
|
242
240
|
a: 0
|
|
243
241
|
});
|
|
244
242
|
}
|
|
245
243
|
const premulR2 = lr1 * c1.a + (lr2 * c2.a - lr1 * c1.a) * t;
|
|
246
244
|
const premulG2 = lg1 * c1.a + (lg2 * c2.a - lg1 * c1.a) * t;
|
|
247
245
|
const premulB2 = lb1 * c1.a + (lb2 * c2.a - lb1 * c1.a) * t;
|
|
248
|
-
return
|
|
249
|
-
r:
|
|
250
|
-
g:
|
|
251
|
-
b:
|
|
246
|
+
return _chunkTFF2GTGNcjs.formatHex.call(void 0, {
|
|
247
|
+
r: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, premulR2 / alpha),
|
|
248
|
+
g: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, premulG2 / alpha),
|
|
249
|
+
b: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, premulB2 / alpha),
|
|
252
250
|
a: alpha
|
|
253
251
|
});
|
|
254
252
|
}
|
|
255
253
|
if (alpha <= 1e-9) {
|
|
256
|
-
return
|
|
254
|
+
return _chunkTFF2GTGNcjs.formatHex.call(void 0, {
|
|
257
255
|
r: c1.r + (c2.r - c1.r) * t,
|
|
258
256
|
g: c1.g + (c2.g - c1.g) * t,
|
|
259
257
|
b: c1.b + (c2.b - c1.b) * t,
|
|
@@ -263,7 +261,7 @@ function mixColors(from, to, t, options = {}) {
|
|
|
263
261
|
const premulR = c1.r * c1.a + (c2.r * c2.a - c1.r * c1.a) * t;
|
|
264
262
|
const premulG = c1.g * c1.a + (c2.g * c2.a - c1.g * c1.a) * t;
|
|
265
263
|
const premulB = c1.b * c1.a + (c2.b * c2.a - c1.b * c1.a) * t;
|
|
266
|
-
return
|
|
264
|
+
return _chunkTFF2GTGNcjs.formatHex.call(void 0, {
|
|
267
265
|
r: premulR / alpha,
|
|
268
266
|
g: premulG / alpha,
|
|
269
267
|
b: premulB / alpha,
|
|
@@ -273,9 +271,9 @@ function mixColors(from, to, t, options = {}) {
|
|
|
273
271
|
|
|
274
272
|
// src/color/recent.ts
|
|
275
273
|
function pushRecentColor(list, color, max = 12) {
|
|
276
|
-
const normal =
|
|
274
|
+
const normal = _chunkTFF2GTGNcjs.normalizeColor.call(void 0, color);
|
|
277
275
|
if (!normal) return list.slice();
|
|
278
|
-
const next = [normal, ...list.filter((c) =>
|
|
276
|
+
const next = [normal, ...list.filter((c) => _chunkTFF2GTGNcjs.normalizeColor.call(void 0, c) !== normal)];
|
|
279
277
|
return next.slice(0, max);
|
|
280
278
|
}
|
|
281
279
|
|
|
@@ -291,7 +289,7 @@ function isDualColor(value) {
|
|
|
291
289
|
function parseDualColor(input) {
|
|
292
290
|
if (input === null || input === void 0) return null;
|
|
293
291
|
if (isDualColor(input)) {
|
|
294
|
-
if (
|
|
292
|
+
if (_chunk5UEFBM2Mcjs.parseColor.call(void 0, input.light) === null || _chunk5UEFBM2Mcjs.parseColor.call(void 0, input.dark) === null) {
|
|
295
293
|
return null;
|
|
296
294
|
}
|
|
297
295
|
return { light: input.light, dark: input.dark };
|
|
@@ -325,12 +323,12 @@ function parseDualColor(input) {
|
|
|
325
323
|
const lightPart = inner.slice(0, commaIndex).trim();
|
|
326
324
|
const darkPart = inner.slice(commaIndex + 1).trim();
|
|
327
325
|
if (!lightPart || !darkPart) return null;
|
|
328
|
-
if (
|
|
326
|
+
if (_chunk5UEFBM2Mcjs.parseColor.call(void 0, lightPart) === null || _chunk5UEFBM2Mcjs.parseColor.call(void 0, darkPart) === null) {
|
|
329
327
|
return null;
|
|
330
328
|
}
|
|
331
329
|
return { light: lightPart, dark: darkPart };
|
|
332
330
|
}
|
|
333
|
-
if (
|
|
331
|
+
if (_chunk5UEFBM2Mcjs.parseColor.call(void 0, trimmed) !== null) {
|
|
334
332
|
return { light: trimmed, dark: trimmed };
|
|
335
333
|
}
|
|
336
334
|
}
|
|
@@ -339,8 +337,8 @@ function parseDualColor(input) {
|
|
|
339
337
|
function normalizeDualColor(input) {
|
|
340
338
|
const parsed = parseDualColor(input);
|
|
341
339
|
if (!parsed) return null;
|
|
342
|
-
const light =
|
|
343
|
-
const dark =
|
|
340
|
+
const light = _chunkTFF2GTGNcjs.normalizeColor.call(void 0, parsed.light);
|
|
341
|
+
const dark = _chunkTFF2GTGNcjs.normalizeColor.call(void 0, parsed.dark);
|
|
344
342
|
if (!light || !dark) return null;
|
|
345
343
|
return { light, dark };
|
|
346
344
|
}
|
|
@@ -350,22 +348,22 @@ function resolveColor(value, scheme) {
|
|
|
350
348
|
return scheme === "dark" ? normalized.dark : normalized.light;
|
|
351
349
|
}
|
|
352
350
|
function formatDualColor(value) {
|
|
353
|
-
const light = _nullishCoalesce(
|
|
354
|
-
const dark = _nullishCoalesce(
|
|
351
|
+
const light = _nullishCoalesce(_chunkTFF2GTGNcjs.normalizeColor.call(void 0, value.light), () => ( value.light));
|
|
352
|
+
const dark = _nullishCoalesce(_chunkTFF2GTGNcjs.normalizeColor.call(void 0, value.dark), () => ( value.dark));
|
|
355
353
|
if (light === dark) {
|
|
356
354
|
return light;
|
|
357
355
|
}
|
|
358
356
|
return `light-dark(${light}, ${dark})`;
|
|
359
357
|
}
|
|
360
358
|
function isSameInBothSchemes(value) {
|
|
361
|
-
const light =
|
|
362
|
-
const dark =
|
|
359
|
+
const light = _chunkTFF2GTGNcjs.normalizeColor.call(void 0, value.light);
|
|
360
|
+
const dark = _chunkTFF2GTGNcjs.normalizeColor.call(void 0, value.dark);
|
|
363
361
|
if (!light || !dark) return value.light === value.dark;
|
|
364
362
|
return light === dark;
|
|
365
363
|
}
|
|
366
364
|
function setDualColorSide(value, scheme, color) {
|
|
367
365
|
const base = _nullishCoalesce(normalizeDualColor(value), () => ( { light: "#000000", dark: "#000000" }));
|
|
368
|
-
const normColor = _nullishCoalesce(
|
|
366
|
+
const normColor = _nullishCoalesce(_chunkTFF2GTGNcjs.normalizeColor.call(void 0, color), () => ( color));
|
|
369
367
|
return {
|
|
370
368
|
light: scheme === "light" ? normColor : base.light,
|
|
371
369
|
dark: scheme === "dark" ? normColor : base.dark
|
|
@@ -373,35 +371,35 @@ function setDualColorSide(value, scheme, color) {
|
|
|
373
371
|
}
|
|
374
372
|
function deriveDualColor(color, options) {
|
|
375
373
|
const fromScheme = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.from]), () => ( "light"));
|
|
376
|
-
const baseRgba =
|
|
374
|
+
const baseRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, color);
|
|
377
375
|
if (!baseRgba) {
|
|
378
376
|
throw new Error(`"${String(color)}" is not a colour; pass hex, rgb(), hsl(), oklch() or a CSS colour name.`);
|
|
379
377
|
}
|
|
380
378
|
if (_optionalChain([options, 'optionalAccess', _3 => _3.surfaces]) && !normalizeDualColor(options.surfaces)) {
|
|
381
379
|
throw new Error('The surfaces need a readable light and dark colour, e.g. { light: "#ffffff", dark: "#0b0b0f" }.');
|
|
382
380
|
}
|
|
383
|
-
const baseHex =
|
|
384
|
-
const lab =
|
|
385
|
-
const lch =
|
|
381
|
+
const baseHex = _chunkTFF2GTGNcjs.formatHex.call(void 0, baseRgba);
|
|
382
|
+
const lab = _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, baseRgba);
|
|
383
|
+
const lch = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, lab);
|
|
386
384
|
const startL = clamp(1.05 - lch.l, 0.12, 0.95);
|
|
387
385
|
const targetC = lch.c * 0.9;
|
|
388
386
|
const targetH = lch.h;
|
|
389
387
|
let derivedHex;
|
|
390
388
|
if (_optionalChain([options, 'optionalAccess', _4 => _4.surfaces])) {
|
|
391
389
|
const surfaces = options.surfaces;
|
|
392
|
-
const fromSurfaceRgba =
|
|
390
|
+
const fromSurfaceRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, surfaces[fromScheme]);
|
|
393
391
|
const targetScheme = fromScheme === "light" ? "dark" : "light";
|
|
394
|
-
const targetSurfaceRgba =
|
|
395
|
-
const targetRatio =
|
|
396
|
-
const targetSurfaceL =
|
|
392
|
+
const targetSurfaceRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, surfaces[targetScheme]);
|
|
393
|
+
const targetRatio = _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, baseRgba, fromSurfaceRgba);
|
|
394
|
+
const targetSurfaceL = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, targetSurfaceRgba)).l;
|
|
397
395
|
const preferHigherL = targetSurfaceL < 0.5;
|
|
398
396
|
let bestDiff = Infinity;
|
|
399
397
|
let bestL = startL;
|
|
400
398
|
for (let candL = 0.05; candL <= 0.98; candL += 5e-3) {
|
|
401
|
-
const candRgb =
|
|
402
|
-
|
|
399
|
+
const candRgb = _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0,
|
|
400
|
+
_chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: candL, c: targetC, h: targetH, alpha: baseRgba.a }))
|
|
403
401
|
);
|
|
404
|
-
const ratio =
|
|
402
|
+
const ratio = _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, candRgb, targetSurfaceRgba);
|
|
405
403
|
const diff = Math.abs(ratio - targetRatio);
|
|
406
404
|
const isBetter = diff < bestDiff - 1e-4 || Math.abs(diff - bestDiff) <= 1e-4 && (preferHigherL ? candL > bestL : candL < bestL);
|
|
407
405
|
if (isBetter) {
|
|
@@ -409,15 +407,15 @@ function deriveDualColor(color, options) {
|
|
|
409
407
|
bestL = candL;
|
|
410
408
|
}
|
|
411
409
|
}
|
|
412
|
-
const finalRgba =
|
|
413
|
-
|
|
410
|
+
const finalRgba = _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0,
|
|
411
|
+
_chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: bestL, c: targetC, h: targetH, alpha: baseRgba.a }))
|
|
414
412
|
);
|
|
415
|
-
derivedHex =
|
|
413
|
+
derivedHex = _chunkTFF2GTGNcjs.formatHex.call(void 0, finalRgba);
|
|
416
414
|
} else {
|
|
417
|
-
const finalRgba =
|
|
418
|
-
|
|
415
|
+
const finalRgba = _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0,
|
|
416
|
+
_chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: startL, c: targetC, h: targetH, alpha: baseRgba.a }))
|
|
419
417
|
);
|
|
420
|
-
derivedHex =
|
|
418
|
+
derivedHex = _chunkTFF2GTGNcjs.formatHex.call(void 0, finalRgba);
|
|
421
419
|
}
|
|
422
420
|
return fromScheme === "light" ? { light: baseHex, dark: derivedHex } : { light: derivedHex, dark: baseHex };
|
|
423
421
|
}
|
|
@@ -432,14 +430,14 @@ function checkDualColorContrast(foreground, background, options) {
|
|
|
432
430
|
const lightBgHex = bg.light;
|
|
433
431
|
const darkFgHex = fg.dark;
|
|
434
432
|
const darkBgHex = bg.dark;
|
|
435
|
-
const lightFg =
|
|
436
|
-
const lightBg =
|
|
437
|
-
const darkFg =
|
|
438
|
-
const darkBg =
|
|
439
|
-
const lightRatio = Math.round(
|
|
440
|
-
const darkRatio = Math.round(
|
|
441
|
-
const lightLevel =
|
|
442
|
-
const darkLevel =
|
|
433
|
+
const lightFg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, lightFgHex);
|
|
434
|
+
const lightBg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, lightBgHex);
|
|
435
|
+
const darkFg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, darkFgHex);
|
|
436
|
+
const darkBg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, darkBgHex);
|
|
437
|
+
const lightRatio = Math.round(_chunk5UEFBM2Mcjs.contrastRatio.call(void 0, lightFg, lightBg) * 100) / 100;
|
|
438
|
+
const darkRatio = Math.round(_chunk5UEFBM2Mcjs.contrastRatio.call(void 0, darkFg, darkBg) * 100) / 100;
|
|
439
|
+
const lightLevel = _chunk5UEFBM2Mcjs.contrastLevel.call(void 0, lightRatio, { large });
|
|
440
|
+
const darkLevel = _chunk5UEFBM2Mcjs.contrastLevel.call(void 0, darkRatio, { large });
|
|
443
441
|
const issues = [];
|
|
444
442
|
if (lightLevel === "fail") {
|
|
445
443
|
issues.push(
|
|
@@ -556,7 +554,7 @@ function requireColor(input, name) {
|
|
|
556
554
|
if (typeof input !== "string" || !input.trim()) {
|
|
557
555
|
fail(`"${String(input)}" is not a colour I can read; use hex (#2a4b8d), rgb(), hsl(), oklch() or a CSS colour name.`);
|
|
558
556
|
}
|
|
559
|
-
const parsed =
|
|
557
|
+
const parsed = _chunk5UEFBM2Mcjs.parseColor.call(void 0, input);
|
|
560
558
|
if (!parsed) {
|
|
561
559
|
fail(`"${input}" is not a colour I can read; use hex (#2a4b8d), rgb(), hsl(), oklch() or a CSS colour name.`);
|
|
562
560
|
}
|
|
@@ -569,7 +567,7 @@ function requireDualColor(input, name) {
|
|
|
569
567
|
}
|
|
570
568
|
return parsed;
|
|
571
569
|
}
|
|
572
|
-
var findAccessibleLightness = (fg, bg, large) =>
|
|
570
|
+
var findAccessibleLightness = (fg, bg, large) => _chunkTFF2GTGNcjs.suggestAccessibleForeground.call(void 0, fg, bg, { large });
|
|
573
571
|
function createColorToolProvider(options = {}) {
|
|
574
572
|
const id = _nullishCoalesce(options.id, () => ( "color"));
|
|
575
573
|
const namespace = _nullishCoalesce(options.namespace, () => ( "color"));
|
|
@@ -589,18 +587,18 @@ function createColorToolProvider(options = {}) {
|
|
|
589
587
|
handler: (args) => {
|
|
590
588
|
const { color } = args;
|
|
591
589
|
const rgba = requireColor(color, "color");
|
|
592
|
-
const inGamut =
|
|
593
|
-
const mappedRgba = inGamut ? rgba :
|
|
594
|
-
const hsl =
|
|
595
|
-
const oklab =
|
|
596
|
-
const oklch =
|
|
590
|
+
const inGamut = _chunkTFF2GTGNcjs.inSrgbGamut.call(void 0, rgba);
|
|
591
|
+
const mappedRgba = inGamut ? rgba : _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0, rgba);
|
|
592
|
+
const hsl = _chunk5UEFBM2Mcjs.rgbToHsl.call(void 0, mappedRgba);
|
|
593
|
+
const oklab = _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, rgba);
|
|
594
|
+
const oklch = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, oklab);
|
|
597
595
|
const formats = ["hex", "rgb", "hsl", "oklab", "oklch"];
|
|
598
596
|
const css = {};
|
|
599
597
|
for (const f of formats) {
|
|
600
|
-
css[f] =
|
|
598
|
+
css[f] = _chunkTFF2GTGNcjs.formatColor.call(void 0, rgba, f);
|
|
601
599
|
}
|
|
602
600
|
return {
|
|
603
|
-
hex:
|
|
601
|
+
hex: _chunkTFF2GTGNcjs.formatHex.call(void 0, mappedRgba),
|
|
604
602
|
alpha: Math.round(rgba.a * 1e3) / 1e3,
|
|
605
603
|
rgb: {
|
|
606
604
|
r: Math.round(Math.min(1, Math.max(0, mappedRgba.r)) * 255),
|
|
@@ -619,8 +617,8 @@ function createColorToolProvider(options = {}) {
|
|
|
619
617
|
},
|
|
620
618
|
css,
|
|
621
619
|
inSrgbGamut: inGamut,
|
|
622
|
-
...inGamut ? {} : { gamutMappedHex:
|
|
623
|
-
relativeLuminance: Math.round(
|
|
620
|
+
...inGamut ? {} : { gamutMappedHex: _chunkTFF2GTGNcjs.formatHex.call(void 0, mappedRgba) },
|
|
621
|
+
relativeLuminance: Math.round(_chunk5UEFBM2Mcjs.relativeLuminance.call(void 0, mappedRgba) * 1e4) / 1e4
|
|
624
622
|
};
|
|
625
623
|
}
|
|
626
624
|
};
|
|
@@ -643,11 +641,11 @@ function createColorToolProvider(options = {}) {
|
|
|
643
641
|
const { foreground, background, large = false } = args;
|
|
644
642
|
const fg = requireColor(foreground, "foreground");
|
|
645
643
|
const bg = requireColor(background, "background");
|
|
646
|
-
const ratio = Math.round(
|
|
647
|
-
const level =
|
|
644
|
+
const ratio = Math.round(_chunk5UEFBM2Mcjs.contrastRatio.call(void 0, fg, bg) * 100) / 100;
|
|
645
|
+
const level = _chunk5UEFBM2Mcjs.contrastLevel.call(void 0, ratio, { large });
|
|
648
646
|
const passesAA = level === "AA" || level === "AAA";
|
|
649
647
|
const passesAAA = level === "AAA";
|
|
650
|
-
const suggestion = passesAA ? void 0 :
|
|
648
|
+
const suggestion = passesAA ? void 0 : _chunkTFF2GTGNcjs.suggestAccessibleForeground.call(void 0, fg, bg, { large });
|
|
651
649
|
return {
|
|
652
650
|
ratio,
|
|
653
651
|
level,
|
|
@@ -729,7 +727,7 @@ function createColorToolProvider(options = {}) {
|
|
|
729
727
|
handler: (args) => {
|
|
730
728
|
const { base, kind, wheel = "rgb", spread } = args;
|
|
731
729
|
const rgba = requireColor(base, "base");
|
|
732
|
-
const hex =
|
|
730
|
+
const hex = _chunkTFF2GTGNcjs.formatHex.call(void 0, _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0, rgba));
|
|
733
731
|
if (!HARMONY_KINDS.includes(kind)) {
|
|
734
732
|
fail(`Unknown harmony kind "${kind}"; expected one of ${HARMONY_KINDS.join(", ")}.`);
|
|
735
733
|
}
|
|
@@ -834,10 +832,10 @@ function createColorToolProvider(options = {}) {
|
|
|
834
832
|
from,
|
|
835
833
|
surfaces: keepContrast ? resolvedSurfaces : void 0
|
|
836
834
|
});
|
|
837
|
-
const lightSurfaceRgba =
|
|
838
|
-
const darkSurfaceRgba =
|
|
839
|
-
const lightRatio = Math.round(
|
|
840
|
-
const darkRatio = Math.round(
|
|
835
|
+
const lightSurfaceRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, resolvedSurfaces.light);
|
|
836
|
+
const darkSurfaceRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, resolvedSurfaces.dark);
|
|
837
|
+
const lightRatio = Math.round(_chunk5UEFBM2Mcjs.contrastRatio.call(void 0, _chunk5UEFBM2Mcjs.parseColor.call(void 0, derived.light), lightSurfaceRgba) * 100) / 100;
|
|
838
|
+
const darkRatio = Math.round(_chunk5UEFBM2Mcjs.contrastRatio.call(void 0, _chunk5UEFBM2Mcjs.parseColor.call(void 0, derived.dark), darkSurfaceRgba) * 100) / 100;
|
|
841
839
|
return {
|
|
842
840
|
light: derived.light,
|
|
843
841
|
dark: derived.dark,
|
|
@@ -880,16 +878,16 @@ function createColorToolProvider(options = {}) {
|
|
|
880
878
|
const res = checkDualColorContrast(fg, bg, { large });
|
|
881
879
|
let suggestion;
|
|
882
880
|
if (res.light.level === "fail") {
|
|
883
|
-
const lightFg =
|
|
884
|
-
const lightBg =
|
|
881
|
+
const lightFg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, fg.light);
|
|
882
|
+
const lightBg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, bg.light);
|
|
885
883
|
const fixed = findAccessibleLightness(lightFg, lightBg, large);
|
|
886
884
|
if (fixed) {
|
|
887
885
|
suggestion = { ..._nullishCoalesce(suggestion, () => ( {})), light: fixed };
|
|
888
886
|
}
|
|
889
887
|
}
|
|
890
888
|
if (res.dark.level === "fail") {
|
|
891
|
-
const darkFg =
|
|
892
|
-
const darkBg =
|
|
889
|
+
const darkFg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, fg.dark);
|
|
890
|
+
const darkBg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, bg.dark);
|
|
893
891
|
const fixed = findAccessibleLightness(darkFg, darkBg, large);
|
|
894
892
|
if (fixed) {
|
|
895
893
|
suggestion = { ..._nullishCoalesce(suggestion, () => ( {})), dark: fixed };
|
|
@@ -973,13 +971,13 @@ function pickerStateFromColor(input, previous) {
|
|
|
973
971
|
if (typeof input === "object" && "r" in input && "g" in input && "b" in input) {
|
|
974
972
|
rgba = input;
|
|
975
973
|
} else if (typeof input === "string") {
|
|
976
|
-
rgba =
|
|
974
|
+
rgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, input);
|
|
977
975
|
} else {
|
|
978
976
|
return null;
|
|
979
977
|
}
|
|
980
978
|
if (!rgba) return null;
|
|
981
|
-
const clampedRgba =
|
|
982
|
-
const hsva =
|
|
979
|
+
const clampedRgba = _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0, rgba);
|
|
980
|
+
const hsva = _chunk5UEFBM2Mcjs.rgbToHsv.call(void 0, clampedRgba);
|
|
983
981
|
let h = hsva.h;
|
|
984
982
|
let s = hsva.s;
|
|
985
983
|
const v = hsva.v;
|
|
@@ -1000,13 +998,13 @@ function pickerStateFromColor(input, previous) {
|
|
|
1000
998
|
};
|
|
1001
999
|
}
|
|
1002
1000
|
function pickerStateToHex(state, forceAlpha = false) {
|
|
1003
|
-
const rgba =
|
|
1001
|
+
const rgba = _chunk5UEFBM2Mcjs.hsvToRgb.call(void 0, {
|
|
1004
1002
|
h: state.h,
|
|
1005
1003
|
s: state.s,
|
|
1006
1004
|
v: state.v,
|
|
1007
1005
|
alpha: state.alpha
|
|
1008
1006
|
});
|
|
1009
|
-
const hex =
|
|
1007
|
+
const hex = _chunkTFF2GTGNcjs.formatHex.call(void 0, rgba);
|
|
1010
1008
|
if (forceAlpha && hex.length === 7) {
|
|
1011
1009
|
return hex + "ff";
|
|
1012
1010
|
}
|
|
@@ -1095,13 +1093,13 @@ function pickerKeyStep(state, target, key, shift) {
|
|
|
1095
1093
|
}
|
|
1096
1094
|
}
|
|
1097
1095
|
function pickerAreaBackground(state) {
|
|
1098
|
-
const pureHueRgb =
|
|
1099
|
-
const hueHex =
|
|
1096
|
+
const pureHueRgb = _chunk5UEFBM2Mcjs.hsvToRgb.call(void 0, { h: state.h, s: 1, v: 1, alpha: 1 });
|
|
1097
|
+
const hueHex = _chunkTFF2GTGNcjs.formatHex.call(void 0, pureHueRgb);
|
|
1100
1098
|
return `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${hueHex})`;
|
|
1101
1099
|
}
|
|
1102
1100
|
function pickerAlphaBackground(state) {
|
|
1103
|
-
const opaqueRgb =
|
|
1104
|
-
const hex =
|
|
1101
|
+
const opaqueRgb = _chunk5UEFBM2Mcjs.hsvToRgb.call(void 0, { h: state.h, s: state.s, v: state.v, alpha: 1 });
|
|
1102
|
+
const hex = _chunkTFF2GTGNcjs.formatHex.call(void 0, opaqueRgb);
|
|
1105
1103
|
return `linear-gradient(to right, transparent, ${hex})`;
|
|
1106
1104
|
}
|
|
1107
1105
|
var PICKER_HUE_BACKGROUND = "linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%)";
|