@pixerate/editor 0.97.0 → 0.99.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 +4 -2
- package/dist/animation-editor/index.cjs +55 -53
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +3 -2
- package/dist/animation-editor/index.d.ts +3 -2
- package/dist/animation-editor/index.js +11 -9
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/chunk-DWGZUSES.cjs +694 -0
- package/dist/chunk-DWGZUSES.cjs.map +1 -0
- package/dist/chunk-GX332W2C.js +181 -0
- package/dist/chunk-GX332W2C.js.map +1 -0
- package/dist/{chunk-7MD7C6XQ.cjs → chunk-JF5PXN7W.cjs} +96 -744
- package/dist/chunk-JF5PXN7W.cjs.map +1 -0
- package/dist/chunk-KKREERP2.js +694 -0
- package/dist/chunk-KKREERP2.js.map +1 -0
- package/dist/chunk-MUUXNRU4.cjs +181 -0
- package/dist/chunk-MUUXNRU4.cjs.map +1 -0
- package/dist/{chunk-OEVSVA6V.js → chunk-WIR377F6.js} +788 -22
- package/dist/chunk-WIR377F6.js.map +1 -0
- package/dist/{chunk-4AB5BHYK.cjs → chunk-WT6ZAWJP.cjs} +788 -22
- package/dist/chunk-WT6ZAWJP.cjs.map +1 -0
- package/dist/{chunk-4JLB2USO.js → chunk-YGZNGDIT.js} +45 -693
- package/dist/chunk-YGZNGDIT.js.map +1 -0
- package/dist/image-editor/index.cjs +1798 -333
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +482 -6
- package/dist/image-editor/index.d.ts +482 -6
- package/dist/image-editor/index.js +1488 -23
- package/dist/image-editor/index.js.map +1 -1
- package/dist/raster/index.cjs +23 -2
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.d.cts +98 -2
- package/dist/raster/index.d.ts +98 -2
- package/dist/raster/index.js +23 -2
- package/dist/{svg-ymShkNtu.d.cts → svg-C9r284x8.d.cts} +6 -9
- package/dist/{svg-Dh17jCyA.d.ts → svg-MVKBqwD4.d.ts} +6 -9
- package/dist/types-CwMPoRMU.d.cts +40 -0
- package/dist/types-CwMPoRMU.d.ts +40 -0
- package/dist/vector/index.cjs +490 -554
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +154 -292
- package/dist/vector/index.d.ts +154 -292
- package/dist/vector/index.js +91 -155
- package/dist/vector/index.js.map +1 -1
- package/dist/warp-B8rAguzs.d.ts +165 -0
- package/dist/warp-nYs2DPrx.d.cts +165 -0
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +49 -3
- package/dist/chunk-4AB5BHYK.cjs.map +0 -1
- package/dist/chunk-4JLB2USO.js.map +0 -1
- package/dist/chunk-7MD7C6XQ.cjs.map +0 -1
- package/dist/chunk-OEVSVA6V.js.map +0 -1
package/dist/vector/index.js
CHANGED
|
@@ -5,7 +5,13 @@ import {
|
|
|
5
5
|
pathfinder
|
|
6
6
|
} from "../chunk-Y3NW4VJE.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
applyHomography,
|
|
9
|
+
homographyFromPoints,
|
|
10
|
+
homographyKeepsQuad,
|
|
11
|
+
orderQuad,
|
|
12
|
+
solve8
|
|
13
|
+
} from "../chunk-GX332W2C.js";
|
|
14
|
+
import {
|
|
9
15
|
KAPPA,
|
|
10
16
|
VECTOR_ARROWHEADS,
|
|
11
17
|
VECTOR_BLEND_SPACINGS,
|
|
@@ -25,16 +31,12 @@ import {
|
|
|
25
31
|
VECTOR_STROKE_GRADIENT_MODES,
|
|
26
32
|
VECTOR_TOOLS,
|
|
27
33
|
VECTOR_TRANSFORM_HANDLES,
|
|
28
|
-
VECTOR_WARP_STYLES,
|
|
29
|
-
VECTOR_WARP_STYLE_LABELS,
|
|
30
34
|
VECTOR_WIDTH_PRESETS,
|
|
31
35
|
VECTOR_WIDTH_PRESET_IDS,
|
|
32
36
|
VECTOR_WIDTH_PROFILE_MAX_POINTS,
|
|
33
37
|
VECTOR_WIDTH_PROFILE_MAX_SCALE,
|
|
34
38
|
VECTOR_WIDTH_SAME_T,
|
|
35
39
|
activeVectorEffects,
|
|
36
|
-
applyMatrix,
|
|
37
|
-
applyMatrixLinear,
|
|
38
40
|
applyVectorCornersAttribute,
|
|
39
41
|
applyVectorEffects,
|
|
40
42
|
applyVectorGradientPatch,
|
|
@@ -60,14 +62,11 @@ import {
|
|
|
60
62
|
createVectorEffect,
|
|
61
63
|
createVectorMorph,
|
|
62
64
|
dashIntervals,
|
|
63
|
-
decomposeRigid,
|
|
64
65
|
defaultVectorGradient,
|
|
65
|
-
dragVectorMeshPoint,
|
|
66
66
|
effectPathLength,
|
|
67
67
|
effectPathVertexCount,
|
|
68
68
|
effectiveStrokeAlign,
|
|
69
69
|
ellipseSubpath,
|
|
70
|
-
evalVectorMesh,
|
|
71
70
|
evaluateVectorPathKeyframes,
|
|
72
71
|
expandVectorAppearance,
|
|
73
72
|
expandVectorAppearances,
|
|
@@ -78,7 +77,6 @@ import {
|
|
|
78
77
|
explicitVectorGradient,
|
|
79
78
|
findVectorNode,
|
|
80
79
|
fitCornerRadius,
|
|
81
|
-
fitVectorMesh,
|
|
82
80
|
foldVectorBooleanOperands,
|
|
83
81
|
generateWidthProfile,
|
|
84
82
|
gradientMidpointRemap,
|
|
@@ -102,23 +100,18 @@ import {
|
|
|
102
100
|
interpolateVectorPaths,
|
|
103
101
|
interpolateVectorStyle,
|
|
104
102
|
interpolateWidthProfiles,
|
|
105
|
-
invertMatrix,
|
|
106
103
|
isCentredVectorGradient,
|
|
107
104
|
isClosedBezierShape,
|
|
108
|
-
isIdentityMatrix,
|
|
109
105
|
isUniformWidthProfile,
|
|
110
|
-
isValidVectorMesh,
|
|
111
106
|
isVectorGradient,
|
|
112
107
|
isVectorLiveBoolean,
|
|
113
108
|
lineSubpath,
|
|
114
109
|
locateVectorNode,
|
|
115
110
|
mapBezierPath,
|
|
116
111
|
mapVectorGradient,
|
|
117
|
-
mapVectorMeshPoints,
|
|
118
112
|
mapVectorPaint,
|
|
119
113
|
mapVectorPoints,
|
|
120
114
|
mapVectorSubpaths,
|
|
121
|
-
matrixRotation,
|
|
122
115
|
mergePaths,
|
|
123
116
|
mirrorWidthProfile,
|
|
124
117
|
morphContourToSubpath,
|
|
@@ -126,7 +119,6 @@ import {
|
|
|
126
119
|
moveAnchorHandle,
|
|
127
120
|
moveVectorGradientHandle,
|
|
128
121
|
moveVectorGradientStop,
|
|
129
|
-
multiplyMatrices,
|
|
130
122
|
nearestSegment,
|
|
131
123
|
nearestStrokePosition,
|
|
132
124
|
nextVectorCornerKind,
|
|
@@ -143,22 +135,17 @@ import {
|
|
|
143
135
|
polygonSubpath,
|
|
144
136
|
pressureWidthProfile,
|
|
145
137
|
puckerBloatPaths,
|
|
146
|
-
pullVectorMesh,
|
|
147
138
|
rectSubpath,
|
|
148
139
|
refineMorphContour,
|
|
149
140
|
removeAnchors,
|
|
150
141
|
removeVectorGradientStop,
|
|
151
|
-
removeVectorMeshSplitU,
|
|
152
|
-
removeVectorMeshSplitV,
|
|
153
142
|
removeWidthPoints,
|
|
154
143
|
repeatPaths,
|
|
155
144
|
resampleGradientStops,
|
|
156
|
-
resizeVectorMesh,
|
|
157
145
|
reverseMorphContour,
|
|
158
146
|
reverseSubpath,
|
|
159
147
|
reverseVectorGradient,
|
|
160
148
|
reverseWidthProfile,
|
|
161
|
-
rotateMatrix,
|
|
162
149
|
roundCornerPaths,
|
|
163
150
|
roundSubpaths,
|
|
164
151
|
samplePlainStops,
|
|
@@ -168,15 +155,12 @@ import {
|
|
|
168
155
|
sanitizeVectorEffects,
|
|
169
156
|
sanitizeVectorGradient,
|
|
170
157
|
sanitizeWidthProfile,
|
|
171
|
-
scaleMatrix,
|
|
172
158
|
setAnchorCorner,
|
|
173
159
|
setSubpathCorners,
|
|
174
160
|
setVectorGradientVector,
|
|
175
161
|
setWidthPoint,
|
|
176
162
|
sortedVectorGradientStops,
|
|
177
163
|
spanVectorGradientStops,
|
|
178
|
-
splitVectorMeshU,
|
|
179
|
-
splitVectorMeshV,
|
|
180
164
|
starSubpath,
|
|
181
165
|
strokePositionPoint,
|
|
182
166
|
strokeWidthProfileOf,
|
|
@@ -190,7 +174,6 @@ import {
|
|
|
190
174
|
transformVectorNode,
|
|
191
175
|
transformVectorPaint,
|
|
192
176
|
translateAnchor,
|
|
193
|
-
translateMatrix,
|
|
194
177
|
trimIntervals,
|
|
195
178
|
trimPaths,
|
|
196
179
|
trimPathsIndividually,
|
|
@@ -227,16 +210,9 @@ import {
|
|
|
227
210
|
vectorGradientSvgDefs,
|
|
228
211
|
vectorGradientTAt,
|
|
229
212
|
vectorGradientUnitsMatrix,
|
|
230
|
-
vectorIdentityMesh,
|
|
231
213
|
vectorLiveBooleanSteps,
|
|
232
|
-
vectorMeshColumns,
|
|
233
|
-
vectorMeshControlBounds,
|
|
234
|
-
vectorMeshEditPoints,
|
|
235
214
|
vectorMeshFromOutline,
|
|
236
|
-
vectorMeshGridCurves,
|
|
237
215
|
vectorMeshOutline,
|
|
238
|
-
vectorMeshParamAt,
|
|
239
|
-
vectorMeshRows,
|
|
240
216
|
vectorNodeBounds,
|
|
241
217
|
vectorNodeEnvelope,
|
|
242
218
|
vectorNodeRotation,
|
|
@@ -255,8 +231,6 @@ import {
|
|
|
255
231
|
vectorStrokeParts,
|
|
256
232
|
vectorStrokeReach,
|
|
257
233
|
vectorStrokeSvgParts,
|
|
258
|
-
vectorWarpPresetGrid,
|
|
259
|
-
vectorWarpPresetMesh,
|
|
260
234
|
vectorWorldMatrix,
|
|
261
235
|
walkVectorNodes,
|
|
262
236
|
widthProfileAt,
|
|
@@ -267,7 +241,7 @@ import {
|
|
|
267
241
|
widthProfileToAttribute,
|
|
268
242
|
wigglePaths,
|
|
269
243
|
zigzagPaths
|
|
270
|
-
} from "../chunk-
|
|
244
|
+
} from "../chunk-YGZNGDIT.js";
|
|
271
245
|
import {
|
|
272
246
|
bezierPathBounds,
|
|
273
247
|
bezierPathToSvg,
|
|
@@ -292,6 +266,43 @@ import {
|
|
|
292
266
|
transformBezierPath,
|
|
293
267
|
windingNumber
|
|
294
268
|
} from "../chunk-YCSFS3GK.js";
|
|
269
|
+
import {
|
|
270
|
+
IDENTITY_MATRIX,
|
|
271
|
+
WARP_STYLES,
|
|
272
|
+
WARP_STYLE_LABELS,
|
|
273
|
+
applyMatrix,
|
|
274
|
+
applyMatrixLinear,
|
|
275
|
+
decomposeRigid,
|
|
276
|
+
dragWarpMeshPoint,
|
|
277
|
+
evalWarpMesh,
|
|
278
|
+
fitWarpMesh,
|
|
279
|
+
identityWarpMesh,
|
|
280
|
+
invertMatrix,
|
|
281
|
+
isIdentityMatrix,
|
|
282
|
+
isValidWarpMesh,
|
|
283
|
+
mapWarpMeshPoints,
|
|
284
|
+
matrixAbout,
|
|
285
|
+
matrixRotation,
|
|
286
|
+
multiplyMatrices,
|
|
287
|
+
pullWarpMesh,
|
|
288
|
+
removeWarpMeshSplitU,
|
|
289
|
+
removeWarpMeshSplitV,
|
|
290
|
+
resizeWarpMesh,
|
|
291
|
+
rotateMatrix,
|
|
292
|
+
scaleMatrix,
|
|
293
|
+
skewMatrix,
|
|
294
|
+
splitWarpMeshU,
|
|
295
|
+
splitWarpMeshV,
|
|
296
|
+
translateMatrix,
|
|
297
|
+
warpMeshColumns,
|
|
298
|
+
warpMeshControlBounds,
|
|
299
|
+
warpMeshEditPoints,
|
|
300
|
+
warpMeshGridCurves,
|
|
301
|
+
warpMeshParamAt,
|
|
302
|
+
warpMeshRows,
|
|
303
|
+
warpPresetGrid,
|
|
304
|
+
warpPresetMesh
|
|
305
|
+
} from "../chunk-KKREERP2.js";
|
|
295
306
|
import {
|
|
296
307
|
HistoryManager
|
|
297
308
|
} from "../chunk-QVZZGT4X.js";
|
|
@@ -598,79 +609,6 @@ function releaseVectorBlend(group, newId) {
|
|
|
598
609
|
return [...keys, group.transform ? transformVectorNode(path, m) : path];
|
|
599
610
|
}
|
|
600
611
|
|
|
601
|
-
// src/vector/perspective.ts
|
|
602
|
-
function solve8(rows) {
|
|
603
|
-
const m = rows.map((r) => r.slice());
|
|
604
|
-
for (let col = 0; col < 8; col++) {
|
|
605
|
-
let pivot = col;
|
|
606
|
-
for (let r = col + 1; r < 8; r++) if (Math.abs(m[r][col]) > Math.abs(m[pivot][col])) pivot = r;
|
|
607
|
-
if (!(Math.abs(m[pivot][col]) >= 1e-12)) return null;
|
|
608
|
-
[m[col], m[pivot]] = [m[pivot], m[col]];
|
|
609
|
-
const p = m[col];
|
|
610
|
-
for (let r = 0; r < 8; r++) {
|
|
611
|
-
if (r === col) continue;
|
|
612
|
-
const f = m[r][col] / p[col];
|
|
613
|
-
if (f !== 0) for (let k = 0; k < 9; k++) m[r][k] -= f * p[k];
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
const out = [];
|
|
617
|
-
for (let i = 0; i < 8; i++) {
|
|
618
|
-
const v = m[i][8] / m[i][i];
|
|
619
|
-
if (!Number.isFinite(v)) return null;
|
|
620
|
-
out.push(v);
|
|
621
|
-
}
|
|
622
|
-
return out;
|
|
623
|
-
}
|
|
624
|
-
function applyVectorHomography(h, p) {
|
|
625
|
-
const w = h[6] * p.x + h[7] * p.y + h[8];
|
|
626
|
-
if (!Number.isFinite(w) || Math.abs(w) < 1e-12) return null;
|
|
627
|
-
const x = (h[0] * p.x + h[1] * p.y + h[2]) / w;
|
|
628
|
-
const y = (h[3] * p.x + h[4] * p.y + h[5]) / w;
|
|
629
|
-
return Number.isFinite(x) && Number.isFinite(y) ? { x, y } : null;
|
|
630
|
-
}
|
|
631
|
-
var finite = (p) => Number.isFinite(p.x) && Number.isFinite(p.y);
|
|
632
|
-
function vectorHomography(from, to) {
|
|
633
|
-
if (from.length !== 4 || to.length !== 4 || ![...from, ...to].every(finite)) return null;
|
|
634
|
-
const rows = [];
|
|
635
|
-
for (let i = 0; i < 4; i++) {
|
|
636
|
-
const { x, y } = from[i];
|
|
637
|
-
const { x: u, y: v } = to[i];
|
|
638
|
-
rows.push([x, y, 1, 0, 0, 0, -u * x, -u * y, u]);
|
|
639
|
-
rows.push([0, 0, 0, x, y, 1, -v * x, -v * y, v]);
|
|
640
|
-
}
|
|
641
|
-
const h = solve8(rows);
|
|
642
|
-
if (!h) return null;
|
|
643
|
-
const out = [h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7], 1];
|
|
644
|
-
for (let i = 0; i < 4; i++) {
|
|
645
|
-
const r = applyVectorHomography(out, from[i]);
|
|
646
|
-
const q = to[i];
|
|
647
|
-
const scale = 1 + Math.max(Math.abs(q.x), Math.abs(q.y));
|
|
648
|
-
if (!r || Math.abs(r.x - q.x) > 1e-6 * scale || Math.abs(r.y - q.y) > 1e-6 * scale) return null;
|
|
649
|
-
}
|
|
650
|
-
return out;
|
|
651
|
-
}
|
|
652
|
-
function vectorHomographyKeepsQuad(h, quad) {
|
|
653
|
-
const ws = quad.map((p) => h[6] * p.x + h[7] * p.y + h[8]);
|
|
654
|
-
return ws.every((w) => w > 1e-9) || ws.every((w) => w < -1e-9);
|
|
655
|
-
}
|
|
656
|
-
function orderVectorQuad(points) {
|
|
657
|
-
if (points.length !== 4 || !points.every(finite)) return null;
|
|
658
|
-
const cx = points.reduce((s, p) => s + p.x, 0) / 4;
|
|
659
|
-
const cy = points.reduce((s, p) => s + p.y, 0) / 4;
|
|
660
|
-
const q = points.slice().sort((a, b) => Math.atan2(a.y - cy, a.x - cx) - Math.atan2(b.y - cy, b.x - cx));
|
|
661
|
-
let first = 0;
|
|
662
|
-
for (let i = 1; i < 4; i++) if (q[i].x + q[i].y < q[first].x + q[first].y) first = i;
|
|
663
|
-
const ordered = [...q.slice(first), ...q.slice(0, first)];
|
|
664
|
-
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
|
665
|
-
const turns = ordered.map((_, i) => cross(ordered[i], ordered[(i + 1) % 4], ordered[(i + 2) % 4]));
|
|
666
|
-
const area = turns.reduce((s, t) => s + t, 0) / 2;
|
|
667
|
-
const xs = ordered.map((p) => p.x);
|
|
668
|
-
const ys = ordered.map((p) => p.y);
|
|
669
|
-
const size = Math.max(Math.max(...xs) - Math.min(...xs), Math.max(...ys) - Math.min(...ys));
|
|
670
|
-
const convex = turns.every((t) => t > 1e-9 * size * size);
|
|
671
|
-
return convex && area > 1e-6 * size * size ? ordered : null;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
612
|
// src/vector/distort.ts
|
|
675
613
|
var VECTOR_DISTORT_TOLERANCE = 0.05;
|
|
676
614
|
var CORNER_INDEX = { nw: 0, ne: 1, se: 2, sw: 3 };
|
|
@@ -705,7 +643,7 @@ function vectorDistortQuad(b, handle, d, mode = "distort") {
|
|
|
705
643
|
if (side) for (const k of side) q[k] = { x: q[k].x + d.x, y: q[k].y + d.y };
|
|
706
644
|
return q;
|
|
707
645
|
}
|
|
708
|
-
var about = (o, m) =>
|
|
646
|
+
var about = (o, m) => matrixAbout(m, o);
|
|
709
647
|
function vectorShearForSide(b, handle, d, fromCenter = false) {
|
|
710
648
|
const center = { x: b.x + b.width / 2, y: b.y + b.height / 2 };
|
|
711
649
|
if (handle === "n" || handle === "s") {
|
|
@@ -721,18 +659,16 @@ function vectorShearForSide(b, handle, d, fromCenter = false) {
|
|
|
721
659
|
return [1, 0, 0, 1, 0, 0];
|
|
722
660
|
}
|
|
723
661
|
function vectorSkewMatrix(ax, ay, origin = { x: 0, y: 0 }) {
|
|
724
|
-
|
|
725
|
-
const ty = Math.tan(ay * Math.PI / 180);
|
|
726
|
-
return about(origin, [1, ty, tx, 1, 0, 0]);
|
|
662
|
+
return skewMatrix(ax, ay, origin);
|
|
727
663
|
}
|
|
728
664
|
function mapEffects(node, f) {
|
|
729
665
|
if (!node.effects?.length) return void 0;
|
|
730
666
|
return node.effects.map((e) => {
|
|
731
667
|
if (e.type !== "envelope") return e;
|
|
732
|
-
if (e.params.style === "mesh") return e.params.mesh ? { ...e, params: { ...e.params, mesh:
|
|
668
|
+
if (e.params.style === "mesh") return e.params.mesh ? { ...e, params: { ...e.params, mesh: mapWarpMeshPoints(e.params.mesh, f) } } : e;
|
|
733
669
|
const bounds = vectorEffectInputBounds(node, e.id);
|
|
734
670
|
if (!bounds || !vectorEnvelopeMap(e.params, bounds)) return e;
|
|
735
|
-
return { ...e, params: { ...e.params, style: "mesh", mesh:
|
|
671
|
+
return { ...e, params: { ...e.params, style: "mesh", mesh: mapWarpMeshPoints(vectorEnvelopeMesh(e.params, bounds), f) } };
|
|
736
672
|
});
|
|
737
673
|
}
|
|
738
674
|
function distortVectorNode(node, parentToDoc, f, tolerance = VECTOR_DISTORT_TOLERANCE) {
|
|
@@ -4424,10 +4360,10 @@ var VectorEditorController = class {
|
|
|
4424
4360
|
if (!frame) return { ok: false, message: "Nothing is selected." };
|
|
4425
4361
|
if (!(frame.width > 0 && frame.height > 0)) return { ok: false, message: "The selection has no area to distort." };
|
|
4426
4362
|
const from = this.frameCorners(frame);
|
|
4427
|
-
const h = corners2.length === 4 ?
|
|
4428
|
-
if (!h || !
|
|
4363
|
+
const h = corners2.length === 4 ? homographyFromPoints(from, corners2) : null;
|
|
4364
|
+
if (!h || !homographyKeepsQuad(h, from)) return { ok: false, message: "The four corners must make a convex quadrilateral, clockwise from the top left." };
|
|
4429
4365
|
this.change("Distort", () => {
|
|
4430
|
-
this.doc = this.distorted(this.doc, new Set(ids), (p) =>
|
|
4366
|
+
this.doc = this.distorted(this.doc, new Set(ids), (p) => applyHomography(h, p) ?? p, options.tolerance);
|
|
4431
4367
|
});
|
|
4432
4368
|
return { ok: true };
|
|
4433
4369
|
}
|
|
@@ -4465,10 +4401,10 @@ var VectorEditorController = class {
|
|
|
4465
4401
|
const mode = corner && input.mod && input.alt && input.shift ? "perspective" : "distort";
|
|
4466
4402
|
const rot = rotateMatrix(angle);
|
|
4467
4403
|
const quad = vectorDistortQuad(drag.frame, drag.handle, d, mode).map((c) => angle ? applyMatrix(rot, c) : c);
|
|
4468
|
-
const h =
|
|
4469
|
-
if (!h || !
|
|
4404
|
+
const h = homographyFromPoints(from, quad);
|
|
4405
|
+
if (!h || !homographyKeepsQuad(h, from)) return;
|
|
4470
4406
|
drag.op = mode === "perspective" ? "Perspective" : "Distort";
|
|
4471
|
-
this.doc = this.distorted(drag.base, ids, (pt) =>
|
|
4407
|
+
this.doc = this.distorted(drag.base, ids, (pt) => applyHomography(h, pt) ?? pt);
|
|
4472
4408
|
this.interaction = { type: "distort", mode, corners: quad };
|
|
4473
4409
|
this.notify(true);
|
|
4474
4410
|
}
|
|
@@ -4486,7 +4422,7 @@ var VectorEditorController = class {
|
|
|
4486
4422
|
if (!frame) return patch;
|
|
4487
4423
|
const rows = typeof patch.rows === "number" ? patch.rows : current.params.rows;
|
|
4488
4424
|
const columns = typeof patch.columns === "number" ? patch.columns : current.params.columns;
|
|
4489
|
-
return { ...patch, mesh:
|
|
4425
|
+
return { ...patch, mesh: resizeWarpMesh(frame.mesh, columns, rows) };
|
|
4490
4426
|
}
|
|
4491
4427
|
/**
|
|
4492
4428
|
* Gives the selected (or given) nodes an envelope distortion, or changes the one they have: a
|
|
@@ -4629,7 +4565,7 @@ var VectorEditorController = class {
|
|
|
4629
4565
|
const target = this.envelopeTarget();
|
|
4630
4566
|
if (!target) return null;
|
|
4631
4567
|
const { mesh } = target.frame;
|
|
4632
|
-
const pts =
|
|
4568
|
+
const pts = warpMeshEditPoints(mesh);
|
|
4633
4569
|
let best = null;
|
|
4634
4570
|
let bestD = Infinity;
|
|
4635
4571
|
for (const index of [...pts.handles.map((h) => h.index), ...pts.anchors]) {
|
|
@@ -4642,7 +4578,7 @@ var VectorEditorController = class {
|
|
|
4642
4578
|
}
|
|
4643
4579
|
if (best !== null) return { target, index: best, s: 0, t: 0 };
|
|
4644
4580
|
const local = applyMatrix(invertMatrix(target.world), p);
|
|
4645
|
-
const at =
|
|
4581
|
+
const at = warpMeshParamAt(mesh, local);
|
|
4646
4582
|
if (at.distance > this.tolerance()) return null;
|
|
4647
4583
|
return { target, index: null, s: at.s, t: at.t };
|
|
4648
4584
|
}
|
|
@@ -4678,7 +4614,7 @@ var VectorEditorController = class {
|
|
|
4678
4614
|
const d = { x: local.x - drag.start.x, y: local.y - drag.start.y };
|
|
4679
4615
|
if (!drag.moved && Math.hypot(d.x, d.y) * this.viewport.zoom < 1) return;
|
|
4680
4616
|
drag.moved = true;
|
|
4681
|
-
const mesh = drag.index !== null ?
|
|
4617
|
+
const mesh = drag.index !== null ? dragWarpMeshPoint(drag.base, drag.index, d) : pullWarpMesh(drag.base, drag.s, drag.t, d);
|
|
4682
4618
|
const nodes = mapTree(drag.baseDoc.nodes, (n) => {
|
|
4683
4619
|
if (n.id !== drag.nodeId) return n;
|
|
4684
4620
|
const effects = (n.effects ?? []).map(
|
|
@@ -7617,14 +7553,14 @@ function envelopeOverlay(state) {
|
|
|
7617
7553
|
const m = multiplyMatrices(target.world, [v.zoom, 0, 0, v.zoom, v.x, v.y]);
|
|
7618
7554
|
const sc = (p) => ({ x: fmt2(m[0] * p.x + m[2] * p.y + m[4]), y: fmt2(m[1] * p.x + m[3] * p.y + m[5]) });
|
|
7619
7555
|
const { mesh } = target.frame;
|
|
7620
|
-
const grid =
|
|
7556
|
+
const grid = warpMeshGridCurves(mesh).map((c) => {
|
|
7621
7557
|
const [a, b, cc, d] = c.map(sc);
|
|
7622
7558
|
return `M${a.x} ${a.y}C${b.x} ${b.y} ${cc.x} ${cc.y} ${d.x} ${d.y}`;
|
|
7623
7559
|
}).join("");
|
|
7624
7560
|
const hover = state.hover?.envelope?.nodeId === target.node.id ? state.hover.envelope.index : void 0;
|
|
7625
7561
|
const it = state.interaction;
|
|
7626
7562
|
const active = it?.type === "envelope" && it.nodeId === target.node.id ? it.index : void 0;
|
|
7627
|
-
const pts =
|
|
7563
|
+
const pts = warpMeshEditPoints(mesh);
|
|
7628
7564
|
return {
|
|
7629
7565
|
nodeId: target.node.id,
|
|
7630
7566
|
grid,
|
|
@@ -7636,7 +7572,7 @@ function envelopeOverlay(state) {
|
|
|
7636
7572
|
};
|
|
7637
7573
|
}
|
|
7638
7574
|
var VECTOR_ENVELOPE_STYLE_OPTIONS = [
|
|
7639
|
-
...
|
|
7575
|
+
...WARP_STYLES.map((value) => ({ value, label: WARP_STYLE_LABELS[value] })),
|
|
7640
7576
|
{ value: "mesh", label: "Mesh" }
|
|
7641
7577
|
];
|
|
7642
7578
|
function getVectorEnvelopePanel(state) {
|
|
@@ -8380,7 +8316,7 @@ function createVectorCommands(controller, options = {}) {
|
|
|
8380
8316
|
type: "object",
|
|
8381
8317
|
properties: {
|
|
8382
8318
|
ids: IDS,
|
|
8383
|
-
preset: { type: "string", enum:
|
|
8319
|
+
preset: { type: "string", enum: WARP_STYLES },
|
|
8384
8320
|
bend: { type: "number", minimum: -100, maximum: 100 },
|
|
8385
8321
|
horizontal: { type: "number", minimum: -100, maximum: 100 },
|
|
8386
8322
|
vertical: { type: "number", minimum: -100, maximum: 100 },
|
|
@@ -8409,7 +8345,7 @@ function createVectorCommands(controller, options = {}) {
|
|
|
8409
8345
|
check(r);
|
|
8410
8346
|
return { nodeId: r.nodeId };
|
|
8411
8347
|
}
|
|
8412
|
-
if (params.preset !== void 0 && !
|
|
8348
|
+
if (params.preset !== void 0 && !WARP_STYLES.includes(params.preset)) fail(`Unknown warp preset "${params.preset}".`);
|
|
8413
8349
|
const patch = {};
|
|
8414
8350
|
if (params.preset) patch.style = params.preset;
|
|
8415
8351
|
for (const k of ["bend", "horizontal", "vertical"]) if (params[k] !== void 0) patch[k] = params[k];
|
|
@@ -8424,7 +8360,7 @@ function createVectorCommands(controller, options = {}) {
|
|
|
8424
8360
|
if (params.mesh.points) {
|
|
8425
8361
|
const even = (n) => Array.from({ length: n + 1 }, (_, i) => i / n);
|
|
8426
8362
|
const mesh = { us: even(columns), vs: even(rows), points: params.mesh.points.map((p) => ({ x: p.x, y: p.y })) };
|
|
8427
|
-
if (!
|
|
8363
|
+
if (!isValidWarpMesh(mesh)) fail(`A ${columns} \xD7 ${rows} mesh needs ${(3 * columns + 1) * (3 * rows + 1)} finite points.`);
|
|
8428
8364
|
patch.mesh = mesh;
|
|
8429
8365
|
}
|
|
8430
8366
|
}
|
|
@@ -9060,8 +8996,8 @@ export {
|
|
|
9060
8996
|
VECTOR_TOOL_GLYPHS,
|
|
9061
8997
|
VECTOR_TOOL_SHORTCUTS,
|
|
9062
8998
|
VECTOR_TRANSFORM_HANDLES,
|
|
9063
|
-
VECTOR_WARP_STYLES,
|
|
9064
|
-
VECTOR_WARP_STYLE_LABELS,
|
|
8999
|
+
WARP_STYLES as VECTOR_WARP_STYLES,
|
|
9000
|
+
WARP_STYLE_LABELS as VECTOR_WARP_STYLE_LABELS,
|
|
9065
9001
|
VECTOR_WIDTH_PRESETS,
|
|
9066
9002
|
VECTOR_WIDTH_PRESET_IDS,
|
|
9067
9003
|
VECTOR_WIDTH_PROFILE_MAX_POINTS,
|
|
@@ -9078,7 +9014,7 @@ export {
|
|
|
9078
9014
|
applyVectorEffects,
|
|
9079
9015
|
applyVectorGradientPatch,
|
|
9080
9016
|
applyVectorGradientSpread,
|
|
9081
|
-
applyVectorHomography,
|
|
9017
|
+
applyHomography as applyVectorHomography,
|
|
9082
9018
|
arrowheadInset,
|
|
9083
9019
|
arrowheadPath,
|
|
9084
9020
|
arrowheadWeight,
|
|
@@ -9108,7 +9044,7 @@ export {
|
|
|
9108
9044
|
decomposeRigid,
|
|
9109
9045
|
defaultVectorGradient,
|
|
9110
9046
|
distortVectorNode,
|
|
9111
|
-
dragVectorMeshPoint,
|
|
9047
|
+
dragWarpMeshPoint as dragVectorMeshPoint,
|
|
9112
9048
|
effectPathLength,
|
|
9113
9049
|
effectPathVertexCount,
|
|
9114
9050
|
effectiveStrokeAlign,
|
|
@@ -9116,7 +9052,7 @@ export {
|
|
|
9116
9052
|
eraseFromFill,
|
|
9117
9053
|
eraseFromOutline,
|
|
9118
9054
|
eraserRegion,
|
|
9119
|
-
evalVectorMesh,
|
|
9055
|
+
evalWarpMesh as evalVectorMesh,
|
|
9120
9056
|
evaluateVectorPathKeyframes,
|
|
9121
9057
|
expandVectorAppearance,
|
|
9122
9058
|
expandVectorAppearances,
|
|
@@ -9128,7 +9064,7 @@ export {
|
|
|
9128
9064
|
explicitVectorGradient,
|
|
9129
9065
|
findVectorNode,
|
|
9130
9066
|
fitCornerRadius,
|
|
9131
|
-
fitVectorMesh,
|
|
9067
|
+
fitWarpMesh as fitVectorMesh,
|
|
9132
9068
|
foldVectorBooleanOperands,
|
|
9133
9069
|
generateVectorBlendChildren,
|
|
9134
9070
|
generateWidthProfile,
|
|
@@ -9179,7 +9115,7 @@ export {
|
|
|
9179
9115
|
isClosedBezierShape,
|
|
9180
9116
|
isIdentityMatrix,
|
|
9181
9117
|
isUniformWidthProfile,
|
|
9182
|
-
isValidVectorMesh,
|
|
9118
|
+
isValidWarpMesh as isValidVectorMesh,
|
|
9183
9119
|
isVectorBlendGroup,
|
|
9184
9120
|
isVectorGradient,
|
|
9185
9121
|
isVectorLiveBoolean,
|
|
@@ -9190,7 +9126,7 @@ export {
|
|
|
9190
9126
|
locateVectorNode,
|
|
9191
9127
|
mapBezierPath,
|
|
9192
9128
|
mapVectorGradient,
|
|
9193
|
-
mapVectorMeshPoints,
|
|
9129
|
+
mapWarpMeshPoints as mapVectorMeshPoints,
|
|
9194
9130
|
mapVectorPaint,
|
|
9195
9131
|
mapVectorPoints,
|
|
9196
9132
|
mapVectorSubpaths,
|
|
@@ -9209,7 +9145,7 @@ export {
|
|
|
9209
9145
|
nodeMatrix,
|
|
9210
9146
|
normalizeVectorEffectParams,
|
|
9211
9147
|
offsetPaths,
|
|
9212
|
-
orderVectorQuad,
|
|
9148
|
+
orderQuad as orderVectorQuad,
|
|
9213
9149
|
parseSvgTransform,
|
|
9214
9150
|
parseVectorColor,
|
|
9215
9151
|
parseVectorSvg,
|
|
@@ -9222,7 +9158,7 @@ export {
|
|
|
9222
9158
|
polylineBounds,
|
|
9223
9159
|
pressureWidthProfile,
|
|
9224
9160
|
puckerBloatPaths,
|
|
9225
|
-
pullVectorMesh,
|
|
9161
|
+
pullWarpMesh as pullVectorMesh,
|
|
9226
9162
|
recognizeInkShape,
|
|
9227
9163
|
rectSubpath,
|
|
9228
9164
|
refineMorphContour,
|
|
@@ -9233,12 +9169,12 @@ export {
|
|
|
9233
9169
|
removeAnchorsKeepingShape,
|
|
9234
9170
|
removeRedundantPoints,
|
|
9235
9171
|
removeVectorGradientStop,
|
|
9236
|
-
removeVectorMeshSplitU,
|
|
9237
|
-
removeVectorMeshSplitV,
|
|
9172
|
+
removeWarpMeshSplitU as removeVectorMeshSplitU,
|
|
9173
|
+
removeWarpMeshSplitV as removeVectorMeshSplitV,
|
|
9238
9174
|
removeWidthPoints,
|
|
9239
9175
|
repeatPaths,
|
|
9240
9176
|
resampleGradientStops,
|
|
9241
|
-
resizeVectorMesh,
|
|
9177
|
+
resizeWarpMesh as resizeVectorMesh,
|
|
9242
9178
|
resolveVectorBlendOptions,
|
|
9243
9179
|
reverseMorphContour,
|
|
9244
9180
|
reverseSubpath,
|
|
@@ -9268,8 +9204,8 @@ export {
|
|
|
9268
9204
|
spanVectorGradientStops,
|
|
9269
9205
|
splitIntoFaces,
|
|
9270
9206
|
splitSubpathAt,
|
|
9271
|
-
splitVectorMeshU,
|
|
9272
|
-
splitVectorMeshV,
|
|
9207
|
+
splitWarpMeshU as splitVectorMeshU,
|
|
9208
|
+
splitWarpMeshV as splitVectorMeshV,
|
|
9273
9209
|
starSubpath,
|
|
9274
9210
|
strokePositionPoint,
|
|
9275
9211
|
strokeWidthProfileOf,
|
|
@@ -9339,19 +9275,19 @@ export {
|
|
|
9339
9275
|
vectorGradientTAt,
|
|
9340
9276
|
vectorGradientTargetPath,
|
|
9341
9277
|
vectorGradientUnitsMatrix,
|
|
9342
|
-
vectorHomography,
|
|
9343
|
-
vectorHomographyKeepsQuad,
|
|
9344
|
-
vectorIdentityMesh,
|
|
9278
|
+
homographyFromPoints as vectorHomography,
|
|
9279
|
+
homographyKeepsQuad as vectorHomographyKeepsQuad,
|
|
9280
|
+
identityWarpMesh as vectorIdentityMesh,
|
|
9345
9281
|
vectorInkShapeName,
|
|
9346
9282
|
vectorLiveBooleanSteps,
|
|
9347
|
-
vectorMeshColumns,
|
|
9348
|
-
vectorMeshControlBounds,
|
|
9349
|
-
vectorMeshEditPoints,
|
|
9283
|
+
warpMeshColumns as vectorMeshColumns,
|
|
9284
|
+
warpMeshControlBounds as vectorMeshControlBounds,
|
|
9285
|
+
warpMeshEditPoints as vectorMeshEditPoints,
|
|
9350
9286
|
vectorMeshFromOutline,
|
|
9351
|
-
vectorMeshGridCurves,
|
|
9287
|
+
warpMeshGridCurves as vectorMeshGridCurves,
|
|
9352
9288
|
vectorMeshOutline,
|
|
9353
|
-
vectorMeshParamAt,
|
|
9354
|
-
vectorMeshRows,
|
|
9289
|
+
warpMeshParamAt as vectorMeshParamAt,
|
|
9290
|
+
warpMeshRows as vectorMeshRows,
|
|
9355
9291
|
vectorNodeBounds,
|
|
9356
9292
|
vectorNodeEnvelope,
|
|
9357
9293
|
vectorNodeRotation,
|
|
@@ -9381,8 +9317,8 @@ export {
|
|
|
9381
9317
|
vectorStrokeSvgParts,
|
|
9382
9318
|
vectorStrokeWidthGeometry,
|
|
9383
9319
|
vectorToolLabel,
|
|
9384
|
-
vectorWarpPresetGrid,
|
|
9385
|
-
vectorWarpPresetMesh,
|
|
9320
|
+
warpPresetGrid as vectorWarpPresetGrid,
|
|
9321
|
+
warpPresetMesh as vectorWarpPresetMesh,
|
|
9386
9322
|
vectorWorldMatrix,
|
|
9387
9323
|
walkVectorNodes,
|
|
9388
9324
|
widthProfileAt,
|