@pixerate/editor 0.73.0 → 0.75.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/THIRD_PARTY_NOTICES.md +3 -0
- package/dist/animation-editor/index.cjs +928 -399
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +130 -3
- package/dist/animation-editor/index.d.ts +130 -3
- package/dist/animation-editor/index.js +819 -290
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/canvas/index.cjs +26 -26
- package/dist/canvas/index.js +2 -2
- package/dist/chart/index.cjs +11 -9
- package/dist/chart/index.cjs.map +1 -1
- package/dist/chart/index.js +5 -3
- package/dist/chart/index.js.map +1 -1
- package/dist/{chunk-3S72F46R.js → chunk-2GFUA4X5.js} +2 -322
- package/dist/chunk-2GFUA4X5.js.map +1 -0
- package/dist/chunk-33AHNSEB.js +323 -0
- package/dist/chunk-33AHNSEB.js.map +1 -0
- package/dist/{chunk-3TLL5OID.js → chunk-4JLB2USO.js} +2 -2
- package/dist/{chunk-NN3JGUSX.cjs → chunk-5PTR7HTL.cjs} +3 -323
- package/dist/chunk-5PTR7HTL.cjs.map +1 -0
- package/dist/{chunk-YJLCBA7V.cjs → chunk-7MD7C6XQ.cjs} +87 -87
- package/dist/{chunk-YJLCBA7V.cjs.map → chunk-7MD7C6XQ.cjs.map} +1 -1
- package/dist/{chunk-4YFMSPBU.js → chunk-EIXXBKUB.js} +6 -4
- package/dist/{chunk-4YFMSPBU.js.map → chunk-EIXXBKUB.js.map} +1 -1
- package/dist/chunk-EMQWJA3G.cjs +323 -0
- package/dist/chunk-EMQWJA3G.cjs.map +1 -0
- package/dist/{chunk-BQQZ6MOI.js → chunk-FGW5OWJ4.js} +6 -4
- package/dist/{chunk-BQQZ6MOI.js.map → chunk-FGW5OWJ4.js.map} +1 -1
- package/dist/{chunk-YZZMX6V7.cjs → chunk-FV5AXTSF.cjs} +11 -9
- package/dist/chunk-FV5AXTSF.cjs.map +1 -0
- package/dist/{chunk-MLREO6J3.cjs → chunk-JEYDXRWQ.cjs} +46 -46
- package/dist/{chunk-MLREO6J3.cjs.map → chunk-JEYDXRWQ.cjs.map} +1 -1
- package/dist/{chunk-7ZSU4MQZ.cjs → chunk-PL3MPFPA.cjs} +10 -8
- package/dist/chunk-PL3MPFPA.cjs.map +1 -0
- package/dist/{chunk-O2UH7LZE.cjs → chunk-XGD3FSNC.cjs} +239 -239
- package/dist/chunk-XGD3FSNC.cjs.map +1 -0
- package/dist/{chunk-VWZB6BCY.js → chunk-Y3NW4VJE.js} +2 -2
- package/dist/{chunk-GTMJ4Y3S.js → chunk-YCSFS3GK.js} +244 -244
- package/dist/{chunk-GTMJ4Y3S.js.map → chunk-YCSFS3GK.js.map} +1 -1
- package/dist/export/index.cjs +4 -3
- package/dist/export/index.cjs.map +1 -1
- package/dist/export/index.js +3 -2
- package/dist/extensions/index.cjs +4 -3
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.js +3 -2
- package/dist/index.cjs +19 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/vector/index.cjs +532 -532
- package/dist/vector/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-3S72F46R.js.map +0 -1
- package/dist/chunk-7ZSU4MQZ.cjs.map +0 -1
- package/dist/chunk-NN3JGUSX.cjs.map +0 -1
- package/dist/chunk-O2UH7LZE.cjs.map +0 -1
- package/dist/chunk-YZZMX6V7.cjs.map +0 -1
- /package/dist/{chunk-3TLL5OID.js.map → chunk-4JLB2USO.js.map} +0 -0
- /package/dist/{chunk-VWZB6BCY.js.map → chunk-Y3NW4VJE.js.map} +0 -0
|
@@ -1,4 +1,240 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3;// src/canvas/
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3;// src/canvas/gradient.ts
|
|
2
|
+
var PIXERATE_BRAND_GRADIENT = {
|
|
3
|
+
type: "linear",
|
|
4
|
+
angle: 135,
|
|
5
|
+
stops: [
|
|
6
|
+
{ offset: 0, color: "#8E51FF" },
|
|
7
|
+
{ offset: 1, color: "#e12afb" }
|
|
8
|
+
]
|
|
9
|
+
};
|
|
10
|
+
var CANVAS_GRADIENT_PRESETS = {
|
|
11
|
+
pixerate: PIXERATE_BRAND_GRADIENT,
|
|
12
|
+
sunset: {
|
|
13
|
+
type: "linear",
|
|
14
|
+
angle: 90,
|
|
15
|
+
stops: [
|
|
16
|
+
{ offset: 0, color: "#f97316" },
|
|
17
|
+
{ offset: 1, color: "#ec4899" }
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
ocean: {
|
|
21
|
+
type: "linear",
|
|
22
|
+
angle: 90,
|
|
23
|
+
stops: [
|
|
24
|
+
{ offset: 0, color: "#06b6d4" },
|
|
25
|
+
{ offset: 1, color: "#3b82f6" }
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
aurora: {
|
|
29
|
+
type: "linear",
|
|
30
|
+
angle: 90,
|
|
31
|
+
stops: [
|
|
32
|
+
{ offset: 0, color: "#10b981" },
|
|
33
|
+
{ offset: 1, color: "#6366f1" }
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
neon: {
|
|
37
|
+
type: "linear",
|
|
38
|
+
angle: 90,
|
|
39
|
+
stops: [
|
|
40
|
+
{ offset: 0, color: "#a855f7" },
|
|
41
|
+
{ offset: 1, color: "#ec4899" }
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
amber: {
|
|
45
|
+
type: "linear",
|
|
46
|
+
angle: 90,
|
|
47
|
+
stops: [
|
|
48
|
+
{ offset: 0, color: "#f59e0b" },
|
|
49
|
+
{ offset: 1, color: "#ef4444" }
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
cosmic: {
|
|
53
|
+
type: "linear",
|
|
54
|
+
angle: 90,
|
|
55
|
+
stops: [
|
|
56
|
+
{ offset: 0, color: "#3b82f6" },
|
|
57
|
+
{ offset: 0.5, color: "#8b5cf6" },
|
|
58
|
+
{ offset: 1, color: "#ec4899" }
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function isCanvasGradient(value) {
|
|
63
|
+
if (!value || typeof value !== "object") return false;
|
|
64
|
+
const val = value;
|
|
65
|
+
if (val.type !== "linear" && val.type !== "radial") return false;
|
|
66
|
+
if (!Array.isArray(val.stops)) return false;
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
function splitCssArgs(str) {
|
|
70
|
+
const parts = [];
|
|
71
|
+
let depth = 0;
|
|
72
|
+
let current = "";
|
|
73
|
+
for (let i = 0; i < str.length; i++) {
|
|
74
|
+
const char = str[i];
|
|
75
|
+
if (char === "(") depth++;
|
|
76
|
+
else if (char === ")") depth = Math.max(0, depth - 1);
|
|
77
|
+
if (char === "," && depth === 0) {
|
|
78
|
+
if (current.trim()) parts.push(current.trim());
|
|
79
|
+
current = "";
|
|
80
|
+
} else {
|
|
81
|
+
current += char;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (current.trim()) parts.push(current.trim());
|
|
85
|
+
return parts;
|
|
86
|
+
}
|
|
87
|
+
function parseCssAngle(val) {
|
|
88
|
+
const trimmed = val.trim().toLowerCase();
|
|
89
|
+
if (trimmed.endsWith("deg")) {
|
|
90
|
+
return parseFloat(trimmed);
|
|
91
|
+
}
|
|
92
|
+
if (trimmed.endsWith("turn")) {
|
|
93
|
+
return parseFloat(trimmed) * 360;
|
|
94
|
+
}
|
|
95
|
+
if (trimmed.endsWith("rad")) {
|
|
96
|
+
return parseFloat(trimmed) * 180 / Math.PI;
|
|
97
|
+
}
|
|
98
|
+
if (trimmed.startsWith("to ")) {
|
|
99
|
+
const dir = trimmed.slice(3).trim();
|
|
100
|
+
if (dir === "bottom") return 180;
|
|
101
|
+
if (dir === "top") return 0;
|
|
102
|
+
if (dir === "right") return 90;
|
|
103
|
+
if (dir === "left") return 270;
|
|
104
|
+
if (dir === "bottom right" || dir === "right bottom") return 135;
|
|
105
|
+
if (dir === "bottom left" || dir === "left bottom") return 225;
|
|
106
|
+
if (dir === "top right" || dir === "right top") return 45;
|
|
107
|
+
if (dir === "top left" || dir === "left top") return 315;
|
|
108
|
+
}
|
|
109
|
+
const n = parseFloat(trimmed);
|
|
110
|
+
return Number.isFinite(n) ? n : 180;
|
|
111
|
+
}
|
|
112
|
+
function parseCssGradient(css) {
|
|
113
|
+
const trimmed = css.trim();
|
|
114
|
+
const linearMatch = trimmed.match(/^linear-gradient\s*\((.*)\)$/is);
|
|
115
|
+
if (linearMatch) {
|
|
116
|
+
const rawArgs = splitCssArgs(linearMatch[1]);
|
|
117
|
+
if (rawArgs.length === 0) return null;
|
|
118
|
+
let angle = 180;
|
|
119
|
+
let stopStartIndex = 0;
|
|
120
|
+
const first = rawArgs[0].trim().toLowerCase();
|
|
121
|
+
if (first.endsWith("deg") || first.endsWith("turn") || first.endsWith("rad") || first.startsWith("to ")) {
|
|
122
|
+
angle = parseCssAngle(first);
|
|
123
|
+
stopStartIndex = 1;
|
|
124
|
+
}
|
|
125
|
+
const stopStrings = rawArgs.slice(stopStartIndex);
|
|
126
|
+
if (stopStrings.length === 0) return null;
|
|
127
|
+
const stops = parseStopStrings(stopStrings);
|
|
128
|
+
if (stops.length === 0) return null;
|
|
129
|
+
return {
|
|
130
|
+
type: "linear",
|
|
131
|
+
angle,
|
|
132
|
+
stops
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const radialMatch = trimmed.match(/^radial-gradient\s*\((.*)\)$/is);
|
|
136
|
+
if (radialMatch) {
|
|
137
|
+
const rawArgs = splitCssArgs(radialMatch[1]);
|
|
138
|
+
if (rawArgs.length === 0) return null;
|
|
139
|
+
let stopStartIndex = 0;
|
|
140
|
+
const first = rawArgs[0].trim().toLowerCase();
|
|
141
|
+
if (first.startsWith("circle") || first.startsWith("ellipse") || first.includes("at ")) {
|
|
142
|
+
stopStartIndex = 1;
|
|
143
|
+
}
|
|
144
|
+
const stopStrings = rawArgs.slice(stopStartIndex);
|
|
145
|
+
if (stopStrings.length === 0) return null;
|
|
146
|
+
const stops = parseStopStrings(stopStrings);
|
|
147
|
+
if (stops.length === 0) return null;
|
|
148
|
+
return {
|
|
149
|
+
type: "radial",
|
|
150
|
+
cx: 0.5,
|
|
151
|
+
cy: 0.5,
|
|
152
|
+
r: 0.5,
|
|
153
|
+
stops
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
function parseStopStrings(stopStrings) {
|
|
159
|
+
const count = stopStrings.length;
|
|
160
|
+
return stopStrings.map((str, idx) => {
|
|
161
|
+
const parts = str.trim().split(/\s+(?=[0-9%])/);
|
|
162
|
+
const color = parts[0];
|
|
163
|
+
let offset = count === 1 ? 0 : idx / (count - 1);
|
|
164
|
+
if (parts.length > 1) {
|
|
165
|
+
const posStr = parts[1].trim();
|
|
166
|
+
if (posStr.endsWith("%")) {
|
|
167
|
+
offset = parseFloat(posStr) / 100;
|
|
168
|
+
} else {
|
|
169
|
+
const val = parseFloat(posStr);
|
|
170
|
+
if (Number.isFinite(val)) offset = val;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
offset: Math.min(1, Math.max(0, offset)),
|
|
175
|
+
color
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function resolveCanvasGradient(value) {
|
|
180
|
+
if (!value) return null;
|
|
181
|
+
if (isCanvasGradient(value)) return value;
|
|
182
|
+
if (typeof value === "string") {
|
|
183
|
+
const lower = value.trim().toLowerCase();
|
|
184
|
+
if (CANVAS_GRADIENT_PRESETS[lower]) {
|
|
185
|
+
return CANVAS_GRADIENT_PRESETS[lower];
|
|
186
|
+
}
|
|
187
|
+
if (lower.startsWith("linear-gradient") || lower.startsWith("radial-gradient")) {
|
|
188
|
+
return parseCssGradient(value);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
function angleToSvgLinearCoords(angleDeg = 180) {
|
|
194
|
+
const rad = (90 - angleDeg) * Math.PI / 180;
|
|
195
|
+
const dx = Math.cos(rad);
|
|
196
|
+
const dy = -Math.sin(rad);
|
|
197
|
+
const half = 0.5;
|
|
198
|
+
return {
|
|
199
|
+
x1: Math.round((half - dx * half) * 1e3) / 1e3,
|
|
200
|
+
y1: Math.round((half - dy * half) * 1e3) / 1e3,
|
|
201
|
+
x2: Math.round((half + dx * half) * 1e3) / 1e3,
|
|
202
|
+
y2: Math.round((half + dy * half) * 1e3) / 1e3
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function gradientToSvgDef(gradient, id) {
|
|
206
|
+
const stops = (_nullishCoalesce(gradient.stops, () => ( []))).map((s) => ({
|
|
207
|
+
offset: `${Math.round(s.offset * 1e3) / 10}%`,
|
|
208
|
+
stopColor: s.color,
|
|
209
|
+
stopOpacity: s.opacity
|
|
210
|
+
}));
|
|
211
|
+
if (gradient.type === "radial") {
|
|
212
|
+
return {
|
|
213
|
+
id,
|
|
214
|
+
type: "radial",
|
|
215
|
+
attrs: {
|
|
216
|
+
cx: gradient.cx !== void 0 ? `${gradient.cx * 100}%` : "50%",
|
|
217
|
+
cy: gradient.cy !== void 0 ? `${gradient.cy * 100}%` : "50%",
|
|
218
|
+
r: gradient.r !== void 0 ? `${gradient.r * 100}%` : "50%"
|
|
219
|
+
},
|
|
220
|
+
stops
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const coords = angleToSvgLinearCoords(_nullishCoalesce(gradient.angle, () => ( 180)));
|
|
224
|
+
return {
|
|
225
|
+
id,
|
|
226
|
+
type: "linear",
|
|
227
|
+
attrs: {
|
|
228
|
+
x1: `${coords.x1 * 100}%`,
|
|
229
|
+
y1: `${coords.y1 * 100}%`,
|
|
230
|
+
x2: `${coords.x2 * 100}%`,
|
|
231
|
+
y2: `${coords.y2 * 100}%`
|
|
232
|
+
},
|
|
233
|
+
stops
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// src/canvas/curveFit.ts
|
|
2
238
|
function formatNumber(value, precision) {
|
|
3
239
|
const factor = 10 ** precision;
|
|
4
240
|
const rounded = Math.round(value * factor) / factor;
|
|
@@ -343,242 +579,6 @@ function fitFreehandPath(points, options = {}) {
|
|
|
343
579
|
return fitPathData(points, { tolerance: 1, ...options, closed: false });
|
|
344
580
|
}
|
|
345
581
|
|
|
346
|
-
// src/canvas/gradient.ts
|
|
347
|
-
var PIXERATE_BRAND_GRADIENT = {
|
|
348
|
-
type: "linear",
|
|
349
|
-
angle: 135,
|
|
350
|
-
stops: [
|
|
351
|
-
{ offset: 0, color: "#8E51FF" },
|
|
352
|
-
{ offset: 1, color: "#e12afb" }
|
|
353
|
-
]
|
|
354
|
-
};
|
|
355
|
-
var CANVAS_GRADIENT_PRESETS = {
|
|
356
|
-
pixerate: PIXERATE_BRAND_GRADIENT,
|
|
357
|
-
sunset: {
|
|
358
|
-
type: "linear",
|
|
359
|
-
angle: 90,
|
|
360
|
-
stops: [
|
|
361
|
-
{ offset: 0, color: "#f97316" },
|
|
362
|
-
{ offset: 1, color: "#ec4899" }
|
|
363
|
-
]
|
|
364
|
-
},
|
|
365
|
-
ocean: {
|
|
366
|
-
type: "linear",
|
|
367
|
-
angle: 90,
|
|
368
|
-
stops: [
|
|
369
|
-
{ offset: 0, color: "#06b6d4" },
|
|
370
|
-
{ offset: 1, color: "#3b82f6" }
|
|
371
|
-
]
|
|
372
|
-
},
|
|
373
|
-
aurora: {
|
|
374
|
-
type: "linear",
|
|
375
|
-
angle: 90,
|
|
376
|
-
stops: [
|
|
377
|
-
{ offset: 0, color: "#10b981" },
|
|
378
|
-
{ offset: 1, color: "#6366f1" }
|
|
379
|
-
]
|
|
380
|
-
},
|
|
381
|
-
neon: {
|
|
382
|
-
type: "linear",
|
|
383
|
-
angle: 90,
|
|
384
|
-
stops: [
|
|
385
|
-
{ offset: 0, color: "#a855f7" },
|
|
386
|
-
{ offset: 1, color: "#ec4899" }
|
|
387
|
-
]
|
|
388
|
-
},
|
|
389
|
-
amber: {
|
|
390
|
-
type: "linear",
|
|
391
|
-
angle: 90,
|
|
392
|
-
stops: [
|
|
393
|
-
{ offset: 0, color: "#f59e0b" },
|
|
394
|
-
{ offset: 1, color: "#ef4444" }
|
|
395
|
-
]
|
|
396
|
-
},
|
|
397
|
-
cosmic: {
|
|
398
|
-
type: "linear",
|
|
399
|
-
angle: 90,
|
|
400
|
-
stops: [
|
|
401
|
-
{ offset: 0, color: "#3b82f6" },
|
|
402
|
-
{ offset: 0.5, color: "#8b5cf6" },
|
|
403
|
-
{ offset: 1, color: "#ec4899" }
|
|
404
|
-
]
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
function isCanvasGradient(value) {
|
|
408
|
-
if (!value || typeof value !== "object") return false;
|
|
409
|
-
const val = value;
|
|
410
|
-
if (val.type !== "linear" && val.type !== "radial") return false;
|
|
411
|
-
if (!Array.isArray(val.stops)) return false;
|
|
412
|
-
return true;
|
|
413
|
-
}
|
|
414
|
-
function splitCssArgs(str) {
|
|
415
|
-
const parts = [];
|
|
416
|
-
let depth = 0;
|
|
417
|
-
let current = "";
|
|
418
|
-
for (let i = 0; i < str.length; i++) {
|
|
419
|
-
const char = str[i];
|
|
420
|
-
if (char === "(") depth++;
|
|
421
|
-
else if (char === ")") depth = Math.max(0, depth - 1);
|
|
422
|
-
if (char === "," && depth === 0) {
|
|
423
|
-
if (current.trim()) parts.push(current.trim());
|
|
424
|
-
current = "";
|
|
425
|
-
} else {
|
|
426
|
-
current += char;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
if (current.trim()) parts.push(current.trim());
|
|
430
|
-
return parts;
|
|
431
|
-
}
|
|
432
|
-
function parseCssAngle(val) {
|
|
433
|
-
const trimmed = val.trim().toLowerCase();
|
|
434
|
-
if (trimmed.endsWith("deg")) {
|
|
435
|
-
return parseFloat(trimmed);
|
|
436
|
-
}
|
|
437
|
-
if (trimmed.endsWith("turn")) {
|
|
438
|
-
return parseFloat(trimmed) * 360;
|
|
439
|
-
}
|
|
440
|
-
if (trimmed.endsWith("rad")) {
|
|
441
|
-
return parseFloat(trimmed) * 180 / Math.PI;
|
|
442
|
-
}
|
|
443
|
-
if (trimmed.startsWith("to ")) {
|
|
444
|
-
const dir = trimmed.slice(3).trim();
|
|
445
|
-
if (dir === "bottom") return 180;
|
|
446
|
-
if (dir === "top") return 0;
|
|
447
|
-
if (dir === "right") return 90;
|
|
448
|
-
if (dir === "left") return 270;
|
|
449
|
-
if (dir === "bottom right" || dir === "right bottom") return 135;
|
|
450
|
-
if (dir === "bottom left" || dir === "left bottom") return 225;
|
|
451
|
-
if (dir === "top right" || dir === "right top") return 45;
|
|
452
|
-
if (dir === "top left" || dir === "left top") return 315;
|
|
453
|
-
}
|
|
454
|
-
const n = parseFloat(trimmed);
|
|
455
|
-
return Number.isFinite(n) ? n : 180;
|
|
456
|
-
}
|
|
457
|
-
function parseCssGradient(css) {
|
|
458
|
-
const trimmed = css.trim();
|
|
459
|
-
const linearMatch = trimmed.match(/^linear-gradient\s*\((.*)\)$/is);
|
|
460
|
-
if (linearMatch) {
|
|
461
|
-
const rawArgs = splitCssArgs(linearMatch[1]);
|
|
462
|
-
if (rawArgs.length === 0) return null;
|
|
463
|
-
let angle = 180;
|
|
464
|
-
let stopStartIndex = 0;
|
|
465
|
-
const first = rawArgs[0].trim().toLowerCase();
|
|
466
|
-
if (first.endsWith("deg") || first.endsWith("turn") || first.endsWith("rad") || first.startsWith("to ")) {
|
|
467
|
-
angle = parseCssAngle(first);
|
|
468
|
-
stopStartIndex = 1;
|
|
469
|
-
}
|
|
470
|
-
const stopStrings = rawArgs.slice(stopStartIndex);
|
|
471
|
-
if (stopStrings.length === 0) return null;
|
|
472
|
-
const stops = parseStopStrings(stopStrings);
|
|
473
|
-
if (stops.length === 0) return null;
|
|
474
|
-
return {
|
|
475
|
-
type: "linear",
|
|
476
|
-
angle,
|
|
477
|
-
stops
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
|
-
const radialMatch = trimmed.match(/^radial-gradient\s*\((.*)\)$/is);
|
|
481
|
-
if (radialMatch) {
|
|
482
|
-
const rawArgs = splitCssArgs(radialMatch[1]);
|
|
483
|
-
if (rawArgs.length === 0) return null;
|
|
484
|
-
let stopStartIndex = 0;
|
|
485
|
-
const first = rawArgs[0].trim().toLowerCase();
|
|
486
|
-
if (first.startsWith("circle") || first.startsWith("ellipse") || first.includes("at ")) {
|
|
487
|
-
stopStartIndex = 1;
|
|
488
|
-
}
|
|
489
|
-
const stopStrings = rawArgs.slice(stopStartIndex);
|
|
490
|
-
if (stopStrings.length === 0) return null;
|
|
491
|
-
const stops = parseStopStrings(stopStrings);
|
|
492
|
-
if (stops.length === 0) return null;
|
|
493
|
-
return {
|
|
494
|
-
type: "radial",
|
|
495
|
-
cx: 0.5,
|
|
496
|
-
cy: 0.5,
|
|
497
|
-
r: 0.5,
|
|
498
|
-
stops
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
return null;
|
|
502
|
-
}
|
|
503
|
-
function parseStopStrings(stopStrings) {
|
|
504
|
-
const count = stopStrings.length;
|
|
505
|
-
return stopStrings.map((str, idx) => {
|
|
506
|
-
const parts = str.trim().split(/\s+(?=[0-9%])/);
|
|
507
|
-
const color = parts[0];
|
|
508
|
-
let offset = count === 1 ? 0 : idx / (count - 1);
|
|
509
|
-
if (parts.length > 1) {
|
|
510
|
-
const posStr = parts[1].trim();
|
|
511
|
-
if (posStr.endsWith("%")) {
|
|
512
|
-
offset = parseFloat(posStr) / 100;
|
|
513
|
-
} else {
|
|
514
|
-
const val = parseFloat(posStr);
|
|
515
|
-
if (Number.isFinite(val)) offset = val;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
return {
|
|
519
|
-
offset: Math.min(1, Math.max(0, offset)),
|
|
520
|
-
color
|
|
521
|
-
};
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
function resolveCanvasGradient(value) {
|
|
525
|
-
if (!value) return null;
|
|
526
|
-
if (isCanvasGradient(value)) return value;
|
|
527
|
-
if (typeof value === "string") {
|
|
528
|
-
const lower = value.trim().toLowerCase();
|
|
529
|
-
if (CANVAS_GRADIENT_PRESETS[lower]) {
|
|
530
|
-
return CANVAS_GRADIENT_PRESETS[lower];
|
|
531
|
-
}
|
|
532
|
-
if (lower.startsWith("linear-gradient") || lower.startsWith("radial-gradient")) {
|
|
533
|
-
return parseCssGradient(value);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
return null;
|
|
537
|
-
}
|
|
538
|
-
function angleToSvgLinearCoords(angleDeg = 180) {
|
|
539
|
-
const rad = (90 - angleDeg) * Math.PI / 180;
|
|
540
|
-
const dx = Math.cos(rad);
|
|
541
|
-
const dy = -Math.sin(rad);
|
|
542
|
-
const half = 0.5;
|
|
543
|
-
return {
|
|
544
|
-
x1: Math.round((half - dx * half) * 1e3) / 1e3,
|
|
545
|
-
y1: Math.round((half - dy * half) * 1e3) / 1e3,
|
|
546
|
-
x2: Math.round((half + dx * half) * 1e3) / 1e3,
|
|
547
|
-
y2: Math.round((half + dy * half) * 1e3) / 1e3
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
function gradientToSvgDef(gradient, id) {
|
|
551
|
-
const stops = (_nullishCoalesce(gradient.stops, () => ( []))).map((s) => ({
|
|
552
|
-
offset: `${Math.round(s.offset * 1e3) / 10}%`,
|
|
553
|
-
stopColor: s.color,
|
|
554
|
-
stopOpacity: s.opacity
|
|
555
|
-
}));
|
|
556
|
-
if (gradient.type === "radial") {
|
|
557
|
-
return {
|
|
558
|
-
id,
|
|
559
|
-
type: "radial",
|
|
560
|
-
attrs: {
|
|
561
|
-
cx: gradient.cx !== void 0 ? `${gradient.cx * 100}%` : "50%",
|
|
562
|
-
cy: gradient.cy !== void 0 ? `${gradient.cy * 100}%` : "50%",
|
|
563
|
-
r: gradient.r !== void 0 ? `${gradient.r * 100}%` : "50%"
|
|
564
|
-
},
|
|
565
|
-
stops
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
const coords = angleToSvgLinearCoords(_nullishCoalesce(gradient.angle, () => ( 180)));
|
|
569
|
-
return {
|
|
570
|
-
id,
|
|
571
|
-
type: "linear",
|
|
572
|
-
attrs: {
|
|
573
|
-
x1: `${coords.x1 * 100}%`,
|
|
574
|
-
y1: `${coords.y1 * 100}%`,
|
|
575
|
-
x2: `${coords.x2 * 100}%`,
|
|
576
|
-
y2: `${coords.y2 * 100}%`
|
|
577
|
-
},
|
|
578
|
-
stops
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
|
|
582
582
|
// src/canvas/shapeGeometry.ts
|
|
583
583
|
var SHAPE_KINDS = ["rect", "ellipse", "polygon", "star", "path"];
|
|
584
584
|
function isShapeDescription(value) {
|
|
@@ -3889,5 +3889,5 @@ function offsetPath(input, distance, options = {}) {
|
|
|
3889
3889
|
|
|
3890
3890
|
|
|
3891
3891
|
|
|
3892
|
-
exports.
|
|
3893
|
-
//# sourceMappingURL=chunk-
|
|
3892
|
+
exports.PIXERATE_BRAND_GRADIENT = PIXERATE_BRAND_GRADIENT; exports.CANVAS_GRADIENT_PRESETS = CANVAS_GRADIENT_PRESETS; exports.isCanvasGradient = isCanvasGradient; exports.parseCssGradient = parseCssGradient; exports.resolveCanvasGradient = resolveCanvasGradient; exports.angleToSvgLinearCoords = angleToSvgLinearCoords; exports.gradientToSvgDef = gradientToSvgDef; exports.cubicPointAt = cubicPointAt; exports.fitCubicWithTangents = fitCubicWithTangents; exports.fitCubicRun = fitCubicRun; exports.fitCubics = fitCubics; exports.isStraightCubic = isStraightCubic; exports.cubicsToPathData = cubicsToPathData; exports.fitPathData = fitPathData; exports.fitFreehandPath = fitFreehandPath; exports.SHAPE_KINDS = SHAPE_KINDS; exports.isShapeDescription = isShapeDescription; exports.parseSvgPath = parseSvgPath; exports.flattenSvgPath = flattenSvgPath; exports.getShapeSvg = getShapeSvg; exports.getShapeRenderData = getShapeRenderData; exports.shapeToPolygon = shapeToPolygon; exports.formatNumber = formatNumber2; exports.simplifyRing = simplifyRing; exports.polygonToSvgPath = polygonToSvgPath; exports.dist = dist2; exports.segmentPoint = segmentPoint; exports.segmentDerivative = segmentDerivative; exports.segmentTangent = segmentTangent; exports.segmentCurvature = segmentCurvature; exports.splitSegment = splitSegment; exports.subSegment = subSegment; exports.segmentExtrema = segmentExtrema; exports.segmentBounds = segmentBounds; exports.segmentLength = segmentLength; exports.segmentParamAtLength = segmentParamAtLength; exports.segmentNearest = segmentNearest; exports.arcToCubics = arcToCubics; exports.toBezierPath = toBezierPath; exports.pathToContours = pathToContours; exports.contoursToPath = contoursToPath; exports.bezierPathToSvg = bezierPathToSvg; exports.transformBezierPath = transformBezierPath; exports.countPathSegments = countPathSegments; exports.closeContour = closeContour; exports.bezierPathBounds = bezierPathBounds; exports.bezierPathSignedArea = bezierPathSignedArea; exports.contourSignedArea = contourSignedArea; exports.bezierPathLength = bezierPathLength; exports.bezierPathPointAtLength = bezierPathPointAtLength; exports.trimSegments = trimSegments; exports.solveMonotone = solveMonotone; exports.windingNumber = windingNumber; exports.pointInBezierPath = pointInBezierPath; exports.distanceToBezierPath = distanceToBezierPath; exports.flattenChain = flattenChain; exports.ringSignedArea = ringSignedArea; exports.polygonArea = polygonArea; exports.multiPolygonArea = multiPolygonArea; exports.multiPolygonBounds = multiPolygonBounds; exports.pointInRings = pointInRings; exports.pointInMultiPolygon = pointInMultiPolygon; exports.polygonBoolean = polygonBoolean; exports.unionPolygons = unionPolygons; exports.intersectPolygons = intersectPolygons; exports.subtractPolygons = subtractPolygons; exports.xorPolygons = xorPolygons; exports.dividePolygons = dividePolygons; exports.PathOpsError = PathOpsError; exports.segmentIntersections = segmentIntersections; exports.pathBoolean = pathBoolean; exports.unitePaths = unitePaths; exports.intersectPaths = intersectPaths; exports.subtractPaths = subtractPaths; exports.excludePaths = excludePaths; exports.dividePaths = dividePaths; exports.normalizeBezierPath = normalizeBezierPath; exports.bezierPathArea = bezierPathArea; exports.planarSplit = planarSplit; exports.pathBooleanSelect = pathBooleanSelect; exports.dashContours = dashContours; exports.strokeOutlineRings = strokeOutlineRings; exports.outlineStroke = outlineStroke; exports.offsetPath = offsetPath;
|
|
3893
|
+
//# sourceMappingURL=chunk-XGD3FSNC.cjs.map
|