@pixerate/editor 0.130.0 → 0.133.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/animation-editor/index.cjs +55 -55
- package/dist/animation-editor/index.d.cts +4 -4
- package/dist/animation-editor/index.d.ts +4 -4
- package/dist/animation-editor/index.js +2 -2
- package/dist/{bezier-CigmusV_.d.ts → bezier-BAGdL89w.d.ts} +1 -1
- package/dist/{bezier-CdoGygwG.d.cts → bezier-DL2wPsFf.d.cts} +1 -1
- package/dist/canvas/index.d.cts +7 -7
- package/dist/canvas/index.d.ts +7 -7
- package/dist/{chunk-MZXQTKUM.cjs → chunk-24ATT2PE.cjs} +10 -6
- package/dist/chunk-24ATT2PE.cjs.map +1 -0
- package/dist/{chunk-AHUYMDYW.js → chunk-2HC4DRF4.js} +10 -6
- package/dist/chunk-2HC4DRF4.js.map +1 -0
- package/dist/{chunk-2PXRKMOH.cjs → chunk-2QKUD3E2.cjs} +36 -36
- package/dist/{chunk-2PXRKMOH.cjs.map → chunk-2QKUD3E2.cjs.map} +1 -1
- package/dist/{chunk-PMHPXCJC.cjs → chunk-65GNHOD4.cjs} +268 -199
- package/dist/chunk-65GNHOD4.cjs.map +1 -0
- package/dist/{chunk-YRZ6NVE3.js → chunk-6CTZAGZ2.js} +235 -4
- package/dist/chunk-6CTZAGZ2.js.map +1 -0
- package/dist/{chunk-ERYGCA72.js → chunk-AOCFL7L7.js} +88 -19
- package/dist/chunk-AOCFL7L7.js.map +1 -0
- package/dist/{chunk-LXGOYRPE.cjs → chunk-F7GGEAO2.cjs} +322 -75
- package/dist/chunk-F7GGEAO2.cjs.map +1 -0
- package/dist/{chunk-PRYMC442.js → chunk-FOBB6AIO.js} +257 -10
- package/dist/chunk-FOBB6AIO.js.map +1 -0
- package/dist/{chunk-W6M7C7R3.cjs → chunk-NVTHUPJ6.cjs} +236 -5
- package/dist/chunk-NVTHUPJ6.cjs.map +1 -0
- package/dist/{chunk-L5OTIYOO.js → chunk-VGZSIXX3.js} +2 -2
- package/dist/effects/index.d.cts +4 -4
- package/dist/effects/index.d.ts +4 -4
- package/dist/{export-CejjC2iI.d.cts → export-BICOEM9d.d.cts} +33 -11
- package/dist/{export-5WDKJqTy.d.cts → export-CeFplzAW.d.cts} +1 -1
- package/dist/{export-B4r8b9Ft.d.ts → export-XnuX8FZ2.d.ts} +33 -11
- package/dist/{export-CU_ARP3A.d.ts → export-zB4HITwP.d.ts} +1 -1
- package/dist/{helpers-CzZu51eI.d.cts → helpers-BuKdqUlM.d.cts} +56 -1
- package/dist/{helpers-X_rycLNJ.d.ts → helpers-cssRNUzH.d.ts} +56 -1
- package/dist/image-editor/index.cjs +1064 -903
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +32 -13
- package/dist/image-editor/index.d.ts +32 -13
- package/dist/image-editor/index.js +180 -19
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +11 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/{opentype-DlRMYcCW.d.cts → opentype-C3iyIFRx.d.cts} +1 -1
- package/dist/{opentype-CrHAsKh3.d.ts → opentype-DG5Lkwul.d.ts} +1 -1
- package/dist/paint/index.cjs +8 -2
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +14 -3
- package/dist/paint/index.d.ts +14 -3
- package/dist/paint/index.js +7 -1
- package/dist/paint-editor/index.cjs +78 -78
- package/dist/paint-editor/index.d.cts +7 -7
- package/dist/paint-editor/index.d.ts +7 -7
- package/dist/paint-editor/index.js +3 -3
- package/dist/{pathfinder-CKfKOVP4.d.cts → pathfinder-8vXik95z.d.cts} +1 -1
- package/dist/{pathfinder-Dlss70hL.d.ts → pathfinder-DKLt4UDG.d.ts} +1 -1
- package/dist/{pool-DDOo0xJH.d.ts → pool-C69pkWRz.d.ts} +1 -1
- package/dist/{pool-DKic69LD.d.cts → pool-VAWcYUbs.d.cts} +1 -1
- package/dist/{rand-pQQ2sJTk.d.ts → rand-BaqEOs1Y.d.ts} +17 -4
- package/dist/{rand-DTXAssW1.d.cts → rand-DdpFzCo6.d.cts} +17 -4
- package/dist/raster/index.cjs +2 -2
- package/dist/raster/index.d.cts +4 -4
- package/dist/raster/index.d.ts +4 -4
- package/dist/raster/index.js +1 -1
- package/dist/{svg-BRaii3pI.d.cts → svg-BThlZmja.d.cts} +2 -2
- package/dist/{svg-BYVZeVo0.d.ts → svg-CEYpvsgH.d.ts} +2 -2
- package/dist/{tools-CtheDLDr.d.cts → tools-CRnZJXXr.d.cts} +1 -1
- package/dist/{tools-D8bZ-7YG.d.ts → tools-CVGqEpO8.d.ts} +1 -1
- package/dist/vector/index.cjs +1493 -1032
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +155 -12
- package/dist/vector/index.d.ts +155 -12
- package/dist/vector/index.js +469 -8
- package/dist/vector/index.js.map +1 -1
- package/dist/video-editor/index.d.cts +4 -4
- package/dist/video-editor/index.d.ts +4 -4
- package/dist/{warp-BFoYxy_s.d.cts → warp-ChcFDdlT.d.cts} +1 -1
- package/dist/{warp-CZVC8pB5.d.ts → warp-mKylbLiF.d.ts} +1 -1
- package/package.json +2 -2
- package/skills/pixerate-image-editor/SKILL.md +7 -3
- package/skills/pixerate-image-editor/references/color-management.md +1 -1
- package/skills/pixerate-image-editor/references/photoshop-files.md +2 -2
- package/skills/pixerate-image-editor/references/retouching.md +12 -3
- package/skills/pixerate-vector/SKILL.md +17 -0
- package/skills/pixerate-vector/references/commands.md +19 -0
- package/dist/chunk-AHUYMDYW.js.map +0 -1
- package/dist/chunk-ERYGCA72.js.map +0 -1
- package/dist/chunk-LXGOYRPE.cjs.map +0 -1
- package/dist/chunk-MZXQTKUM.cjs.map +0 -1
- package/dist/chunk-PMHPXCJC.cjs.map +0 -1
- package/dist/chunk-PRYMC442.js.map +0 -1
- package/dist/chunk-W6M7C7R3.cjs.map +0 -1
- package/dist/chunk-YRZ6NVE3.js.map +0 -1
- /package/dist/{chunk-L5OTIYOO.js.map → chunk-VGZSIXX3.js.map} +0 -0
|
@@ -74,6 +74,7 @@ var VECTOR_BLEND_MODES = [
|
|
|
74
74
|
];
|
|
75
75
|
var VECTOR_HORIZONTAL_RESIZING = ["left", "right", "leftRight", "center", "scale"];
|
|
76
76
|
var VECTOR_VERTICAL_RESIZING = ["top", "bottom", "topBottom", "center", "scale"];
|
|
77
|
+
var VECTOR_LENS_TYPES = ["transparency", "magnify", "fisheye", "brighten", "invert", "tintedGrayscale", "colorAdd", "colorLimit", "heatMap", "wireframe"];
|
|
77
78
|
var VECTOR_CONNECTOR_SIDES = ["auto", "top", "right", "bottom", "left", "center"];
|
|
78
79
|
var VECTOR_CONNECTOR_ROUTES = ["straight", "elbow", "curved"];
|
|
79
80
|
var VECTOR_BLEND_SPACINGS = ["steps", "distance", "smoothColor"];
|
|
@@ -81,6 +82,7 @@ var VECTOR_MASK_TYPES = ["clip", "alpha", "luminance"];
|
|
|
81
82
|
var VECTOR_SYMMETRY_MODES = ["vertical", "horizontal", "dual", "diagonal", "radial"];
|
|
82
83
|
var VECTOR_TEXT_ALIGNS = ["left", "center", "right", "justify"];
|
|
83
84
|
var VECTOR_PATH_TEXT_BASELINES = ["baseline", "ascender", "descender", "center"];
|
|
85
|
+
var VECTOR_PERSPECTIVE_PLANES = ["floor", "left", "right", "side", "front"];
|
|
84
86
|
var VECTOR_CONSTRAINT_KINDS = [
|
|
85
87
|
"coincident",
|
|
86
88
|
"collinear",
|
|
@@ -5772,6 +5774,237 @@ function vectorBevelFaces(path, params, fillRule = "nonzero") {
|
|
|
5772
5774
|
return faces;
|
|
5773
5775
|
}
|
|
5774
5776
|
|
|
5777
|
+
// src/vector/lens.ts
|
|
5778
|
+
function isVectorLens(node) {
|
|
5779
|
+
return !!node && node.type === "path" && !!node.lens && VECTOR_LENS_TYPES.includes(node.lens.type);
|
|
5780
|
+
}
|
|
5781
|
+
var VECTOR_LENS_LABELS = {
|
|
5782
|
+
transparency: "Transparency",
|
|
5783
|
+
magnify: "Magnify",
|
|
5784
|
+
fisheye: "Fish Eye",
|
|
5785
|
+
brighten: "Brighten",
|
|
5786
|
+
invert: "Invert",
|
|
5787
|
+
tintedGrayscale: "Tinted Grayscale",
|
|
5788
|
+
colorAdd: "Color Add",
|
|
5789
|
+
colorLimit: "Color Limit",
|
|
5790
|
+
heatMap: "Heat Map",
|
|
5791
|
+
wireframe: "Wireframe"
|
|
5792
|
+
};
|
|
5793
|
+
var VECTOR_LENS_SPECS = {
|
|
5794
|
+
transparency: { min: 0, max: 100, amount: 50, color: null, unit: "percent see-through" },
|
|
5795
|
+
magnify: { min: 1, max: 20, amount: 2, color: null, unit: "times" },
|
|
5796
|
+
fisheye: { min: -100, max: 100, amount: 50, color: null, unit: "percent, negative pinches" },
|
|
5797
|
+
brighten: { min: -100, max: 100, amount: 40, color: null, unit: "percent, negative darkens" },
|
|
5798
|
+
invert: { min: 0, max: 100, amount: 100, color: null, unit: "percent strength" },
|
|
5799
|
+
tintedGrayscale: { min: 0, max: 100, amount: 100, color: "#b45309", unit: "percent strength" },
|
|
5800
|
+
colorAdd: { min: 0, max: 100, amount: 50, color: "#ff0000", unit: "percent of the colour added" },
|
|
5801
|
+
colorLimit: { min: 0, max: 100, amount: 100, color: "#22c55e", unit: "percent strength" },
|
|
5802
|
+
heatMap: { min: 0, max: 100, amount: 0, color: null, unit: "percent the palette is turned" },
|
|
5803
|
+
wireframe: { min: 0, max: 100, amount: 100, color: "#0f172a", unit: "percent outline opacity" }
|
|
5804
|
+
};
|
|
5805
|
+
function sanitizeVectorLens(value) {
|
|
5806
|
+
if (!value || typeof value !== "object") return null;
|
|
5807
|
+
const r = value;
|
|
5808
|
+
if (typeof r.type !== "string" || !VECTOR_LENS_TYPES.includes(r.type)) return null;
|
|
5809
|
+
const type = r.type;
|
|
5810
|
+
const spec = VECTOR_LENS_SPECS[type];
|
|
5811
|
+
const amount = typeof r.amount === "number" && Number.isFinite(r.amount) ? Math.min(spec.max, Math.max(spec.min, r.amount)) : spec.amount;
|
|
5812
|
+
const out = { type, amount };
|
|
5813
|
+
if (spec.color !== null) out.color = typeof r.color === "string" && parseVectorColor(r.color) ? r.color : spec.color;
|
|
5814
|
+
return out;
|
|
5815
|
+
}
|
|
5816
|
+
var hex22 = (v2) => Math.round(Math.min(1, Math.max(0, v2)) * 255).toString(16).padStart(2, "0");
|
|
5817
|
+
var formatRgba = (c) => c[3] >= 1 ? `#${hex22(c[0])}${hex22(c[1])}${hex22(c[2])}` : `rgba(${Math.round(c[0] * 255)}, ${Math.round(c[1] * 255)}, ${Math.round(c[2] * 255)}, ${Math.round(c[3] * 1e3) / 1e3})`;
|
|
5818
|
+
var luma = (c) => 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
|
|
5819
|
+
var mix = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t, a[3]];
|
|
5820
|
+
var HEAT = [
|
|
5821
|
+
[0, "#1e1b4b"],
|
|
5822
|
+
[0.25, "#2563eb"],
|
|
5823
|
+
[0.5, "#22c55e"],
|
|
5824
|
+
[0.7, "#facc15"],
|
|
5825
|
+
[0.85, "#f97316"],
|
|
5826
|
+
[1, "#dc2626"]
|
|
5827
|
+
];
|
|
5828
|
+
var heatAt = (t) => {
|
|
5829
|
+
const u = (t % 1 + 1) % 1;
|
|
5830
|
+
for (let i = 1; i < HEAT.length; i++) {
|
|
5831
|
+
if (u <= HEAT[i][0]) {
|
|
5832
|
+
const a = parseVectorColor(HEAT[i - 1][1]);
|
|
5833
|
+
const b = parseVectorColor(HEAT[i][1]);
|
|
5834
|
+
const k = (u - HEAT[i - 1][0]) / (HEAT[i][0] - HEAT[i - 1][0]);
|
|
5835
|
+
return [0, 1, 2].map((c) => a[c] + (b[c] - a[c]) * k);
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
return parseVectorColor(HEAT[HEAT.length - 1][1]).slice(0, 3);
|
|
5839
|
+
};
|
|
5840
|
+
function vectorLensColorMap(lens) {
|
|
5841
|
+
const tint = parseVectorColor(lens.color ?? "#000000") ?? [0, 0, 0, 1];
|
|
5842
|
+
const s = Math.min(1, Math.max(0, lens.amount / 100));
|
|
5843
|
+
switch (lens.type) {
|
|
5844
|
+
case "brighten": {
|
|
5845
|
+
const a = Math.min(1, Math.max(-1, lens.amount / 100));
|
|
5846
|
+
return (c) => a >= 0 ? mix(c, [1, 1, 1], a) : mix(c, [0, 0, 0], -a);
|
|
5847
|
+
}
|
|
5848
|
+
case "invert":
|
|
5849
|
+
return (c) => mix(c, [1 - c[0], 1 - c[1], 1 - c[2]], s);
|
|
5850
|
+
case "tintedGrayscale":
|
|
5851
|
+
return (c) => {
|
|
5852
|
+
const l = luma(c);
|
|
5853
|
+
const duo = l < 0.5 ? [tint[0] * 2 * l, tint[1] * 2 * l, tint[2] * 2 * l] : [0, 1, 2].map((k) => tint[k] + (1 - tint[k]) * (2 * l - 1));
|
|
5854
|
+
return mix(c, duo, s);
|
|
5855
|
+
};
|
|
5856
|
+
case "colorAdd":
|
|
5857
|
+
return (c) => [Math.min(1, c[0] + tint[0] * s), Math.min(1, c[1] + tint[1] * s), Math.min(1, c[2] + tint[2] * s), c[3]];
|
|
5858
|
+
case "colorLimit":
|
|
5859
|
+
return (c) => [c[0] * (1 - s + s * tint[0]), c[1] * (1 - s + s * tint[1]), c[2] * (1 - s + s * tint[2]), c[3]];
|
|
5860
|
+
case "heatMap":
|
|
5861
|
+
return (c) => [...heatAt(luma(c) + lens.amount / 100), c[3]];
|
|
5862
|
+
default:
|
|
5863
|
+
return null;
|
|
5864
|
+
}
|
|
5865
|
+
}
|
|
5866
|
+
function mapVectorPaintColors(paint, f) {
|
|
5867
|
+
const one = (color2) => {
|
|
5868
|
+
const c = parseVectorColor(color2);
|
|
5869
|
+
return c ? formatRgba(f(c)) : color2;
|
|
5870
|
+
};
|
|
5871
|
+
if (paint == null || paint === "none") return paint;
|
|
5872
|
+
if (typeof paint === "string") return one(paint);
|
|
5873
|
+
const p = paint;
|
|
5874
|
+
const out = { ...p };
|
|
5875
|
+
if (Array.isArray(p.stops)) out.stops = p.stops.map((s) => ({ ...s, color: one(s.color) }));
|
|
5876
|
+
if (Array.isArray(p.colors)) out.colors = p.colors.map(one);
|
|
5877
|
+
if (Array.isArray(p.points)) out.points = p.points.map((q) => typeof q.color === "string" ? { ...q, color: one(q.color) } : q);
|
|
5878
|
+
return out;
|
|
5879
|
+
}
|
|
5880
|
+
var drawnCache2 = /* @__PURE__ */ new WeakMap();
|
|
5881
|
+
var STYLE_OFF = { effects: void 0, transform: void 0, opacity: void 0, blendMode: void 0, filters: void 0, lens: void 0, lensView: void 0, connector: void 0 };
|
|
5882
|
+
function shapePath(shape, id, path, extra = {}) {
|
|
5883
|
+
const { id: _i, subpaths: _s, booleanOperation: _b, blendStep: _bs, locked: _l, visible: _v, ...style } = shape.source;
|
|
5884
|
+
return { ...style, ...STYLE_OFF, id, type: "path", subpaths: bezierToSubpaths(path), ...shape.opacity < 1 ? { opacity: shape.opacity } : {}, ...extra };
|
|
5885
|
+
}
|
|
5886
|
+
function vectorLensDrawn(node) {
|
|
5887
|
+
const hit = drawnCache2.get(node);
|
|
5888
|
+
if (hit) return hit;
|
|
5889
|
+
const { lens } = node;
|
|
5890
|
+
const own = subpathsToBezier(node.subpaths);
|
|
5891
|
+
const box = bezierPathBounds(own);
|
|
5892
|
+
const children = [];
|
|
5893
|
+
if (box && lens.type !== "transparency") {
|
|
5894
|
+
const c = { x: (box.minX + box.maxX) / 2, y: (box.minY + box.maxY) / 2 };
|
|
5895
|
+
const inv = node.transform && !isIdentityMatrix(node.transform) ? invertMatrix(node.transform) : null;
|
|
5896
|
+
const k = lens.type === "magnify" ? Math.max(1, lens.amount) : 1;
|
|
5897
|
+
const reach = { minX: c.x - (c.x - box.minX) / k, maxX: c.x + (box.maxX - c.x) / k, minY: c.y - (c.y - box.minY) / k, maxY: c.y + (box.maxY - c.y) / k };
|
|
5898
|
+
let map = null;
|
|
5899
|
+
if (lens.type === "magnify") {
|
|
5900
|
+
const m = [k, 0, 0, k, c.x * (1 - k), c.y * (1 - k)];
|
|
5901
|
+
map = (p) => transformBezierPath(p, m);
|
|
5902
|
+
} else if (lens.type === "fisheye") {
|
|
5903
|
+
const a = Math.min(100, Math.max(-100, lens.amount));
|
|
5904
|
+
const gamma = a >= 0 ? 1 / (1 + a / 25) : 1 - a / 25;
|
|
5905
|
+
const rx = Math.max(1e-9, (box.maxX - box.minX) / 2);
|
|
5906
|
+
const ry = Math.max(1e-9, (box.maxY - box.minY) / 2);
|
|
5907
|
+
const warp = (p) => {
|
|
5908
|
+
const dx = (p.x - c.x) / rx;
|
|
5909
|
+
const dy = (p.y - c.y) / ry;
|
|
5910
|
+
const u = Math.hypot(dx, dy);
|
|
5911
|
+
if (u >= 1 || u < 1e-12) return p;
|
|
5912
|
+
const f = u ** gamma / u;
|
|
5913
|
+
return { x: c.x + dx * f * rx, y: c.y + dy * f * ry };
|
|
5914
|
+
};
|
|
5915
|
+
map = (p) => mapBezierPath(p, warp, 0.25);
|
|
5916
|
+
}
|
|
5917
|
+
const recolour = vectorLensColorMap(lens);
|
|
5918
|
+
const wire = lens.type === "wireframe" ? lens.color ?? "#000000" : null;
|
|
5919
|
+
const contents = [];
|
|
5920
|
+
(node.lensView ?? []).forEach((below, i) => {
|
|
5921
|
+
for (const shape of vectorChildAppearanceShapes(below, i)) {
|
|
5922
|
+
const path = inv ? transformBezierPath(shape.path, inv) : shape.path;
|
|
5923
|
+
const b = bezierPathBounds(path);
|
|
5924
|
+
if (!b || b.maxX < reach.minX || b.minX > reach.maxX || b.maxY < reach.minY || b.minY > reach.maxY) continue;
|
|
5925
|
+
const id = `${node.id}~lens${contents.length}`;
|
|
5926
|
+
const changed = map ? map(path) : path;
|
|
5927
|
+
if (wire) {
|
|
5928
|
+
contents.push(shapePath(shape, id, changed, { fill: null, fills: void 0, stroke: wire, strokes: void 0, strokeWidth: 1, strokeAlign: void 0, strokeDasharray: void 0, strokeWidthProfile: void 0, opacity: Math.min(1, Math.max(0, lens.amount / 100)) }));
|
|
5929
|
+
} else if (recolour) {
|
|
5930
|
+
const fills = shape.source.fills?.map((l) => ({ ...l, paint: mapVectorPaintColors(l.paint, recolour) ?? null }));
|
|
5931
|
+
const strokes = shape.source.strokes?.map((l) => ({ ...l, paint: mapVectorPaintColors(l.paint, recolour) ?? null }));
|
|
5932
|
+
contents.push(shapePath(shape, id, changed, { fill: mapVectorPaintColors(shape.source.fill, recolour) ?? null, stroke: mapVectorPaintColors(shape.source.stroke, recolour) ?? null, ...fills ? { fills } : {}, ...strokes ? { strokes } : {} }));
|
|
5933
|
+
} else contents.push(shapePath(shape, id, changed));
|
|
5934
|
+
}
|
|
5935
|
+
});
|
|
5936
|
+
if (contents.length) {
|
|
5937
|
+
const outline = { id: `${node.id}~lens-clip`, type: "path", subpaths: node.subpaths, fill: "#000000", stroke: null, ...node.fillRule ? { fillRule: node.fillRule } : {} };
|
|
5938
|
+
children.push({ id: `${node.id}~lens-view`, type: "group", mask: { type: "clip" }, children: [outline, ...contents] });
|
|
5939
|
+
}
|
|
5940
|
+
}
|
|
5941
|
+
const { lens: _l, lensView: _v, transform: _t, opacity: _o, effects: _e, blendMode: _bm, filters: _f, ...style } = node;
|
|
5942
|
+
const fillOpacity = lens.type === "transparency" ? 1 - Math.min(100, Math.max(0, lens.amount)) / 100 : 0;
|
|
5943
|
+
children.push({ ...style, id: `${node.id}~lens-fill`, stroke: null, strokes: void 0, opacity: fillOpacity });
|
|
5944
|
+
const stroked = (node.strokes?.length ?? 0) > 0 || node.stroke != null && node.stroke !== "none";
|
|
5945
|
+
if (stroked) children.push({ ...style, id: `${node.id}~lens-stroke`, fill: null, fills: void 0 });
|
|
5946
|
+
const out = {
|
|
5947
|
+
id: node.id,
|
|
5948
|
+
type: "group",
|
|
5949
|
+
...node.name !== void 0 ? { name: node.name } : {},
|
|
5950
|
+
...node.transform ? { transform: node.transform } : {},
|
|
5951
|
+
...node.opacity !== void 0 ? { opacity: node.opacity } : {},
|
|
5952
|
+
...node.blendMode ? { blendMode: node.blendMode } : {},
|
|
5953
|
+
...node.filters?.length ? { filters: node.filters } : {},
|
|
5954
|
+
children
|
|
5955
|
+
};
|
|
5956
|
+
drawnCache2.set(node, out);
|
|
5957
|
+
return out;
|
|
5958
|
+
}
|
|
5959
|
+
var sameMatrix = (a, b) => !a && !b || !!a && !!b && a.every((v2, i) => Math.abs(v2 - b[i]) < 1e-12);
|
|
5960
|
+
function sameView(a, b) {
|
|
5961
|
+
if (!a || a.length !== b.length) return false;
|
|
5962
|
+
return a.every((n, i) => {
|
|
5963
|
+
const m = b[i];
|
|
5964
|
+
if (n === m) return true;
|
|
5965
|
+
return n.type === "group" && m.type === "group" && n.id === m.id && n.id.endsWith("~below") && sameMatrix(n.transform, m.transform) && sameView(n.children, m.children);
|
|
5966
|
+
});
|
|
5967
|
+
}
|
|
5968
|
+
function hasLens(nodes) {
|
|
5969
|
+
return nodes.some((n) => isVectorLens(n) || n.type === "group" && hasLens(n.children));
|
|
5970
|
+
}
|
|
5971
|
+
function resolveVectorLenses(doc) {
|
|
5972
|
+
if (!hasLens(doc.nodes)) return doc;
|
|
5973
|
+
let changed = false;
|
|
5974
|
+
const walk = (list, outer, depth) => {
|
|
5975
|
+
const below = outer.slice();
|
|
5976
|
+
const out = list.map((n) => {
|
|
5977
|
+
let next = n;
|
|
5978
|
+
if (isVectorLens(n)) {
|
|
5979
|
+
if (!sameView(n.lensView, below)) next = { ...n, lensView: below.slice() };
|
|
5980
|
+
} else if (n.type === "group" && hasLens(n.children)) {
|
|
5981
|
+
const m = n.transform && !isIdentityMatrix(n.transform) ? invertMatrix(n.transform) : null;
|
|
5982
|
+
const inner = below.length ? m ? [{ id: `${n.id}:${depth}~below`, type: "group", transform: m, children: below.slice() }] : below.slice() : [];
|
|
5983
|
+
const children = walk(n.children, inner, depth + 1);
|
|
5984
|
+
if (children !== n.children) next = { ...n, children };
|
|
5985
|
+
}
|
|
5986
|
+
if (next !== n) changed = true;
|
|
5987
|
+
below.push(next);
|
|
5988
|
+
return next;
|
|
5989
|
+
});
|
|
5990
|
+
return out.some((n, i) => n !== list[i]) ? out : list;
|
|
5991
|
+
};
|
|
5992
|
+
const nodes = walk(doc.nodes, [], 0);
|
|
5993
|
+
return changed ? { ...doc, nodes } : doc;
|
|
5994
|
+
}
|
|
5995
|
+
function stripVectorLensViews(doc) {
|
|
5996
|
+
if (!hasLens(doc.nodes)) return doc;
|
|
5997
|
+
const strip2 = (list) => list.map((n) => {
|
|
5998
|
+
if (n.type === "path" && n.lensView) {
|
|
5999
|
+
const { lensView: _v, ...rest } = n;
|
|
6000
|
+
return rest;
|
|
6001
|
+
}
|
|
6002
|
+
if (n.type === "group") return { ...n, children: strip2(n.children) };
|
|
6003
|
+
return n;
|
|
6004
|
+
});
|
|
6005
|
+
return { ...doc, nodes: strip2(doc.nodes) };
|
|
6006
|
+
}
|
|
6007
|
+
|
|
5775
6008
|
// src/geom/warp.ts
|
|
5776
6009
|
var WARP_STYLES = [
|
|
5777
6010
|
"arc",
|
|
@@ -6750,7 +6983,7 @@ function activeVectorEffects(node) {
|
|
|
6750
6983
|
return node.effects?.filter(isEnabled) ?? [];
|
|
6751
6984
|
}
|
|
6752
6985
|
function hasOwnVectorAppearance(node) {
|
|
6753
|
-
return node.type === "text" || node.type === "instance" || node.type === "group" && !!node.liveBoolean || isVectorFrame(node) || isVectorSymmetryGroup(node) || !!node.effects?.some(isEnabled);
|
|
6986
|
+
return node.type === "text" || node.type === "instance" || node.type === "group" && !!node.liveBoolean || isVectorFrame(node) || isVectorSymmetryGroup(node) || isVectorLens(node) || !!node.effects?.some(isEnabled);
|
|
6754
6987
|
}
|
|
6755
6988
|
var liveCache = /* @__PURE__ */ new WeakMap();
|
|
6756
6989
|
function hasVectorAppearance(node) {
|
|
@@ -7196,8 +7429,8 @@ function expandVectorAppearance(node) {
|
|
|
7196
7429
|
expandCache.set(node, [vectorTextShaperGeneration(), drawn]);
|
|
7197
7430
|
return drawn;
|
|
7198
7431
|
}
|
|
7199
|
-
if (isVectorFrame(node) || isVectorSymmetryGroup(node)) {
|
|
7200
|
-
const drawn = isVectorFrame(node) ? vectorFrameDrawn(node) : vectorSymmetryDrawn(node);
|
|
7432
|
+
if (isVectorFrame(node) || isVectorSymmetryGroup(node) || isVectorLens(node)) {
|
|
7433
|
+
const drawn = isVectorFrame(node) ? vectorFrameDrawn(node) : isVectorLens(node) ? vectorLensDrawn(node) : vectorSymmetryDrawn(node);
|
|
7201
7434
|
const out2 = hasVectorAppearance(drawn) ? expandVectorAppearance(drawn) : drawn;
|
|
7202
7435
|
expandCache.set(node, [vectorTextShaperGeneration(), out2]);
|
|
7203
7436
|
return out2;
|
|
@@ -7912,7 +8145,7 @@ function blendFromAttribute(value, m) {
|
|
|
7912
8145
|
return out;
|
|
7913
8146
|
}
|
|
7914
8147
|
function vectorDocumentToSvg(doc, options = {}) {
|
|
7915
|
-
doc = resolveVectorSymbols(doc);
|
|
8148
|
+
doc = resolveVectorLenses(resolveVectorSymbols(doc));
|
|
7916
8149
|
const precision = options.precision ?? 3;
|
|
7917
8150
|
const prefix = options.idPrefix ?? "vg-";
|
|
7918
8151
|
const pretty = options.pretty !== false;
|
|
@@ -7931,6 +8164,7 @@ function vectorDocumentToSvg(doc, options = {}) {
|
|
|
7931
8164
|
if (node.resizing) out2 += ` data-vector-resizing="${escapeAttr2(JSON.stringify(node.resizing))}"`;
|
|
7932
8165
|
if (node.type === "path" && isVectorShadedPaint(node.fill)) out2 += ` data-vector-shading="${escapeAttr2(JSON.stringify(node.fill))}"`;
|
|
7933
8166
|
if (node.type === "path" && node.connector) out2 += ` data-vector-connector="${escapeAttr2(JSON.stringify(node.connector))}"`;
|
|
8167
|
+
if (node.type === "path" && node.lens) out2 += ` data-vector-lens="${escapeAttr2(JSON.stringify(node.lens))}"`;
|
|
7934
8168
|
const blend = vectorBlendModeCss(node.blendMode);
|
|
7935
8169
|
if (blend) out2 += ` style="mix-blend-mode:${blend}"`;
|
|
7936
8170
|
if (node.filters?.length) {
|
|
@@ -8202,11 +8436,11 @@ function vectorDocumentToSvg(doc, options = {}) {
|
|
|
8202
8436
|
};
|
|
8203
8437
|
lines.push(`${indent(depth)}<g${common(node)} data-vector-live="${escapeAttr2(JSON.stringify(live2))}">`);
|
|
8204
8438
|
lines.push(`${indent(depth + 1)}<g data-vector-part="appearance">`);
|
|
8205
|
-
for (const shape of vectorAppearanceNodes(node)) emit2(shape, depth + 2);
|
|
8439
|
+
for (const shape of isVectorLens(node) ? vectorLensDrawn(node).children : vectorAppearanceNodes(node)) emit2(shape, depth + 2);
|
|
8206
8440
|
lines.push(`${indent(depth + 1)}</g>`);
|
|
8207
8441
|
lines.push(`${indent(depth + 1)}<g data-vector-part="source" display="none">`);
|
|
8208
8442
|
if (node.type === "path") {
|
|
8209
|
-
const { effects: _e, transform: _t, opacity: _o, visible: _v, booleanOperation: _b, blendStep: _s, blendMode: _bm, filters: _f, ...source } = node;
|
|
8443
|
+
const { effects: _e, transform: _t, opacity: _o, visible: _v, booleanOperation: _b, blendStep: _s, blendMode: _bm, filters: _f, lens: _l, lensView: _lv, ...source } = node;
|
|
8210
8444
|
emit2({ ...source, id: `${node.id}~src` }, depth + 2);
|
|
8211
8445
|
} else for (const child of node.children) emit2(child, depth + 2);
|
|
8212
8446
|
lines.push(`${indent(depth + 1)}</g>`);
|
|
@@ -9033,6 +9267,8 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9033
9267
|
if (resizing) meta.resizing = resizing;
|
|
9034
9268
|
const connector = child.attrs["data-vector-connector"] !== void 0 ? sanitizeVectorConnector(parseJson(child.attrs["data-vector-connector"])) : null;
|
|
9035
9269
|
if (connector) meta.connector = connector;
|
|
9270
|
+
const lens = child.attrs["data-vector-lens"] !== void 0 ? sanitizeVectorLens(parseJson(child.attrs["data-vector-lens"])) : null;
|
|
9271
|
+
if (lens) meta.lens = lens;
|
|
9036
9272
|
if (child.name === "g" && child.attrs["data-vector-frame"] !== void 0) {
|
|
9037
9273
|
const node2 = frameGroup(child, s, m, meta);
|
|
9038
9274
|
if (node2) out.push(node2);
|
|
@@ -9811,14 +10047,14 @@ function renamed(node, k) {
|
|
|
9811
10047
|
if (node.type === "group") return { ...node, id, children: node.children.map((c) => renamed(c, k)) };
|
|
9812
10048
|
return { ...node, id };
|
|
9813
10049
|
}
|
|
9814
|
-
var
|
|
10050
|
+
var drawnCache3 = /* @__PURE__ */ new WeakMap();
|
|
9815
10051
|
function vectorSymmetryDrawn(node) {
|
|
9816
|
-
let hit =
|
|
10052
|
+
let hit = drawnCache3.get(node);
|
|
9817
10053
|
if (hit) return hit;
|
|
9818
10054
|
const { symmetry, ...group } = node;
|
|
9819
10055
|
const copies = vectorSymmetryMatrices(symmetry).flatMap((m, k) => node.children.map((c) => ({ ...renamed(transformVectorNode(c, m), k + 1), locked: true })));
|
|
9820
10056
|
hit = { ...group, children: [...node.children, ...copies] };
|
|
9821
|
-
|
|
10057
|
+
drawnCache3.set(node, hit);
|
|
9822
10058
|
return hit;
|
|
9823
10059
|
}
|
|
9824
10060
|
function vectorSymmetryAxes(s, box) {
|
|
@@ -9907,6 +10143,7 @@ export {
|
|
|
9907
10143
|
VECTOR_BLEND_MODES,
|
|
9908
10144
|
VECTOR_HORIZONTAL_RESIZING,
|
|
9909
10145
|
VECTOR_VERTICAL_RESIZING,
|
|
10146
|
+
VECTOR_LENS_TYPES,
|
|
9910
10147
|
VECTOR_CONNECTOR_SIDES,
|
|
9911
10148
|
VECTOR_CONNECTOR_ROUTES,
|
|
9912
10149
|
VECTOR_BLEND_SPACINGS,
|
|
@@ -9914,6 +10151,7 @@ export {
|
|
|
9914
10151
|
VECTOR_SYMMETRY_MODES,
|
|
9915
10152
|
VECTOR_TEXT_ALIGNS,
|
|
9916
10153
|
VECTOR_PATH_TEXT_BASELINES,
|
|
10154
|
+
VECTOR_PERSPECTIVE_PLANES,
|
|
9917
10155
|
VECTOR_CONSTRAINT_KINDS,
|
|
9918
10156
|
VECTOR_TOOLS,
|
|
9919
10157
|
VECTOR_TRANSFORM_HANDLES,
|
|
@@ -10207,6 +10445,15 @@ export {
|
|
|
10207
10445
|
vectorPathRings,
|
|
10208
10446
|
vectorExtrudeFaces,
|
|
10209
10447
|
vectorBevelFaces,
|
|
10448
|
+
isVectorLens,
|
|
10449
|
+
VECTOR_LENS_LABELS,
|
|
10450
|
+
VECTOR_LENS_SPECS,
|
|
10451
|
+
sanitizeVectorLens,
|
|
10452
|
+
vectorLensColorMap,
|
|
10453
|
+
mapVectorPaintColors,
|
|
10454
|
+
vectorLensDrawn,
|
|
10455
|
+
resolveVectorLenses,
|
|
10456
|
+
stripVectorLensViews,
|
|
10210
10457
|
WARP_STYLES,
|
|
10211
10458
|
WARP_STYLE_LABELS,
|
|
10212
10459
|
warpPresetGrid,
|
|
@@ -10335,4 +10582,4 @@ export {
|
|
|
10335
10582
|
lineSubpath,
|
|
10336
10583
|
roundSubpaths
|
|
10337
10584
|
};
|
|
10338
|
-
//# sourceMappingURL=chunk-
|
|
10585
|
+
//# sourceMappingURL=chunk-FOBB6AIO.js.map
|