@snowcone-app/canvas 0.43.8 → 0.44.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/{CanvasRenderer-DIug_mjX.js → CanvasRenderer-B8BADU_r.js} +876 -830
- package/dist/CanvasRenderer-B8BADU_r.js.map +1 -0
- package/dist/{CanvasStateV1-BWd358xJ.js → CanvasStateV1-BlDWgOzV.js} +3 -3
- package/dist/{CanvasStateV1-BWd358xJ.js.map → CanvasStateV1-BlDWgOzV.js.map} +1 -1
- package/dist/ContextualToolbars-rCZo-KCm.js +6808 -0
- package/dist/ContextualToolbars-rCZo-KCm.js.map +1 -0
- package/dist/EditorCanvasImpl-C63QS2OK.js +144 -0
- package/dist/EditorCanvasImpl-C63QS2OK.js.map +1 -0
- package/dist/{ExportManager-BDH9jW4Q.js → ExportManager-xRsXgyNo.js} +2 -2
- package/dist/{ExportManager-BDH9jW4Q.js.map → ExportManager-xRsXgyNo.js.map} +1 -1
- package/dist/{FontAnalyzer-CyhywbAM.js → FontAnalyzer-Ds3Wdba7.js} +239 -236
- package/dist/FontAnalyzer-Ds3Wdba7.js.map +1 -0
- package/dist/{ImagePanel-CIGpLY3B.js → ImagePanel-DhOWKvIN.js} +6 -6
- package/dist/{ImagePanel-CIGpLY3B.js.map → ImagePanel-DhOWKvIN.js.map} +1 -1
- package/dist/{SnowconeCanvas-DE0A9UwD.js → SnowconeCanvas-C-AGGT44.js} +478 -465
- package/dist/SnowconeCanvas-C-AGGT44.js.map +1 -0
- package/dist/adjust-CDVzlVBY.js +145 -0
- package/dist/adjust-CDVzlVBY.js.map +1 -0
- package/dist/advanced.mjs +15 -15
- package/dist/api/stable.d.ts +2 -0
- package/dist/components/ImageToolbar.d.ts +3 -0
- package/dist/components/ShapeToolbar.d.ts +2 -0
- package/dist/components/TextToolbar.d.ts +2 -1
- package/dist/components/embed/SnowconeCanvas.d.ts +8 -0
- package/dist/components/toolbars/SecondaryPanels.d.ts +24 -0
- package/dist/components/toolbars/index.d.ts +2 -2
- package/dist/core/ArtboardElement.d.ts +2 -0
- package/dist/core/CanvasRenderer.d.ts +3 -1
- package/dist/{custom-icons-sT5sNRcG.js → custom-icons-C4bzABm2.js} +2 -2
- package/dist/{custom-icons-sT5sNRcG.js.map → custom-icons-C4bzABm2.js.map} +1 -1
- package/dist/{design-builder-CwfefZJC.js → design-builder-DCHVrEFV.js} +315 -314
- package/dist/design-builder-DCHVrEFV.js.map +1 -0
- package/dist/{embed-rRSCS25g.js → embed-DnjyfavG.js} +10 -10
- package/dist/{embed-rRSCS25g.js.map → embed-DnjyfavG.js.map} +1 -1
- package/dist/embed.mjs +19 -19
- package/dist/engrave/EngraveSync.d.ts +5 -0
- package/dist/engrave/adjust.d.ts +36 -0
- package/dist/engrave/makeEngraved.d.ts +23 -0
- package/dist/engrave/types.d.ts +33 -0
- package/dist/{guards-Dvw7Qch0.js → guards-DwYEoqcn.js} +2 -2
- package/dist/{guards-Dvw7Qch0.js.map → guards-DwYEoqcn.js.map} +1 -1
- package/dist/index.mjs +57 -54
- package/dist/index.mjs.map +1 -1
- package/dist/internals.mjs +6 -6
- package/dist/rendering/EngraveViewRenderer.d.ts +15 -0
- package/dist/{template-fields-DF1ijCl9.js → template-fields-CK7Uvvc8.js} +5 -5
- package/dist/{template-fields-DF1ijCl9.js.map → template-fields-CK7Uvvc8.js.map} +1 -1
- package/dist/testing.mjs +3 -3
- package/dist/types/index.d.ts +5 -0
- package/dist/{useCommands-wwGeWCn6.js → useCommands-BrkGKdXr.js} +7 -7
- package/dist/{useCommands-wwGeWCn6.js.map → useCommands-BrkGKdXr.js.map} +1 -1
- package/dist/{usePieceGuideBundle-BWQINIJR.js → usePieceGuideBundle-BWdobHQE.js} +2 -2
- package/dist/{usePieceGuideBundle-BWQINIJR.js.map → usePieceGuideBundle-BWdobHQE.js.map} +1 -1
- package/dist/{validation-CXC34UhU.js → validation-DETfj7tg.js} +2206 -2201
- package/dist/validation-DETfj7tg.js.map +1 -0
- package/example/package.json +1 -1
- package/package.json +3 -3
- package/dist/CanvasRenderer-DIug_mjX.js.map +0 -1
- package/dist/ContextualToolbars-CspkC1T3.js +0 -6604
- package/dist/ContextualToolbars-CspkC1T3.js.map +0 -1
- package/dist/EditorCanvasImpl-Cn2fdo6a.js +0 -144
- package/dist/EditorCanvasImpl-Cn2fdo6a.js.map +0 -1
- package/dist/FontAnalyzer-CyhywbAM.js.map +0 -1
- package/dist/SnowconeCanvas-DE0A9UwD.js.map +0 -1
- package/dist/design-builder-CwfefZJC.js.map +0 -1
- package/dist/validation-CXC34UhU.js.map +0 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { k as
|
|
2
|
-
import { T as
|
|
3
|
-
import { a as
|
|
1
|
+
import { k as pe, l as ye, a2 as nt, m as $t, a3 as be, a4 as Se, a5 as Kt, a6 as me, a7 as gt, a8 as Te, a9 as jt, aa as we, ab as ve, c as ae, ac as _t, ad as Me, ae as xe, af as Re, ag as Ce, v as re, s as le, ah as pt, w as he, ai as zt, aj as qt, ak as At, al as Ut, am as ke, an as Ae, ao as Zt, ap as Pe, aq as Ee, ar as He, I as Ie, as as Be, at as Le, au as tt } from "./FontAnalyzer-Ds3Wdba7.js";
|
|
2
|
+
import { T as Vt, b as De, v as We, L as _e, M as Ft, A as Pt, N as ze, O as Ve, P as Fe, Q as Jt } from "./ExportManager-xRsXgyNo.js";
|
|
3
|
+
import { a as Ot, i as Qt } from "./guards-DwYEoqcn.js";
|
|
4
|
+
import { cutValue as Oe, CUT_THRESHOLD as ce, hairlineMask as Ge } from "@snowcone-app/sdk/engrave";
|
|
5
|
+
import { m as Ye } from "./adjust-CDVzlVBY.js";
|
|
4
6
|
const ct = {
|
|
5
7
|
// Canvas-specific
|
|
6
8
|
canvas: {
|
|
@@ -15,30 +17,30 @@ const ct = {
|
|
|
15
17
|
spacingLabelFontSize: 11,
|
|
16
18
|
spacingLabelFontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
17
19
|
}
|
|
18
|
-
},
|
|
19
|
-
function
|
|
20
|
-
return
|
|
20
|
+
}, Xe = 2, Ct = 6, Ne = 16, $e = 5, Ke = 5, de = 0.5;
|
|
21
|
+
function te(T) {
|
|
22
|
+
return Xe / T;
|
|
21
23
|
}
|
|
22
|
-
function
|
|
23
|
-
return Ct /
|
|
24
|
+
function bn(T) {
|
|
25
|
+
return Ct / T;
|
|
24
26
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
27
|
+
function je(T) {
|
|
28
|
+
return Ne / T;
|
|
27
29
|
}
|
|
28
|
-
function
|
|
29
|
-
return [
|
|
30
|
+
function Sn(T) {
|
|
31
|
+
return [$e / T, Ke / T];
|
|
30
32
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
const n =
|
|
34
|
-
|
|
33
|
+
function qe(T, t, e, s) {
|
|
34
|
+
T.save();
|
|
35
|
+
const n = de / s;
|
|
36
|
+
T.translate(t, e), T.scale(n, n), T.strokeStyle = "#000", T.lineWidth = 1.5, T.lineCap = "round", T.lineJoin = "round", T.translate(-12, -12), T.beginPath(), T.moveTo(21, 12), T.arc(12, 12, 9, 0, -Math.PI / 2, !0), T.bezierCurveTo(3.5, 4.5, 4, 6, 3, 8), T.stroke(), T.beginPath(), T.moveTo(3, 3), T.lineTo(3, 8), T.lineTo(8, 8), T.stroke(), T.beginPath(), T.moveTo(3, 12), T.arc(12, 12, 9, Math.PI, Math.PI / 2, !0), T.bezierCurveTo(20.5, 19.5, 20, 18, 21, 16), T.stroke(), T.beginPath(), T.moveTo(16, 16), T.lineTo(21, 16), T.lineTo(21, 21), T.stroke(), T.restore();
|
|
35
37
|
}
|
|
36
|
-
function
|
|
37
|
-
const i =
|
|
38
|
-
|
|
38
|
+
function mn(T, t, e, s = 1, n = "#3b82f6", o = !1) {
|
|
39
|
+
const i = je(s);
|
|
40
|
+
T.save(), T.fillStyle = "#fff", T.strokeStyle = n, T.lineWidth = o ? te(s) * 1.25 : te(s), T.beginPath(), T.arc(t, e, i, 0, Math.PI * 2), T.fill(), T.stroke(), qe(T, t, e, s), T.restore();
|
|
39
41
|
}
|
|
40
|
-
const
|
|
41
|
-
class
|
|
42
|
+
const ee = Ct * 2;
|
|
43
|
+
class Tn {
|
|
42
44
|
constructor() {
|
|
43
45
|
this.resizeHandles = [], this.rotationHandle = null, this.elementRotation = 0, this.rotationAnchor = { x: 0, y: 0 };
|
|
44
46
|
}
|
|
@@ -55,8 +57,8 @@ class sn {
|
|
|
55
57
|
y: n.y - a,
|
|
56
58
|
width: n.width + a * 2,
|
|
57
59
|
height: n.height + a * 2
|
|
58
|
-
}, l =
|
|
59
|
-
this.resizeHandles = l.filter((c) => !(!i.includes(c.anchor) || h && c.anchor.includes("middle"))), this.rotationHandle =
|
|
60
|
+
}, l = pe(r, t.rotation, o), h = Math.abs(t.rotation % 360) > 0.1;
|
|
61
|
+
this.resizeHandles = l.filter((c) => !(!i.includes(c.anchor) || h && c.anchor.includes("middle"))), this.rotationHandle = ye(
|
|
60
62
|
r,
|
|
61
63
|
t.rotation,
|
|
62
64
|
o,
|
|
@@ -71,8 +73,8 @@ class sn {
|
|
|
71
73
|
this.resizeHandles.forEach((c) => {
|
|
72
74
|
if (a && r && c.anchor !== r.anchor)
|
|
73
75
|
return;
|
|
74
|
-
const
|
|
75
|
-
this.renderResizeHandle(t, c,
|
|
76
|
+
const f = !!(i && i.anchor === c.anchor), d = !!(a && r && r.anchor === c.anchor);
|
|
77
|
+
this.renderResizeHandle(t, c, f, d, l);
|
|
76
78
|
}), h && e && this.rotationHandle && !n && !a && this.renderRotationHandle(t, this.rotationHandle, o, l), h && e && this.rotationHandle && n && this.renderRotationTooltip(t, this.rotationHandle, s, l);
|
|
77
79
|
}
|
|
78
80
|
/**
|
|
@@ -85,8 +87,8 @@ class sn {
|
|
|
85
87
|
if (e.anchor.includes("middle")) {
|
|
86
88
|
const l = e.anchor === "middle-top" || e.anchor === "middle-bottom";
|
|
87
89
|
t.translate(i, a), t.rotate(-this.elementRotation * Math.PI / 180), l && t.rotate(Math.PI / 2), t.translate(-i, -a);
|
|
88
|
-
const h =
|
|
89
|
-
t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = s || n ? 2.5 : 2, t.beginPath(), t.roundRect(
|
|
90
|
+
const h = ee * 0.6, c = ee * 1.4, f = h / 2, d = i - h / 2, y = a - c / 2;
|
|
91
|
+
t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = s || n ? 2.5 : 2, t.beginPath(), t.roundRect(d, y, h, c, f), t.fill(), t.stroke();
|
|
90
92
|
} else
|
|
91
93
|
t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = s || n ? 2.5 : 2, t.beginPath(), t.arc(i, a, Ct, 0, Math.PI * 2), t.fill(), t.stroke();
|
|
92
94
|
t.restore();
|
|
@@ -99,7 +101,7 @@ class sn {
|
|
|
99
101
|
t.save();
|
|
100
102
|
const o = e.x * n, i = e.y * n, a = Ct * 2.67;
|
|
101
103
|
t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = s ? 2.5 : 2, t.beginPath(), t.arc(o, i, a, 0, Math.PI * 2), t.fill(), t.stroke();
|
|
102
|
-
const r =
|
|
104
|
+
const r = de;
|
|
103
105
|
t.translate(o, i), t.scale(r, r), t.strokeStyle = "#000", t.lineWidth = 1.5, t.lineCap = "round", t.lineJoin = "round", t.translate(-12, -12), t.beginPath(), t.moveTo(21, 12), t.arc(12, 12, 9, 0, -Math.PI / 2, !0), t.bezierCurveTo(3.5, 4.5, 4, 6, 3, 8), t.stroke(), t.beginPath(), t.moveTo(3, 3), t.lineTo(3, 8), t.lineTo(8, 8), t.stroke(), t.beginPath(), t.moveTo(3, 12), t.arc(12, 12, 9, Math.PI, Math.PI / 2, !0), t.bezierCurveTo(20.5, 19.5, 20, 18, 21, 16), t.stroke(), t.beginPath(), t.moveTo(16, 16), t.lineTo(21, 16), t.lineTo(21, 21), t.stroke(), t.restore();
|
|
104
106
|
}
|
|
105
107
|
/**
|
|
@@ -115,9 +117,9 @@ class sn {
|
|
|
115
117
|
* @param zoom - Current zoom level (radius scales inversely with zoom)
|
|
116
118
|
*/
|
|
117
119
|
hitTestResize(t, e, s = 1) {
|
|
118
|
-
const n =
|
|
120
|
+
const n = Se / s;
|
|
119
121
|
for (const o of this.resizeHandles)
|
|
120
|
-
if (
|
|
122
|
+
if ($t(t, e, o.x, o.y, n))
|
|
121
123
|
return o;
|
|
122
124
|
return null;
|
|
123
125
|
}
|
|
@@ -128,7 +130,7 @@ class sn {
|
|
|
128
130
|
hitTestRotation(t, e, s = 1) {
|
|
129
131
|
if (!this.rotationHandle) return !1;
|
|
130
132
|
const n = (Ct * 2.67 + 2) / s;
|
|
131
|
-
return
|
|
133
|
+
return $t(t, e, this.rotationHandle.x, this.rotationHandle.y, n);
|
|
132
134
|
}
|
|
133
135
|
/**
|
|
134
136
|
* Get rotation handle position (for React-based rendering)
|
|
@@ -143,7 +145,7 @@ class sn {
|
|
|
143
145
|
*/
|
|
144
146
|
getCursor(t, e) {
|
|
145
147
|
const s = t.anchor.includes("middle") ? "edge" : "corner";
|
|
146
|
-
return
|
|
148
|
+
return be(
|
|
147
149
|
t.x,
|
|
148
150
|
t.y,
|
|
149
151
|
this.rotationAnchor.x,
|
|
@@ -154,19 +156,19 @@ class sn {
|
|
|
154
156
|
);
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
|
-
const
|
|
158
|
-
function
|
|
159
|
-
return Math.abs(
|
|
159
|
+
const Ue = 15;
|
|
160
|
+
function Ze(T, t) {
|
|
161
|
+
return Math.abs(T) >= Math.abs(t) ? "x" : "y";
|
|
160
162
|
}
|
|
161
|
-
function
|
|
162
|
-
return e != null && e.shift ?
|
|
163
|
+
function Je(T, t, e) {
|
|
164
|
+
return e != null && e.shift ? Ze(T, t) === "x" ? { dx: T, dy: 0, lockedAxis: "y" } : { dx: 0, dy: t, lockedAxis: "x" } : { dx: T, dy: t, lockedAxis: null };
|
|
163
165
|
}
|
|
164
|
-
function
|
|
165
|
-
let s = (Math.round(
|
|
166
|
+
function Qe(T, t = Ue) {
|
|
167
|
+
let s = (Math.round(T / t) * t % 360 + 360) % 360;
|
|
166
168
|
return s > 180 && (s -= 360), s === 0 ? 0 : s;
|
|
167
169
|
}
|
|
168
|
-
function
|
|
169
|
-
anchor:
|
|
170
|
+
function tn({
|
|
171
|
+
anchor: T,
|
|
170
172
|
startVisualWidth: t,
|
|
171
173
|
startVisualHeight: e,
|
|
172
174
|
newVisualWidth: s,
|
|
@@ -174,13 +176,13 @@ function Xe({
|
|
|
174
176
|
}) {
|
|
175
177
|
const o = t !== 0 ? t : 1, i = e !== 0 ? e : 1, a = s / o, r = n / i;
|
|
176
178
|
let l;
|
|
177
|
-
return
|
|
179
|
+
return T === "middle-left" || T === "middle-right" ? l = a : T === "middle-top" || T === "middle-bottom" ? l = r : l = Math.abs(a - 1) >= Math.abs(r - 1) ? a : r, {
|
|
178
180
|
scale: l,
|
|
179
181
|
newVisualWidth: t * l,
|
|
180
182
|
newVisualHeight: e * l
|
|
181
183
|
};
|
|
182
184
|
}
|
|
183
|
-
class
|
|
185
|
+
class en {
|
|
184
186
|
/**
|
|
185
187
|
* Calculate new dimensions and position for a resize operation
|
|
186
188
|
*/
|
|
@@ -193,76 +195,76 @@ class Ne {
|
|
|
193
195
|
snapSystem: i,
|
|
194
196
|
modifiers: a
|
|
195
197
|
}) {
|
|
196
|
-
var _,
|
|
197
|
-
const l = new
|
|
198
|
-
let
|
|
199
|
-
e.anchor.includes("right") ?
|
|
200
|
-
const
|
|
198
|
+
var _, Y, V, j, B;
|
|
199
|
+
const l = new Kt(t).worldDeltaToLocal(s, n), h = l.dx, c = l.dy, f = o.visualWidth ?? o.width ?? 0, d = o.visualHeight ?? o.height ?? 0, y = o.width ?? 0, p = o.height ?? 0;
|
|
200
|
+
let u = f, g = d;
|
|
201
|
+
e.anchor.includes("right") ? u = f + h : e.anchor.includes("left") && (u = f - h), e.anchor !== "middle-left" && e.anchor !== "middle-right" && (e.anchor.includes("bottom") ? g = d + c : e.anchor.includes("top") && (g = d - c));
|
|
202
|
+
const b = (a == null ? void 0 : a.shift) === !0;
|
|
201
203
|
let S = null;
|
|
202
|
-
if (
|
|
203
|
-
const z =
|
|
204
|
+
if (b) {
|
|
205
|
+
const z = tn({
|
|
204
206
|
anchor: e.anchor,
|
|
205
|
-
startVisualWidth:
|
|
206
|
-
startVisualHeight:
|
|
207
|
-
newVisualWidth:
|
|
208
|
-
newVisualHeight:
|
|
207
|
+
startVisualWidth: f,
|
|
208
|
+
startVisualHeight: d,
|
|
209
|
+
newVisualWidth: u,
|
|
210
|
+
newVisualHeight: g
|
|
209
211
|
});
|
|
210
|
-
S = z.scale,
|
|
212
|
+
S = z.scale, u = z.newVisualWidth, g = z.newVisualHeight;
|
|
211
213
|
}
|
|
212
214
|
let m, w;
|
|
213
215
|
if (S !== null)
|
|
214
|
-
m =
|
|
216
|
+
m = y * S, w = p * S;
|
|
215
217
|
else if (e.anchor === "middle-left" || e.anchor === "middle-right") {
|
|
216
|
-
const z =
|
|
217
|
-
m =
|
|
218
|
+
const z = u - f;
|
|
219
|
+
m = y + z, w = p;
|
|
218
220
|
} else if (e.anchor === "middle-top" || e.anchor === "middle-bottom") {
|
|
219
|
-
const z =
|
|
220
|
-
m =
|
|
221
|
+
const z = g - d;
|
|
222
|
+
m = y, w = p + z;
|
|
221
223
|
} else {
|
|
222
|
-
const z =
|
|
223
|
-
m =
|
|
224
|
+
const z = u / f, $ = g / d;
|
|
225
|
+
m = y * z, w = p * $;
|
|
224
226
|
}
|
|
225
|
-
const
|
|
227
|
+
const v = u, M = g;
|
|
226
228
|
let C = !1;
|
|
227
229
|
if (i && t.transformType === "image") {
|
|
228
|
-
const z = e.anchor ?? "",
|
|
229
|
-
if (
|
|
230
|
-
const L = (_ = i.activeSnaps) == null ? void 0 : _.x,
|
|
231
|
-
if (!!L || !!
|
|
232
|
-
const X = [L,
|
|
233
|
-
(
|
|
230
|
+
const z = e.anchor ?? "", $ = z === "top-left" || z === "top-right" || z === "bottom-left" || z === "bottom-right", Q = z.startsWith("crop-");
|
|
231
|
+
if ($ && !Q) {
|
|
232
|
+
const L = (_ = i.activeSnaps) == null ? void 0 : _.x, E = (Y = i.activeSnaps) == null ? void 0 : Y.y;
|
|
233
|
+
if (!!L || !!E) {
|
|
234
|
+
const X = [L, E].find(
|
|
235
|
+
(H) => typeof H == "object" && H !== null && "frozenWidth" in H
|
|
234
236
|
);
|
|
235
237
|
if (X) {
|
|
236
|
-
const
|
|
238
|
+
const H = t, W = o.transformData, U = X.frozenWidth ?? ((V = H.transformData) == null ? void 0 : V.width) ?? y, ot = H.imageAspectRatio || (W != null && W.width && (W != null && W.height) ? W.width / W.height : null);
|
|
237
239
|
let et = X.frozenHeight;
|
|
238
|
-
et == null && (ot && ot !== 0 ? et = U / ot : (j =
|
|
239
|
-
const lt =
|
|
240
|
-
|
|
240
|
+
et == null && (ot && ot !== 0 ? et = U / ot : (j = H.transformData) != null && j.height ? et = H.transformData.height : et = p);
|
|
241
|
+
const lt = y !== 0 ? U / y : 1, G = p !== 0 ? et / p : 1;
|
|
242
|
+
u = f * lt, g = d * G, m = U, w = et, C = !0;
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
247
|
m = Math.max(50, m), w = Math.max(40, w);
|
|
246
|
-
const
|
|
247
|
-
if (!e.anchor.includes("middle") && ((
|
|
248
|
-
const z = o.width ?? 1,
|
|
249
|
-
|
|
248
|
+
const R = t.clone(), I = R.resize(e.anchor, m, w, o);
|
|
249
|
+
if (!e.anchor.includes("middle") && ((B = R.stroke) != null && B.enabled) && o.strokeWidth !== void 0 && o.strokeWidth > 0) {
|
|
250
|
+
const z = o.width ?? 1, $ = o.height ?? 1, Q = Math.sqrt(m / z * (w / $)), L = Math.max(1, Math.round(o.strokeWidth * Q * 10) / 10);
|
|
251
|
+
R.stroke = { ...R.stroke, width: L };
|
|
250
252
|
}
|
|
251
|
-
const
|
|
252
|
-
if (
|
|
253
|
-
const z = t.getRotationAnchor(),
|
|
253
|
+
const A = C || I === !1, k = e.anchor.includes("top") || e.anchor.includes("bottom"), P = "isCropping" in R && R.isCropping, D = "isGroup" in R && R.isGroup;
|
|
254
|
+
if (k && !P && !D) {
|
|
255
|
+
const z = t.getRotationAnchor(), $ = this._calculateFixedCornerOffset({
|
|
254
256
|
element: t,
|
|
255
|
-
updatedElement:
|
|
257
|
+
updatedElement: R,
|
|
256
258
|
handle: e,
|
|
257
259
|
rotationAnchor: z
|
|
258
260
|
});
|
|
259
|
-
|
|
261
|
+
R.x += $.x, R.y += $.y;
|
|
260
262
|
}
|
|
261
263
|
return {
|
|
262
|
-
element:
|
|
263
|
-
isFrozen:
|
|
264
|
+
element: R,
|
|
265
|
+
isFrozen: A,
|
|
264
266
|
// For snap system to detect break-free: dimensions before freeze was applied
|
|
265
|
-
unfrozenDimensions: C ? { width:
|
|
267
|
+
unfrozenDimensions: C ? { width: v, height: M } : void 0
|
|
266
268
|
};
|
|
267
269
|
}
|
|
268
270
|
/**
|
|
@@ -276,10 +278,10 @@ class Ne {
|
|
|
276
278
|
handle: s,
|
|
277
279
|
rotationAnchor: n
|
|
278
280
|
}) {
|
|
279
|
-
const o = new
|
|
281
|
+
const o = new Kt(t), { cos: i, sin: a } = o.getRenderingCosSin(), r = t.getVisualBoundingBox(), l = e.getVisualBoundingBox(), h = n, c = e.getRotationAnchor(), f = this._getFixedLocalCoords(s.anchor, r.width, r.height), d = f.x, y = f.y, p = r.x - h.x, u = r.y - h.y, g = p + d, b = u + y, S = g * i - b * a, m = g * a + b * i, w = h.x + S, v = h.y + m, M = this._getFixedLocalCoords(s.anchor, l.width, l.height), C = M.x, R = M.y, I = l.x - c.x, x = l.y - c.y, A = I + C, k = x + R, P = A * i - k * a, D = A * a + k * i, _ = c.x + P, Y = c.y + D;
|
|
280
282
|
return {
|
|
281
283
|
x: w - _,
|
|
282
|
-
y:
|
|
284
|
+
y: v - Y
|
|
283
285
|
};
|
|
284
286
|
}
|
|
285
287
|
/**
|
|
@@ -317,7 +319,7 @@ class Ne {
|
|
|
317
319
|
return n;
|
|
318
320
|
}
|
|
319
321
|
}
|
|
320
|
-
class
|
|
322
|
+
class nn {
|
|
321
323
|
constructor() {
|
|
322
324
|
this.hooks = {
|
|
323
325
|
beforeResize: [],
|
|
@@ -372,7 +374,7 @@ class Ke {
|
|
|
372
374
|
*/
|
|
373
375
|
executeResize(t) {
|
|
374
376
|
const e = this.runHooks("beforeResize", t);
|
|
375
|
-
let s =
|
|
377
|
+
let s = en.calculateResize({
|
|
376
378
|
...e,
|
|
377
379
|
snapSystem: t.snapSystem,
|
|
378
380
|
modifiers: t.modifiers
|
|
@@ -388,8 +390,8 @@ class Ke {
|
|
|
388
390
|
return this.runHooks("afterPositionUpdate", s).position;
|
|
389
391
|
}
|
|
390
392
|
}
|
|
391
|
-
const
|
|
392
|
-
class
|
|
393
|
+
const wn = new nn();
|
|
394
|
+
class vn {
|
|
393
395
|
constructor(t = null) {
|
|
394
396
|
this.state = "IDLE", this.context = {
|
|
395
397
|
mode: null,
|
|
@@ -484,13 +486,13 @@ class an {
|
|
|
484
486
|
updateDrag(t, e, s = null, n) {
|
|
485
487
|
if (this.state !== "DRAGGING")
|
|
486
488
|
throw new Error("Cannot update drag: not in DRAGGING state");
|
|
487
|
-
const o = t - this.context.startX, i = e - this.context.startY, { dx: a, dy: r, lockedAxis: l } =
|
|
488
|
-
let c = h.x + a,
|
|
489
|
+
const o = t - this.context.startX, i = e - this.context.startY, { dx: a, dy: r, lockedAxis: l } = Je(o, i, n), h = this.context.startData;
|
|
490
|
+
let c = h.x + a, f = h.y + r;
|
|
489
491
|
if (this.snapHandler && this.snapHandler.snapPosition && this.context.element) {
|
|
490
|
-
const
|
|
491
|
-
c =
|
|
492
|
+
const d = this.snapHandler.snapPosition({ x: c, y: f }, this.context.element, s);
|
|
493
|
+
c = d.x, f = d.y;
|
|
492
494
|
}
|
|
493
|
-
return l === "x" ? c = h.x : l === "y" && (
|
|
495
|
+
return l === "x" ? c = h.x : l === "y" && (f = h.y), { x: c, y: f };
|
|
494
496
|
}
|
|
495
497
|
/**
|
|
496
498
|
* Start resize operation
|
|
@@ -600,9 +602,9 @@ class an {
|
|
|
600
602
|
updateRotate(t, e, s, n, o) {
|
|
601
603
|
if (this.state !== "ROTATING")
|
|
602
604
|
throw new Error("Cannot update rotate: not in ROTATING state");
|
|
603
|
-
const i = this.context.startData, r = (
|
|
605
|
+
const i = this.context.startData, r = (me(s, n, t, e) - i.startAngle) * 180 / Math.PI;
|
|
604
606
|
let l = i.currentRotation - r;
|
|
605
|
-
return l = (l % 360 + 360) % 360, l > 180 && (l -= 360), o != null && o.shift ?
|
|
607
|
+
return l = (l % 360 + 360) % 360, l > 180 && (l -= 360), o != null && o.shift ? Qe(l) : this.snapHandler && this.snapHandler.snapRotation && this.context.element ? this.snapHandler.snapRotation(l, this.context.element) : l;
|
|
606
608
|
}
|
|
607
609
|
/**
|
|
608
610
|
* Get rotation context
|
|
@@ -663,10 +665,10 @@ class an {
|
|
|
663
665
|
const s = this.context.startData, n = {
|
|
664
666
|
x: (t.x + e.x) / 2,
|
|
665
667
|
y: (t.y + e.y) / 2
|
|
666
|
-
}, o = e.x - t.x, i = e.y - t.y, a = Math.hypot(o, i), r = Math.atan2(i, o), l = Math.max(s.startDistance, 1e-4), h = a / l, c = Math.max(h, 0.05),
|
|
668
|
+
}, o = e.x - t.x, i = e.y - t.y, a = Math.hypot(o, i), r = Math.atan2(i, o), l = Math.max(s.startDistance, 1e-4), h = a / l, c = Math.max(h, 0.05), f = r - s.startAngle;
|
|
667
669
|
return {
|
|
668
670
|
scale: c,
|
|
669
|
-
rotationDelta:
|
|
671
|
+
rotationDelta: f,
|
|
670
672
|
startCentroid: s.startCentroid,
|
|
671
673
|
currentCentroid: n
|
|
672
674
|
};
|
|
@@ -824,7 +826,7 @@ class mt {
|
|
|
824
826
|
return Math.abs(n.x - s.x) > o || Math.abs(n.y - s.y) > o;
|
|
825
827
|
}
|
|
826
828
|
}
|
|
827
|
-
class
|
|
829
|
+
class ne {
|
|
828
830
|
constructor(t) {
|
|
829
831
|
this.cellSize = t, this.cells = /* @__PURE__ */ new Map(), this.idIndex = /* @__PURE__ */ new Map();
|
|
830
832
|
}
|
|
@@ -866,12 +868,12 @@ class Zt {
|
|
|
866
868
|
const o = [], i = Math.floor((t - s) / this.cellSize), a = Math.floor((t + s) / this.cellSize), r = Math.floor((e - s) / this.cellSize), l = Math.floor((e + s) / this.cellSize);
|
|
867
869
|
for (let h = i; h <= a; h++)
|
|
868
870
|
for (let c = r; c <= l; c++) {
|
|
869
|
-
const
|
|
870
|
-
if (
|
|
871
|
-
for (const
|
|
872
|
-
if (n !== void 0 &&
|
|
873
|
-
const
|
|
874
|
-
|
|
871
|
+
const f = `${h},${c}`, d = this.cells.get(f);
|
|
872
|
+
if (d)
|
|
873
|
+
for (const y of d) {
|
|
874
|
+
if (n !== void 0 && y.id === n) continue;
|
|
875
|
+
const p = y.x - t, u = y.y - e;
|
|
876
|
+
p * p + u * u <= s * s && o.push(y);
|
|
875
877
|
}
|
|
876
878
|
}
|
|
877
879
|
return o;
|
|
@@ -895,16 +897,16 @@ class Zt {
|
|
|
895
897
|
for (const [r, l] of this.cells) {
|
|
896
898
|
const h = r.indexOf(","), c = parseInt(r.substring(0, h), 10);
|
|
897
899
|
if (!(c < i || c > a))
|
|
898
|
-
for (const
|
|
899
|
-
n !== void 0 &&
|
|
900
|
+
for (const f of l)
|
|
901
|
+
n !== void 0 && f.id === n || Math.abs(f.x - e) <= s && o.push(f);
|
|
900
902
|
}
|
|
901
903
|
} else {
|
|
902
904
|
const i = Math.floor((e - s) / this.cellSize), a = Math.floor((e + s) / this.cellSize);
|
|
903
905
|
for (const [r, l] of this.cells) {
|
|
904
906
|
const h = r.indexOf(","), c = parseInt(r.substring(h + 1), 10);
|
|
905
907
|
if (!(c < i || c > a))
|
|
906
|
-
for (const
|
|
907
|
-
n !== void 0 &&
|
|
908
|
+
for (const f of l)
|
|
909
|
+
n !== void 0 && f.id === n || Math.abs(f.y - e) <= s && o.push(f);
|
|
908
910
|
}
|
|
909
911
|
}
|
|
910
912
|
return o;
|
|
@@ -920,32 +922,32 @@ class Zt {
|
|
|
920
922
|
return `${Math.floor(t / this.cellSize)},${Math.floor(e / this.cellSize)}`;
|
|
921
923
|
}
|
|
922
924
|
}
|
|
923
|
-
function ft(
|
|
924
|
-
const t =
|
|
925
|
+
function ft(T) {
|
|
926
|
+
const t = T.transformData;
|
|
925
927
|
if (t && "width" in t && typeof t.width == "number")
|
|
926
928
|
return t.width;
|
|
927
929
|
}
|
|
928
|
-
function Tt(
|
|
929
|
-
const t =
|
|
930
|
+
function Tt(T) {
|
|
931
|
+
const t = T.transformData;
|
|
930
932
|
if (t && "height" in t && typeof t.height == "number")
|
|
931
933
|
return t.height;
|
|
932
934
|
}
|
|
933
|
-
function xt(
|
|
934
|
-
const e =
|
|
935
|
+
function xt(T, t) {
|
|
936
|
+
const e = T.transformData;
|
|
935
937
|
return e && "width" in e ? (e.width = t, !0) : !1;
|
|
936
938
|
}
|
|
937
|
-
function Et(
|
|
938
|
-
const e =
|
|
939
|
+
function Et(T, t) {
|
|
940
|
+
const e = T.transformData;
|
|
939
941
|
return e && "height" in e ? (e.height = t, !0) : !1;
|
|
940
942
|
}
|
|
941
|
-
class
|
|
943
|
+
class Mn {
|
|
942
944
|
constructor(t = {}) {
|
|
943
945
|
this._extraSnapRects = [], this.snapThreshold = t.snapThreshold || ct.canvas.snapThreshold, this.enabled = t.enabled !== !1, this.showGuides = t.showGuides !== !1, this.guides = [], this.activeSnaps = {
|
|
944
946
|
x: null,
|
|
945
947
|
// { snapTo: number, anchorKey: string, frozenFontSize: number, frozenWidth: number, frozenPosition: {x, y}, isPositionBasedSnap: boolean }
|
|
946
948
|
y: null
|
|
947
949
|
// { snapTo: number, anchorKey: string, frozenFontSize: number, frozenWidth: number, frozenPosition: {x, y}, isPositionBasedSnap: boolean }
|
|
948
|
-
}, this.stickyThreshold = t.stickyThreshold || 15, this._spatialGrid = new
|
|
950
|
+
}, this.stickyThreshold = t.stickyThreshold || 15, this._spatialGrid = new ne(Math.max(this.snapThreshold * 2, 16)), this._anchorMetadata = /* @__PURE__ */ new Map();
|
|
949
951
|
}
|
|
950
952
|
/**
|
|
951
953
|
* Enable or disable snapping
|
|
@@ -957,7 +959,7 @@ class rn {
|
|
|
957
959
|
* Set snap threshold in pixels
|
|
958
960
|
*/
|
|
959
961
|
setSnapThreshold(t) {
|
|
960
|
-
this.snapThreshold = t, this._spatialGrid = new
|
|
962
|
+
this.snapThreshold = t, this._spatialGrid = new ne(Math.max(t * 2, 16));
|
|
961
963
|
}
|
|
962
964
|
/**
|
|
963
965
|
* Get current snap guides for rendering
|
|
@@ -1045,18 +1047,18 @@ class rn {
|
|
|
1045
1047
|
return this.clearGuides(), t;
|
|
1046
1048
|
const n = e.clone();
|
|
1047
1049
|
n.x = t.x, n.y = t.y;
|
|
1048
|
-
const o = mt.getSnapAnchors(n), i = s.filter((
|
|
1050
|
+
const o = mt.getSnapAnchors(n), i = s.filter((b) => b.id !== e.id);
|
|
1049
1051
|
this._populateSpatialGrid(i);
|
|
1050
1052
|
let a = null, r = null, l = 1 / 0, h = 1 / 0;
|
|
1051
|
-
const c = [],
|
|
1052
|
-
for (const [
|
|
1053
|
+
const c = [], f = [], d = [];
|
|
1054
|
+
for (const [b, S] of Object.entries(o)) {
|
|
1053
1055
|
const m = this._spatialGrid.queryNearAxis("x", S.x, this.snapThreshold);
|
|
1054
|
-
for (const
|
|
1055
|
-
const
|
|
1056
|
-
if (!
|
|
1057
|
-
const C =
|
|
1056
|
+
for (const v of m) {
|
|
1057
|
+
const M = this._anchorMetadata.get(v.id);
|
|
1058
|
+
if (!M) continue;
|
|
1059
|
+
const C = M.point, R = M.anchorKey, I = Math.abs(S.x - C.x);
|
|
1058
1060
|
if (I < this.snapThreshold) {
|
|
1059
|
-
const
|
|
1061
|
+
const x = {
|
|
1060
1062
|
snapTo: C.x,
|
|
1061
1063
|
offset: S.x - t.x,
|
|
1062
1064
|
// How far anchor is from element position
|
|
@@ -1066,20 +1068,20 @@ class rn {
|
|
|
1066
1068
|
x: C.x,
|
|
1067
1069
|
y1: Math.min(S.y, C.y) - 50,
|
|
1068
1070
|
y2: Math.max(S.y, C.y) + 50,
|
|
1069
|
-
movingKey:
|
|
1070
|
-
otherKey:
|
|
1071
|
+
movingKey: b,
|
|
1072
|
+
otherKey: R
|
|
1071
1073
|
}
|
|
1072
1074
|
};
|
|
1073
|
-
c.push(
|
|
1075
|
+
c.push(x), I < l && (l = I, a = x);
|
|
1074
1076
|
}
|
|
1075
1077
|
}
|
|
1076
1078
|
const w = this._spatialGrid.queryNearAxis("y", S.y, this.snapThreshold);
|
|
1077
|
-
for (const
|
|
1078
|
-
const
|
|
1079
|
-
if (!
|
|
1080
|
-
const C =
|
|
1079
|
+
for (const v of w) {
|
|
1080
|
+
const M = this._anchorMetadata.get(v.id);
|
|
1081
|
+
if (!M) continue;
|
|
1082
|
+
const C = M.point, R = M.anchorKey, I = Math.abs(S.y - C.y);
|
|
1081
1083
|
if (I < this.snapThreshold) {
|
|
1082
|
-
const
|
|
1084
|
+
const x = {
|
|
1083
1085
|
snapTo: C.y,
|
|
1084
1086
|
offset: S.y - t.y,
|
|
1085
1087
|
distance: I,
|
|
@@ -1088,30 +1090,30 @@ class rn {
|
|
|
1088
1090
|
y: C.y,
|
|
1089
1091
|
x1: Math.min(S.x, C.x) - 50,
|
|
1090
1092
|
x2: Math.max(S.x, C.x) + 50,
|
|
1091
|
-
movingKey:
|
|
1092
|
-
otherKey:
|
|
1093
|
+
movingKey: b,
|
|
1094
|
+
otherKey: R
|
|
1093
1095
|
}
|
|
1094
1096
|
};
|
|
1095
|
-
|
|
1097
|
+
f.push(x), I < h && (h = I, r = x);
|
|
1096
1098
|
}
|
|
1097
1099
|
}
|
|
1098
1100
|
}
|
|
1099
|
-
let
|
|
1100
|
-
a && (
|
|
1101
|
-
const
|
|
1102
|
-
for (const
|
|
1103
|
-
const S =
|
|
1104
|
-
(!S ||
|
|
1101
|
+
let y = t.x, p = t.y;
|
|
1102
|
+
a && (y = a.snapTo - a.offset), r && (p = r.snapTo - r.offset);
|
|
1103
|
+
const u = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
1104
|
+
for (const b of c) {
|
|
1105
|
+
const S = u.get(b.snapTo);
|
|
1106
|
+
(!S || b.distance < S.distance) && u.set(b.snapTo, b);
|
|
1105
1107
|
}
|
|
1106
|
-
for (const
|
|
1107
|
-
const S =
|
|
1108
|
-
(!S ||
|
|
1108
|
+
for (const b of f) {
|
|
1109
|
+
const S = g.get(b.snapTo);
|
|
1110
|
+
(!S || b.distance < S.distance) && g.set(b.snapTo, b);
|
|
1109
1111
|
}
|
|
1110
|
-
for (const
|
|
1111
|
-
|
|
1112
|
-
for (const
|
|
1113
|
-
|
|
1114
|
-
return this.guides =
|
|
1112
|
+
for (const b of u.values())
|
|
1113
|
+
d.push(b.guide);
|
|
1114
|
+
for (const b of g.values())
|
|
1115
|
+
d.push(b.guide);
|
|
1116
|
+
return this.guides = d, { x: y, y: p };
|
|
1115
1117
|
}
|
|
1116
1118
|
/**
|
|
1117
1119
|
* Calculate what the frozen font size should be at the snap point
|
|
@@ -1162,18 +1164,18 @@ class rn {
|
|
|
1162
1164
|
for (const h of l) {
|
|
1163
1165
|
const c = this._anchorMetadata.get(h.id);
|
|
1164
1166
|
if (!c || !i.has(c.anchorKey)) continue;
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1167
|
-
distance:
|
|
1168
|
-
snapTo:
|
|
1167
|
+
const f = c.point, d = c.anchorKey, y = Math.abs(r.x - f.x);
|
|
1168
|
+
y < this.snapThreshold && o.push({
|
|
1169
|
+
distance: y,
|
|
1170
|
+
snapTo: f.x,
|
|
1169
1171
|
currentValue: r.x,
|
|
1170
1172
|
guide: {
|
|
1171
1173
|
type: "vertical",
|
|
1172
|
-
x:
|
|
1173
|
-
y1: Math.min(r.y,
|
|
1174
|
-
y2: Math.max(r.y,
|
|
1174
|
+
x: f.x,
|
|
1175
|
+
y1: Math.min(r.y, f.y) - 50,
|
|
1176
|
+
y2: Math.max(r.y, f.y) + 50,
|
|
1175
1177
|
movingKey: a,
|
|
1176
|
-
otherKey:
|
|
1178
|
+
otherKey: d
|
|
1177
1179
|
}
|
|
1178
1180
|
});
|
|
1179
1181
|
}
|
|
@@ -1194,18 +1196,18 @@ class rn {
|
|
|
1194
1196
|
for (const h of l) {
|
|
1195
1197
|
const c = this._anchorMetadata.get(h.id);
|
|
1196
1198
|
if (!c || !i.has(c.anchorKey)) continue;
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
distance:
|
|
1200
|
-
snapTo:
|
|
1199
|
+
const f = c.point, d = c.anchorKey, y = Math.abs(r.y - f.y);
|
|
1200
|
+
y < this.snapThreshold && o.push({
|
|
1201
|
+
distance: y,
|
|
1202
|
+
snapTo: f.y,
|
|
1201
1203
|
currentValue: r.y,
|
|
1202
1204
|
guide: {
|
|
1203
1205
|
type: "horizontal",
|
|
1204
|
-
y:
|
|
1205
|
-
x1: Math.min(r.x,
|
|
1206
|
-
x2: Math.max(r.x,
|
|
1206
|
+
y: f.y,
|
|
1207
|
+
x1: Math.min(r.x, f.x) - 50,
|
|
1208
|
+
x2: Math.max(r.x, f.x) + 50,
|
|
1207
1209
|
movingKey: a,
|
|
1208
|
-
otherKey:
|
|
1210
|
+
otherKey: d
|
|
1209
1211
|
}
|
|
1210
1212
|
});
|
|
1211
1213
|
}
|
|
@@ -1316,8 +1318,8 @@ class rn {
|
|
|
1316
1318
|
_calculateFrozenDimensionsAtSnap(t, e, s, n, o) {
|
|
1317
1319
|
const i = ft(t) ?? t.width ?? 0, a = Tt(t) ?? t.height ?? 0;
|
|
1318
1320
|
let r = i, l = a;
|
|
1319
|
-
const h = t.transformType === "image", c = h ? t.imageAspectRatio || (i && a ? i / a : null) : null,
|
|
1320
|
-
return e === "x" ?
|
|
1321
|
+
const h = t.transformType === "image", c = h ? t.imageAspectRatio || (i && a ? i / a : null) : null, f = n.toLowerCase();
|
|
1322
|
+
return e === "x" ? f.includes("right") ? (r = i + s, h && c && (l = r / c)) : f.includes("left") && (r = i - s, h && c && (l = r / c)) : e === "y" && (f.includes("bottom") ? (l = a + s, h && c && (r = l * c)) : f.includes("top") && (l = a - s, h && c && (r = l * c))), { frozenWidth: r, frozenHeight: l };
|
|
1321
1323
|
}
|
|
1322
1324
|
/**
|
|
1323
1325
|
* Process sticky snapping for a single axis
|
|
@@ -1329,32 +1331,32 @@ class rn {
|
|
|
1329
1331
|
if (r) {
|
|
1330
1332
|
const c = e[r.anchorKey];
|
|
1331
1333
|
if (c) {
|
|
1332
|
-
const
|
|
1333
|
-
if (
|
|
1334
|
-
if (l = r.snapTo -
|
|
1335
|
-
const
|
|
1334
|
+
const f = t === "x" ? c.x : c.y, d = Math.abs(f - r.snapTo), y = this._getAdjustedStickyThreshold(t, n);
|
|
1335
|
+
if (d < y) {
|
|
1336
|
+
if (l = r.snapTo - f, !(t === "y" && r.isPositionBasedSnap)) {
|
|
1337
|
+
const u = this._calculateFrozenFontSizeAtSnap(
|
|
1336
1338
|
n,
|
|
1337
1339
|
t === "x" ? l : 0,
|
|
1338
1340
|
t === "y" ? l : 0,
|
|
1339
1341
|
o,
|
|
1340
1342
|
i
|
|
1341
1343
|
);
|
|
1342
|
-
|
|
1344
|
+
u !== r.frozenFontSize && (r.frozenFontSize = u);
|
|
1343
1345
|
}
|
|
1344
1346
|
h = this._createGuideForSnap(r, r.anchorKey, e, a, t);
|
|
1345
1347
|
} else {
|
|
1346
|
-
const
|
|
1348
|
+
const p = r;
|
|
1347
1349
|
if (this.activeSnaps[t] = null, s.length > 0 && s[0].distance < this.snapThreshold) {
|
|
1348
1350
|
h = s[0], l = h.snapTo - h.currentValue;
|
|
1349
|
-
const
|
|
1351
|
+
const u = p && p.anchorKey === h.guide.movingKey && Math.abs(p.snapTo - h.snapTo) < 1, g = u ? p.frozenFontSize : this._calculateFrozenFontSizeAtSnap(
|
|
1350
1352
|
n,
|
|
1351
1353
|
t === "x" ? l : 0,
|
|
1352
1354
|
t === "y" ? l : 0,
|
|
1353
1355
|
o,
|
|
1354
1356
|
i
|
|
1355
|
-
),
|
|
1357
|
+
), b = this._isPositionBasedSnap(n, t);
|
|
1356
1358
|
let S;
|
|
1357
|
-
|
|
1359
|
+
u ? S = p.frozenPosition : b ? S = {
|
|
1358
1360
|
x: t === "x" ? n.x + l : n.x,
|
|
1359
1361
|
y: t === "y" ? n.y + l : n.y
|
|
1360
1362
|
} : S = { x: n.x, y: n.y };
|
|
@@ -1368,11 +1370,11 @@ class rn {
|
|
|
1368
1370
|
this.activeSnaps[t] = {
|
|
1369
1371
|
snapTo: h.snapTo,
|
|
1370
1372
|
anchorKey: h.guide.movingKey,
|
|
1371
|
-
frozenFontSize:
|
|
1373
|
+
frozenFontSize: g,
|
|
1372
1374
|
frozenWidth: m.frozenWidth,
|
|
1373
1375
|
frozenHeight: m.frozenHeight,
|
|
1374
1376
|
frozenPosition: S,
|
|
1375
|
-
isPositionBasedSnap:
|
|
1377
|
+
isPositionBasedSnap: b
|
|
1376
1378
|
};
|
|
1377
1379
|
}
|
|
1378
1380
|
}
|
|
@@ -1380,19 +1382,19 @@ class rn {
|
|
|
1380
1382
|
this.activeSnaps[t] = null;
|
|
1381
1383
|
} else if (s.length > 0 && s[0].distance < this.snapThreshold) {
|
|
1382
1384
|
h = s[0], l = h.snapTo - h.currentValue;
|
|
1383
|
-
const c = this.activeSnaps[t],
|
|
1385
|
+
const c = this.activeSnaps[t], f = c && c.anchorKey === h.guide.movingKey && Math.abs(c.snapTo - h.snapTo) < 1, d = f ? c.frozenFontSize : this._calculateFrozenFontSizeAtSnap(
|
|
1384
1386
|
n,
|
|
1385
1387
|
t === "x" ? l : 0,
|
|
1386
1388
|
t === "y" ? l : 0,
|
|
1387
1389
|
o,
|
|
1388
1390
|
i
|
|
1389
|
-
),
|
|
1390
|
-
let
|
|
1391
|
-
|
|
1391
|
+
), y = this._isPositionBasedSnap(n, t);
|
|
1392
|
+
let p;
|
|
1393
|
+
f ? p = c.frozenPosition : y ? p = {
|
|
1392
1394
|
x: t === "x" ? n.x + l : n.x,
|
|
1393
1395
|
y: t === "y" ? n.y + l : n.y
|
|
1394
|
-
} :
|
|
1395
|
-
const
|
|
1396
|
+
} : p = { x: n.x, y: n.y };
|
|
1397
|
+
const u = this._calculateFrozenDimensionsAtSnap(
|
|
1396
1398
|
n,
|
|
1397
1399
|
t,
|
|
1398
1400
|
l,
|
|
@@ -1402,11 +1404,11 @@ class rn {
|
|
|
1402
1404
|
this.activeSnaps[t] = {
|
|
1403
1405
|
snapTo: h.snapTo,
|
|
1404
1406
|
anchorKey: h.guide.movingKey,
|
|
1405
|
-
frozenFontSize:
|
|
1406
|
-
frozenWidth:
|
|
1407
|
-
frozenHeight:
|
|
1408
|
-
frozenPosition:
|
|
1409
|
-
isPositionBasedSnap:
|
|
1407
|
+
frozenFontSize: d,
|
|
1408
|
+
frozenWidth: u.frozenWidth,
|
|
1409
|
+
frozenHeight: u.frozenHeight,
|
|
1410
|
+
frozenPosition: p,
|
|
1411
|
+
isPositionBasedSnap: y
|
|
1410
1412
|
};
|
|
1411
1413
|
}
|
|
1412
1414
|
return { snapDelta: l, bestSnap: h };
|
|
@@ -1493,63 +1495,63 @@ class rn {
|
|
|
1493
1495
|
* @returns {object} Modified resize result with adjusted element
|
|
1494
1496
|
*/
|
|
1495
1497
|
snapDimensions(t, e, s = null) {
|
|
1496
|
-
var
|
|
1498
|
+
var v, M, C, R, I;
|
|
1497
1499
|
if (!this.enabled || !e)
|
|
1498
1500
|
return this.clearGuides(), t;
|
|
1499
1501
|
const { element: n } = t, o = t.handle;
|
|
1500
1502
|
let i;
|
|
1501
1503
|
const a = n.transformType === "image", r = this.activeSnaps.x !== null || this.activeSnaps.y !== null;
|
|
1502
1504
|
if (a && r && t.isFrozen && t.unfrozenDimensions) {
|
|
1503
|
-
const
|
|
1504
|
-
if (
|
|
1505
|
-
const
|
|
1506
|
-
xt(
|
|
1505
|
+
const x = n.clone();
|
|
1506
|
+
if (x.transformData) {
|
|
1507
|
+
const A = n.getVisualBoundingBox(), k = A.width, P = A.height, D = (s == null ? void 0 : s.width) ?? n.width ?? 0, _ = (s == null ? void 0 : s.height) ?? n.height ?? 0, Y = (s == null ? void 0 : s.visualWidth) ?? k, V = (s == null ? void 0 : s.visualHeight) ?? P, j = t.unfrozenDimensions.width / Y, B = t.unfrozenDimensions.height / V;
|
|
1508
|
+
xt(x, D * j), Et(x, _ * B);
|
|
1507
1509
|
}
|
|
1508
|
-
i = mt.getSnapAnchors(
|
|
1510
|
+
i = mt.getSnapAnchors(x);
|
|
1509
1511
|
} else
|
|
1510
1512
|
i = mt.getSnapAnchors(n);
|
|
1511
|
-
const l = e.filter((
|
|
1513
|
+
const l = e.filter((x) => x.id !== n.id);
|
|
1512
1514
|
if (l.length === 0)
|
|
1513
1515
|
return this.clearGuides(), t;
|
|
1514
1516
|
this._populateSpatialGrid(l);
|
|
1515
|
-
const h = this._getSnapKeysForHandle(o), c = this._getTargetSnapKeys(),
|
|
1516
|
-
this._prioritizeSnaps(
|
|
1517
|
-
const
|
|
1518
|
-
|
|
1517
|
+
const h = this._getSnapKeysForHandle(o), c = this._getTargetSnapKeys(), f = this._findXSnaps(i, l, h, c), d = this._findYSnaps(i, l, h, c);
|
|
1518
|
+
this._prioritizeSnaps(f, o, "x"), this._prioritizeSnaps(d, o, "y");
|
|
1519
|
+
const y = this._processStickySnap("x", i, f, n, o, s, l), p = this._processStickySnap("y", i, d, n, o, s, l), u = y.snapDelta, g = p.snapDelta, b = y.bestSnap, S = p.bestSnap, m = [];
|
|
1520
|
+
b && m.push(b.guide), S && m.push(S.guide), this.guides = m, m.length > 0;
|
|
1519
1521
|
const w = o && (o.anchor === "top-left" || o.anchor === "top-right" || o.anchor === "bottom-left" || o.anchor === "bottom-right");
|
|
1520
|
-
if (a && w && (
|
|
1522
|
+
if (a && w && (u !== 0 || g !== 0))
|
|
1521
1523
|
return t;
|
|
1522
|
-
if (
|
|
1523
|
-
const
|
|
1524
|
-
if (!
|
|
1524
|
+
if (u !== 0 || g !== 0) {
|
|
1525
|
+
const x = n.clone(), A = this.activeSnaps.x || this.activeSnaps.y, k = (A == null ? void 0 : A.frozenFontSize) ?? n.fontSize ?? 0, P = (A == null ? void 0 : A.frozenWidth) ?? ft(n) ?? n.width ?? 0, D = (A == null ? void 0 : A.frozenHeight) ?? Tt(n) ?? n.height ?? 0, _ = (A == null ? void 0 : A.frozenPosition) ?? { x: n.x, y: n.y }, Y = x.isCropping && !String(o.anchor).startsWith("crop-");
|
|
1526
|
+
if (!Y)
|
|
1525
1527
|
if (o && o.anchor) {
|
|
1526
|
-
if (
|
|
1527
|
-
const L = (
|
|
1528
|
-
|
|
1528
|
+
if (u !== 0) {
|
|
1529
|
+
const L = (v = this.activeSnaps.x) == null ? void 0 : v.anchorKey, E = L == null ? void 0 : L.toLowerCase();
|
|
1530
|
+
E && E.includes("right") ? this._adjustElementForRightResize(x, u, o) : E && E.includes("left") ? this._adjustElementForLeftResize(x, u, o) : x.x += u;
|
|
1529
1531
|
}
|
|
1530
|
-
if (
|
|
1531
|
-
const L = (
|
|
1532
|
-
|
|
1532
|
+
if (g !== 0) {
|
|
1533
|
+
const L = (M = this.activeSnaps.y) == null ? void 0 : M.anchorKey, E = L == null ? void 0 : L.toLowerCase();
|
|
1534
|
+
E && E.includes("bottom") ? this._adjustElementForBottomResize(x, g, o) : E && E.includes("top") ? this._adjustElementForTopResize(x, g, o) : x.y += g;
|
|
1533
1535
|
}
|
|
1534
1536
|
} else
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
const V =
|
|
1537
|
+
x.x += u, x.y += g;
|
|
1538
|
+
x.fontSize !== void 0 && (x.fontSize = k);
|
|
1539
|
+
const V = x.transformType === "image", j = this.activeSnaps.x !== null || this.activeSnaps.y !== null;
|
|
1538
1540
|
if (V && j) {
|
|
1539
|
-
if (ft(
|
|
1541
|
+
if (ft(x) !== void 0) {
|
|
1540
1542
|
const L = this.activeSnaps.x || this.activeSnaps.y;
|
|
1541
|
-
let
|
|
1542
|
-
L && (
|
|
1543
|
-
const X = ft(n),
|
|
1544
|
-
|
|
1543
|
+
let E = P, O = D;
|
|
1544
|
+
L && (E = L.frozenWidth ?? E, O = L.frozenHeight ?? O);
|
|
1545
|
+
const X = ft(n), H = Tt(n), W = x.imageAspectRatio || (X && H ? X / H : null);
|
|
1546
|
+
W && W !== 0 && (O = E / W), xt(x, E), Et(x, O), L && (L.frozenWidth = E, L.frozenHeight = O);
|
|
1545
1547
|
}
|
|
1546
1548
|
} else
|
|
1547
|
-
(((C = this.activeSnaps.y) == null ? void 0 : C.isPositionBasedSnap) || !1) && (ft(
|
|
1548
|
-
const
|
|
1549
|
-
return (
|
|
1549
|
+
(((C = this.activeSnaps.y) == null ? void 0 : C.isPositionBasedSnap) || !1) && (ft(x) !== void 0 ? xt(x, P) : x.width !== void 0 && (x.width = P));
|
|
1550
|
+
const B = o && (o.anchor === "middle-left" || o.anchor === "middle-right"), z = o && (o.anchor === "middle-top" || o.anchor === "middle-bottom"), $ = ((R = this.activeSnaps.x) == null ? void 0 : R.isPositionBasedSnap) || !1, Q = ((I = this.activeSnaps.y) == null ? void 0 : I.isPositionBasedSnap) || !1;
|
|
1551
|
+
return (u === 0 || $) && !B && !z && !Y && (x.x = _.x), (g === 0 || Q) && !z && !B && !Y && (x.y = _.y), {
|
|
1550
1552
|
...t,
|
|
1551
|
-
element:
|
|
1552
|
-
snapAdjustment: { dx:
|
|
1553
|
+
element: x,
|
|
1554
|
+
snapAdjustment: { dx: u, dy: g },
|
|
1553
1555
|
// Flag to indicate we're in sticky snap mode (used to freeze font size)
|
|
1554
1556
|
isInStickySnap: !0
|
|
1555
1557
|
};
|
|
@@ -1563,12 +1565,12 @@ class rn {
|
|
|
1563
1565
|
if (!this.enabled) return t;
|
|
1564
1566
|
const n = [0, 45, 90, 135, 180, 225, 270, 315, 360], o = 5;
|
|
1565
1567
|
for (const i of n)
|
|
1566
|
-
if (
|
|
1568
|
+
if (Te(t, i, o))
|
|
1567
1569
|
return i;
|
|
1568
1570
|
return t;
|
|
1569
1571
|
}
|
|
1570
1572
|
}
|
|
1571
|
-
class
|
|
1573
|
+
class xn {
|
|
1572
1574
|
constructor(t = {}) {
|
|
1573
1575
|
this.lastSnapTarget = null, this.detectionThreshold = t.detectionThreshold || 100, this.minDistance = t.minDistance || 10, this.enabled = t.enabled !== !1, this.showLabels = t.showLabels !== !1, this.indicators = [];
|
|
1574
1576
|
}
|
|
@@ -1603,106 +1605,106 @@ class ln {
|
|
|
1603
1605
|
snapToSpacing(t, e, s) {
|
|
1604
1606
|
if (!this.enabled || !s)
|
|
1605
1607
|
return t;
|
|
1606
|
-
const n =
|
|
1608
|
+
const n = jt, o = s.filter((u) => u.id !== e.id);
|
|
1607
1609
|
if (o.length === 0)
|
|
1608
1610
|
return t;
|
|
1609
1611
|
const i = e.clone();
|
|
1610
1612
|
i.x = t.x, i.y = t.y;
|
|
1611
1613
|
const a = i.getVisualBoundingBox(), r = a.x - t.x, l = a.y - t.y;
|
|
1612
|
-
let h = t.x, c = t.y,
|
|
1613
|
-
const
|
|
1614
|
-
const
|
|
1615
|
-
return !(a.x + a.width <
|
|
1614
|
+
let h = t.x, c = t.y, f = !1, d = !1;
|
|
1615
|
+
const y = o.filter((u) => {
|
|
1616
|
+
const g = u.getVisualBoundingBox();
|
|
1617
|
+
return !(a.x + a.width < g.x || a.x > g.x + g.width);
|
|
1616
1618
|
});
|
|
1617
|
-
if (
|
|
1618
|
-
const
|
|
1619
|
-
return
|
|
1620
|
-
}),
|
|
1621
|
-
let
|
|
1622
|
-
for (const m of
|
|
1619
|
+
if (y.sort((u, g) => {
|
|
1620
|
+
const b = u.getVisualBoundingBox(), S = g.getVisualBoundingBox();
|
|
1621
|
+
return b.y - S.y;
|
|
1622
|
+
}), y.length >= 1) {
|
|
1623
|
+
let u = null, g = null;
|
|
1624
|
+
for (const m of y) {
|
|
1623
1625
|
const w = m.getVisualBoundingBox();
|
|
1624
|
-
w.y + w.height <= a.y ? (!
|
|
1626
|
+
w.y + w.height <= a.y ? (!u || w.y > u.getVisualBoundingBox().y) && (u = m) : w.y >= a.y + a.height && (!g || w.y < g.getVisualBoundingBox().y) && (g = m);
|
|
1625
1627
|
}
|
|
1626
|
-
const
|
|
1627
|
-
for (let m = 0; m <
|
|
1628
|
-
const w =
|
|
1629
|
-
|
|
1628
|
+
const b = [];
|
|
1629
|
+
for (let m = 0; m < y.length - 1; m++) {
|
|
1630
|
+
const w = y[m].getVisualBoundingBox(), M = y[m + 1].getVisualBoundingBox().y - (w.y + w.height);
|
|
1631
|
+
b.push(M);
|
|
1630
1632
|
}
|
|
1631
1633
|
let S = null;
|
|
1632
|
-
if (
|
|
1633
|
-
const m =
|
|
1634
|
-
for (const
|
|
1635
|
-
if (Math.abs(w -
|
|
1636
|
-
S =
|
|
1634
|
+
if (u) {
|
|
1635
|
+
const m = u.getVisualBoundingBox(), w = a.y - (m.y + m.height);
|
|
1636
|
+
for (const v of b)
|
|
1637
|
+
if (Math.abs(w - v) <= n) {
|
|
1638
|
+
S = v;
|
|
1637
1639
|
break;
|
|
1638
1640
|
}
|
|
1639
1641
|
}
|
|
1640
|
-
if (!S &&
|
|
1641
|
-
const w =
|
|
1642
|
-
for (const
|
|
1643
|
-
if (Math.abs(w -
|
|
1644
|
-
S =
|
|
1642
|
+
if (!S && g) {
|
|
1643
|
+
const w = g.getVisualBoundingBox().y - (a.y + a.height);
|
|
1644
|
+
for (const v of b)
|
|
1645
|
+
if (Math.abs(w - v) <= n) {
|
|
1646
|
+
S = v;
|
|
1645
1647
|
break;
|
|
1646
1648
|
}
|
|
1647
1649
|
}
|
|
1648
1650
|
if (S !== null && S > 0) {
|
|
1649
|
-
if (
|
|
1650
|
-
const m =
|
|
1651
|
-
Math.abs(w - S) <= n && (c = m.y + m.height + S - l,
|
|
1651
|
+
if (u) {
|
|
1652
|
+
const m = u.getVisualBoundingBox(), w = a.y - (m.y + m.height);
|
|
1653
|
+
Math.abs(w - S) <= n && (c = m.y + m.height + S - l, d = !0);
|
|
1652
1654
|
}
|
|
1653
|
-
if (!
|
|
1654
|
-
const m =
|
|
1655
|
-
Math.abs(w - S) <= n && (c = m.y - a.height - S - l,
|
|
1655
|
+
if (!d && g) {
|
|
1656
|
+
const m = g.getVisualBoundingBox(), w = m.y - (a.y + a.height);
|
|
1657
|
+
Math.abs(w - S) <= n && (c = m.y - a.height - S - l, d = !0);
|
|
1656
1658
|
}
|
|
1657
1659
|
}
|
|
1658
1660
|
}
|
|
1659
|
-
const
|
|
1660
|
-
const
|
|
1661
|
-
return !(a.y + a.height <
|
|
1661
|
+
const p = o.filter((u) => {
|
|
1662
|
+
const g = u.getVisualBoundingBox();
|
|
1663
|
+
return !(a.y + a.height < g.y || a.y > g.y + g.height);
|
|
1662
1664
|
});
|
|
1663
|
-
if (
|
|
1664
|
-
const
|
|
1665
|
-
return
|
|
1666
|
-
}),
|
|
1667
|
-
let
|
|
1668
|
-
for (const m of
|
|
1665
|
+
if (p.sort((u, g) => {
|
|
1666
|
+
const b = u.getVisualBoundingBox(), S = g.getVisualBoundingBox();
|
|
1667
|
+
return b.x - S.x;
|
|
1668
|
+
}), p.length >= 1) {
|
|
1669
|
+
let u = null, g = null;
|
|
1670
|
+
for (const m of p) {
|
|
1669
1671
|
const w = m.getVisualBoundingBox();
|
|
1670
|
-
w.x + w.width <= a.x ? (!
|
|
1672
|
+
w.x + w.width <= a.x ? (!u || w.x > u.getVisualBoundingBox().x) && (u = m) : w.x >= a.x + a.width && (!g || w.x < g.getVisualBoundingBox().x) && (g = m);
|
|
1671
1673
|
}
|
|
1672
|
-
const
|
|
1673
|
-
for (let m = 0; m <
|
|
1674
|
-
const w =
|
|
1675
|
-
|
|
1674
|
+
const b = [];
|
|
1675
|
+
for (let m = 0; m < p.length - 1; m++) {
|
|
1676
|
+
const w = p[m].getVisualBoundingBox(), M = p[m + 1].getVisualBoundingBox().x - (w.x + w.width);
|
|
1677
|
+
b.push(M);
|
|
1676
1678
|
}
|
|
1677
1679
|
let S = null;
|
|
1678
|
-
if (
|
|
1679
|
-
const m =
|
|
1680
|
-
for (const
|
|
1681
|
-
if (Math.abs(w -
|
|
1682
|
-
S =
|
|
1680
|
+
if (u) {
|
|
1681
|
+
const m = u.getVisualBoundingBox(), w = a.x - (m.x + m.width);
|
|
1682
|
+
for (const v of b)
|
|
1683
|
+
if (Math.abs(w - v) <= n) {
|
|
1684
|
+
S = v;
|
|
1683
1685
|
break;
|
|
1684
1686
|
}
|
|
1685
1687
|
}
|
|
1686
|
-
if (!S &&
|
|
1687
|
-
const w =
|
|
1688
|
-
for (const
|
|
1689
|
-
if (Math.abs(w -
|
|
1690
|
-
S =
|
|
1688
|
+
if (!S && g) {
|
|
1689
|
+
const w = g.getVisualBoundingBox().x - (a.x + a.width);
|
|
1690
|
+
for (const v of b)
|
|
1691
|
+
if (Math.abs(w - v) <= n) {
|
|
1692
|
+
S = v;
|
|
1691
1693
|
break;
|
|
1692
1694
|
}
|
|
1693
1695
|
}
|
|
1694
1696
|
if (S !== null && S > 0) {
|
|
1695
|
-
if (
|
|
1696
|
-
const m =
|
|
1697
|
-
Math.abs(w - S) <= n && (h = m.x + m.width + S - r,
|
|
1697
|
+
if (u) {
|
|
1698
|
+
const m = u.getVisualBoundingBox(), w = a.x - (m.x + m.width);
|
|
1699
|
+
Math.abs(w - S) <= n && (h = m.x + m.width + S - r, f = !0);
|
|
1698
1700
|
}
|
|
1699
|
-
if (!
|
|
1700
|
-
const m =
|
|
1701
|
-
Math.abs(w - S) <= n && (h = m.x - a.width - S - r,
|
|
1701
|
+
if (!f && g) {
|
|
1702
|
+
const m = g.getVisualBoundingBox(), w = m.x - (a.x + a.width);
|
|
1703
|
+
Math.abs(w - S) <= n && (h = m.x - a.width - S - r, f = !0);
|
|
1702
1704
|
}
|
|
1703
1705
|
}
|
|
1704
1706
|
}
|
|
1705
|
-
return this.lastSnapTarget =
|
|
1707
|
+
return this.lastSnapTarget = f || d ? { x: h, y: c } : null, { x: h, y: c };
|
|
1706
1708
|
}
|
|
1707
1709
|
/**
|
|
1708
1710
|
* Detect spacing between a moving element and other elements
|
|
@@ -1718,10 +1720,10 @@ class ln {
|
|
|
1718
1720
|
return this.clearIndicators(), [];
|
|
1719
1721
|
const o = t.getVisualBoundingBox(), i = [], a = [], r = [], l = [];
|
|
1720
1722
|
for (const c of n) {
|
|
1721
|
-
const
|
|
1722
|
-
|
|
1723
|
+
const f = c.getVisualBoundingBox(), d = o.x - (f.x + f.width), y = f.x - (o.x + o.width), p = o.y - (f.y + f.height), u = f.y - (o.y + o.height), g = !(o.y + o.height < f.y || o.y > f.y + f.height), b = !(o.x + o.width < f.x || o.x > f.x + f.width);
|
|
1724
|
+
d >= this.minDistance && d < this.detectionThreshold && g && i.push({ element: c, distance: d }), y >= this.minDistance && y < this.detectionThreshold && g && a.push({ element: c, distance: y }), p >= this.minDistance && p < this.detectionThreshold && b && r.push({ element: c, distance: p }), u >= this.minDistance && u < this.detectionThreshold && b && l.push({ element: c, distance: u });
|
|
1723
1725
|
}
|
|
1724
|
-
i.sort((c,
|
|
1726
|
+
i.sort((c, f) => c.distance - f.distance), a.sort((c, f) => c.distance - f.distance), r.sort((c, f) => c.distance - f.distance), l.sort((c, f) => c.distance - f.distance);
|
|
1725
1727
|
const h = [];
|
|
1726
1728
|
if (s) {
|
|
1727
1729
|
const c = this.detectAllMeasurements(t, e);
|
|
@@ -1778,28 +1780,28 @@ class ln {
|
|
|
1778
1780
|
// bottom
|
|
1779
1781
|
) > i)
|
|
1780
1782
|
continue;
|
|
1781
|
-
let
|
|
1782
|
-
const
|
|
1783
|
-
h.x >= n.x + n.width ? (
|
|
1783
|
+
let f = 0, d = !1, y = 0, p = 0, u = 0;
|
|
1784
|
+
const b = -30 * (a % 2 === 0 ? 1 : -1);
|
|
1785
|
+
h.x >= n.x + n.width ? (f = h.x - (n.x + n.width), f >= this.minDistance && (d = !0, y = n.x + n.width, p = h.x, u = (n.y + n.height / 2 + h.y + h.height / 2) / 2 + b)) : n.x >= h.x + h.width && (f = n.x - (h.x + h.width), f >= this.minDistance && (d = !0, y = h.x + h.width, p = n.x, u = (n.y + n.height / 2 + h.y + h.height / 2) / 2 + b)), d && (s.push({
|
|
1784
1786
|
type: "horizontal",
|
|
1785
|
-
distance: Math.round(
|
|
1786
|
-
x1:
|
|
1787
|
-
x2:
|
|
1788
|
-
y:
|
|
1789
|
-
labelX: (
|
|
1790
|
-
labelY:
|
|
1787
|
+
distance: Math.round(f),
|
|
1788
|
+
x1: y,
|
|
1789
|
+
x2: p,
|
|
1790
|
+
y: u,
|
|
1791
|
+
labelX: (y + p) / 2,
|
|
1792
|
+
labelY: u,
|
|
1791
1793
|
isAltHover: !0
|
|
1792
1794
|
}), a++);
|
|
1793
|
-
let S = 0, m = !1, w = 0,
|
|
1794
|
-
const
|
|
1795
|
-
h.y >= n.y + n.height ? (S = h.y - (n.y + n.height), S >= this.minDistance && (m = !0, w = (n.x + n.width / 2 + h.x + h.width / 2) / 2 +
|
|
1795
|
+
let S = 0, m = !1, w = 0, v = 0, M = 0;
|
|
1796
|
+
const R = 30 * (r % 2 === 0 ? 1 : -1);
|
|
1797
|
+
h.y >= n.y + n.height ? (S = h.y - (n.y + n.height), S >= this.minDistance && (m = !0, w = (n.x + n.width / 2 + h.x + h.width / 2) / 2 + R, v = n.y + n.height, M = h.y)) : n.y >= h.y + h.height && (S = n.y - (h.y + h.height), S >= this.minDistance && (m = !0, w = (n.x + n.width / 2 + h.x + h.width / 2) / 2 + R, v = h.y + h.height, M = n.y)), m && (s.push({
|
|
1796
1798
|
type: "vertical",
|
|
1797
1799
|
distance: Math.round(S),
|
|
1798
1800
|
x: w,
|
|
1799
|
-
y1:
|
|
1800
|
-
y2:
|
|
1801
|
+
y1: v,
|
|
1802
|
+
y2: M,
|
|
1801
1803
|
labelX: w,
|
|
1802
|
-
labelY: (
|
|
1804
|
+
labelY: (v + M) / 2,
|
|
1803
1805
|
isAltHover: !0
|
|
1804
1806
|
}), r++);
|
|
1805
1807
|
}
|
|
@@ -1812,84 +1814,84 @@ class ln {
|
|
|
1812
1814
|
detectConsistentSpacing(t, e, s, n, o) {
|
|
1813
1815
|
const i = [], r = s[0], l = r.distance, h = r.element.getVisualBoundingBox(), c = this.checkIfWouldSnap(e, l, n, o);
|
|
1814
1816
|
if (this.addIndicatorForDirection(i, e, h, l, n, c), n === "left" || n === "right") {
|
|
1815
|
-
const
|
|
1816
|
-
if (
|
|
1817
|
-
const
|
|
1818
|
-
return !(e.y + e.height <
|
|
1817
|
+
const f = o.filter((d) => {
|
|
1818
|
+
if (d.id === t.id) return !1;
|
|
1819
|
+
const y = d.getVisualBoundingBox();
|
|
1820
|
+
return !(e.y + e.height < y.y || e.y > y.y + y.height);
|
|
1819
1821
|
});
|
|
1820
|
-
if (
|
|
1821
|
-
const
|
|
1822
|
-
return
|
|
1822
|
+
if (f.sort((d, y) => {
|
|
1823
|
+
const p = d.getVisualBoundingBox(), u = y.getVisualBoundingBox();
|
|
1824
|
+
return p.x - u.x;
|
|
1823
1825
|
}), n === "left")
|
|
1824
|
-
for (let
|
|
1825
|
-
const
|
|
1826
|
-
if (Math.abs(
|
|
1827
|
-
const S = Math.max(
|
|
1826
|
+
for (let d = 0; d < f.length - 1; d++) {
|
|
1827
|
+
const y = f[d], p = f[d + 1], u = y.getVisualBoundingBox(), g = p.getVisualBoundingBox(), b = g.x - (u.x + u.width);
|
|
1828
|
+
if (Math.abs(b - l) <= 16 && b >= this.minDistance) {
|
|
1829
|
+
const S = Math.max(u.y, g.y), m = Math.min(u.y + u.height, g.y + g.height), w = (S + m) / 2;
|
|
1828
1830
|
i.push({
|
|
1829
1831
|
type: "horizontal",
|
|
1830
|
-
distance: Math.round(
|
|
1831
|
-
x1:
|
|
1832
|
-
x2:
|
|
1832
|
+
distance: Math.round(b),
|
|
1833
|
+
x1: u.x + u.width,
|
|
1834
|
+
x2: g.x,
|
|
1833
1835
|
y: w,
|
|
1834
|
-
labelX: (
|
|
1836
|
+
labelX: (u.x + u.width + g.x) / 2,
|
|
1835
1837
|
labelY: w
|
|
1836
1838
|
});
|
|
1837
1839
|
}
|
|
1838
1840
|
}
|
|
1839
1841
|
else
|
|
1840
|
-
for (let
|
|
1841
|
-
const
|
|
1842
|
-
if (Math.abs(
|
|
1843
|
-
const S = Math.max(
|
|
1842
|
+
for (let d = 0; d < f.length - 1; d++) {
|
|
1843
|
+
const y = f[d], p = f[d + 1], u = y.getVisualBoundingBox(), g = p.getVisualBoundingBox(), b = g.x - (u.x + u.width);
|
|
1844
|
+
if (Math.abs(b - l) <= 16 && b >= this.minDistance) {
|
|
1845
|
+
const S = Math.max(u.y, g.y), m = Math.min(u.y + u.height, g.y + g.height), w = (S + m) / 2;
|
|
1844
1846
|
i.push({
|
|
1845
1847
|
type: "horizontal",
|
|
1846
|
-
distance: Math.round(
|
|
1847
|
-
x1:
|
|
1848
|
-
x2:
|
|
1848
|
+
distance: Math.round(b),
|
|
1849
|
+
x1: u.x + u.width,
|
|
1850
|
+
x2: g.x,
|
|
1849
1851
|
y: w,
|
|
1850
|
-
labelX: (
|
|
1852
|
+
labelX: (u.x + u.width + g.x) / 2,
|
|
1851
1853
|
labelY: w
|
|
1852
1854
|
});
|
|
1853
1855
|
}
|
|
1854
1856
|
}
|
|
1855
1857
|
} else {
|
|
1856
|
-
const
|
|
1857
|
-
if (
|
|
1858
|
-
const
|
|
1859
|
-
return !(e.x + e.width <
|
|
1858
|
+
const f = o.filter((d) => {
|
|
1859
|
+
if (d.id === t.id) return !1;
|
|
1860
|
+
const y = d.getVisualBoundingBox();
|
|
1861
|
+
return !(e.x + e.width < y.x || e.x > y.x + y.width);
|
|
1860
1862
|
});
|
|
1861
|
-
if (
|
|
1862
|
-
const
|
|
1863
|
-
return
|
|
1863
|
+
if (f.sort((d, y) => {
|
|
1864
|
+
const p = d.getVisualBoundingBox(), u = y.getVisualBoundingBox();
|
|
1865
|
+
return p.y - u.y;
|
|
1864
1866
|
}), n === "top")
|
|
1865
|
-
for (let
|
|
1866
|
-
const
|
|
1867
|
-
if (Math.abs(
|
|
1868
|
-
const S = Math.max(
|
|
1867
|
+
for (let d = 0; d < f.length - 1; d++) {
|
|
1868
|
+
const y = f[d], p = f[d + 1], u = y.getVisualBoundingBox(), g = p.getVisualBoundingBox(), b = g.y - (u.y + u.height);
|
|
1869
|
+
if (Math.abs(b - l) <= 16 && b >= this.minDistance) {
|
|
1870
|
+
const S = Math.max(u.x, g.x), m = Math.min(u.x + u.width, g.x + g.width), w = (S + m) / 2;
|
|
1869
1871
|
i.push({
|
|
1870
1872
|
type: "vertical",
|
|
1871
|
-
distance: Math.round(
|
|
1873
|
+
distance: Math.round(b),
|
|
1872
1874
|
x: w,
|
|
1873
|
-
y1:
|
|
1874
|
-
y2:
|
|
1875
|
+
y1: u.y + u.height,
|
|
1876
|
+
y2: g.y,
|
|
1875
1877
|
labelX: w,
|
|
1876
|
-
labelY: (
|
|
1878
|
+
labelY: (u.y + u.height + g.y) / 2
|
|
1877
1879
|
});
|
|
1878
1880
|
}
|
|
1879
1881
|
}
|
|
1880
1882
|
else
|
|
1881
|
-
for (let
|
|
1882
|
-
const
|
|
1883
|
-
if (Math.abs(
|
|
1884
|
-
const S = Math.max(
|
|
1883
|
+
for (let d = 0; d < f.length - 1; d++) {
|
|
1884
|
+
const y = f[d], p = f[d + 1], u = y.getVisualBoundingBox(), g = p.getVisualBoundingBox(), b = g.y - (u.y + u.height);
|
|
1885
|
+
if (Math.abs(b - l) <= 16 && b >= this.minDistance) {
|
|
1886
|
+
const S = Math.max(u.x, g.x), m = Math.min(u.x + u.width, g.x + g.width), w = (S + m) / 2;
|
|
1885
1887
|
i.push({
|
|
1886
1888
|
type: "vertical",
|
|
1887
|
-
distance: Math.round(
|
|
1889
|
+
distance: Math.round(b),
|
|
1888
1890
|
x: w,
|
|
1889
|
-
y1:
|
|
1890
|
-
y2:
|
|
1891
|
+
y1: u.y + u.height,
|
|
1892
|
+
y2: g.y,
|
|
1891
1893
|
labelX: w,
|
|
1892
|
-
labelY: (
|
|
1894
|
+
labelY: (u.y + u.height + g.y) / 2
|
|
1893
1895
|
});
|
|
1894
1896
|
}
|
|
1895
1897
|
}
|
|
@@ -1900,7 +1902,7 @@ class ln {
|
|
|
1900
1902
|
* Check if spacing would snap to a pattern
|
|
1901
1903
|
*/
|
|
1902
1904
|
checkIfWouldSnap(t, e, s, n) {
|
|
1903
|
-
const o =
|
|
1905
|
+
const o = jt;
|
|
1904
1906
|
if (s === "top" || s === "bottom") {
|
|
1905
1907
|
const i = n.filter((a) => {
|
|
1906
1908
|
const r = a.getVisualBoundingBox();
|
|
@@ -1917,7 +1919,7 @@ class ln {
|
|
|
1917
1919
|
a.push(c);
|
|
1918
1920
|
}
|
|
1919
1921
|
if (a.length > 0) {
|
|
1920
|
-
const r = a.reduce((c,
|
|
1922
|
+
const r = a.reduce((c, f) => c + f, 0) / a.length;
|
|
1921
1923
|
return Math.abs(e - r) <= o;
|
|
1922
1924
|
}
|
|
1923
1925
|
}
|
|
@@ -1938,7 +1940,7 @@ class ln {
|
|
|
1938
1940
|
a.push(c);
|
|
1939
1941
|
}
|
|
1940
1942
|
if (a.length > 0) {
|
|
1941
|
-
const r = a.reduce((c,
|
|
1943
|
+
const r = a.reduce((c, f) => c + f, 0) / a.length;
|
|
1942
1944
|
return Math.abs(e - r) <= o;
|
|
1943
1945
|
}
|
|
1944
1946
|
}
|
|
@@ -2000,7 +2002,7 @@ class ln {
|
|
|
2000
2002
|
}
|
|
2001
2003
|
}
|
|
2002
2004
|
}
|
|
2003
|
-
const
|
|
2005
|
+
const Gt = ae("ArtboardRenderer"), sn = {
|
|
2004
2006
|
showLabel: !0,
|
|
2005
2007
|
showBorder: !0,
|
|
2006
2008
|
borderColor: "",
|
|
@@ -2018,9 +2020,9 @@ const zt = te("ArtboardRenderer"), $e = {
|
|
|
2018
2020
|
borderRadius: 0
|
|
2019
2021
|
// Default to no border radius (sharp corners)
|
|
2020
2022
|
};
|
|
2021
|
-
class
|
|
2023
|
+
class fe {
|
|
2022
2024
|
constructor(t = {}) {
|
|
2023
|
-
this.options = {
|
|
2025
|
+
this.options = { ...sn, ...t };
|
|
2024
2026
|
}
|
|
2025
2027
|
/**
|
|
2026
2028
|
* Render an artboard
|
|
@@ -2042,10 +2044,10 @@ class ie {
|
|
|
2042
2044
|
* Renders preset color as base layer, then texture on top
|
|
2043
2045
|
*/
|
|
2044
2046
|
renderTextureBackground(t, e) {
|
|
2045
|
-
const s =
|
|
2047
|
+
const s = Vt.getTexture(e.backgroundTexture), n = Vt.getTexturePresetColor(e.backgroundTexture);
|
|
2046
2048
|
if (t.fillStyle = n, t.fillRect(e.x, e.y, e.width, e.height), !s || !s.complete) {
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
+
Vt.loadTexture(e.backgroundTexture).catch((o) => {
|
|
2050
|
+
Gt.error("Failed to load texture:", o);
|
|
2049
2051
|
});
|
|
2050
2052
|
return;
|
|
2051
2053
|
}
|
|
@@ -2066,7 +2068,7 @@ class ie {
|
|
|
2066
2068
|
* Render artboard border (respects clipShape and borderRadius option)
|
|
2067
2069
|
*/
|
|
2068
2070
|
renderBorder(t, e, s) {
|
|
2069
|
-
const { x: n, y: o, width: i, height: a, clipShape: r } = e, l = this.options.borderColor ||
|
|
2071
|
+
const { x: n, y: o, width: i, height: a, clipShape: r } = e, l = this.options.borderColor || we(), h = this.options.selectedBorderColor || nt();
|
|
2070
2072
|
if (t.strokeStyle = s ? h : l, t.lineWidth = s ? this.options.selectedBorderWidth : this.options.borderWidth, t.beginPath(), !r || r === "rectangle")
|
|
2071
2073
|
if (this.options.borderRadius > 0) {
|
|
2072
2074
|
const c = Math.min(this.options.borderRadius, Math.min(i, a) / 2);
|
|
@@ -2074,8 +2076,8 @@ class ie {
|
|
|
2074
2076
|
} else
|
|
2075
2077
|
t.rect(n, o, i, a);
|
|
2076
2078
|
else if (r === "circle") {
|
|
2077
|
-
const c = n + i / 2,
|
|
2078
|
-
t.arc(c,
|
|
2079
|
+
const c = n + i / 2, f = o + a / 2, d = Math.min(i, a) / 2;
|
|
2080
|
+
t.arc(c, f, d, 0, Math.PI * 2);
|
|
2079
2081
|
} else if (typeof r == "object" && r.type === "rounded") {
|
|
2080
2082
|
const c = Math.min(r.radius, Math.min(i, a) / 2);
|
|
2081
2083
|
this.roundedRect(t, n, o, i, a, c);
|
|
@@ -2085,7 +2087,7 @@ class ie {
|
|
|
2085
2087
|
t.save(), t.translate(n, o), t.stroke(c), t.restore();
|
|
2086
2088
|
return;
|
|
2087
2089
|
} catch (c) {
|
|
2088
|
-
|
|
2090
|
+
Gt.warn("Invalid SVG path for border, falling back to rectangle:", c), t.rect(n, o, i, a);
|
|
2089
2091
|
}
|
|
2090
2092
|
t.stroke();
|
|
2091
2093
|
}
|
|
@@ -2095,7 +2097,7 @@ class ie {
|
|
|
2095
2097
|
renderLabel(t, e, s) {
|
|
2096
2098
|
const n = this.options.labelFontSize, o = this.options.labelPadding, i = `${e.name} (${Math.round(e.width)} × ${Math.round(e.height)})`, a = e.x, r = e.y - o;
|
|
2097
2099
|
t.font = `${n}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
|
|
2098
|
-
const l = this.options.selectedBorderColor || nt(), h = this.options.labelColor ||
|
|
2100
|
+
const l = this.options.selectedBorderColor || nt(), h = this.options.labelColor || ve();
|
|
2099
2101
|
t.fillStyle = s ? l : h, t.textAlign = "left", t.textBaseline = "bottom", t.fillText(i, a, r);
|
|
2100
2102
|
}
|
|
2101
2103
|
/**
|
|
@@ -2139,7 +2141,7 @@ class ie {
|
|
|
2139
2141
|
t.translate(s, n), t.clip(r), t.translate(-s, -n);
|
|
2140
2142
|
return;
|
|
2141
2143
|
} catch (r) {
|
|
2142
|
-
|
|
2144
|
+
Gt.warn("Invalid SVG path, falling back to rectangle:", r), t.rect(s, n, o, i);
|
|
2143
2145
|
}
|
|
2144
2146
|
t.clip();
|
|
2145
2147
|
}
|
|
@@ -2198,7 +2200,7 @@ class ie {
|
|
|
2198
2200
|
* Use this when exporting to ensure preview background is never included
|
|
2199
2201
|
*/
|
|
2200
2202
|
static createForExport(t = {}) {
|
|
2201
|
-
return new
|
|
2203
|
+
return new fe({
|
|
2202
2204
|
...t,
|
|
2203
2205
|
showPreviewBackground: !1
|
|
2204
2206
|
// CRITICAL: Never show preview in exports
|
|
@@ -2211,8 +2213,50 @@ class ie {
|
|
|
2211
2213
|
return !!(this.options.showPreviewBackground && t.previewBackgroundColor && t.previewBackgroundColor !== "transparent");
|
|
2212
2214
|
}
|
|
2213
2215
|
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
+
const on = 300, an = 15e5;
|
|
2217
|
+
let It = { sig: "", mask: null }, Bt = "", Ht = null, Xt = !1;
|
|
2218
|
+
function Rn() {
|
|
2219
|
+
const T = Xt;
|
|
2220
|
+
return Xt = !1, T;
|
|
2221
|
+
}
|
|
2222
|
+
function se(T) {
|
|
2223
|
+
const t = /^#?([0-9a-f]{6})$/i.exec(T.trim()), e = t ? parseInt(t[1], 16) : 0;
|
|
2224
|
+
return [e >> 16 & 255, e >> 8 & 255, e & 255];
|
|
2225
|
+
}
|
|
2226
|
+
function rn(T, t, e) {
|
|
2227
|
+
const s = T.getTransform(), n = Math.round(s.a * e.x + s.e), o = Math.round(s.d * e.y + s.f), i = Math.round(s.a * e.width), a = Math.round(s.d * e.height);
|
|
2228
|
+
if (i <= 0 || a <= 0) return;
|
|
2229
|
+
const r = T.canvas, l = Math.max(0, n), h = Math.max(0, o), c = Math.min(r.width, n + i), f = Math.min(r.height, o + a), d = c - l, y = f - h;
|
|
2230
|
+
if (d <= 0 || y <= 0) return;
|
|
2231
|
+
const p = T.getImageData(l, h, d, y), u = p.data, g = d * y, b = new Uint8Array(g);
|
|
2232
|
+
let S = 2166136261, m = 0;
|
|
2233
|
+
for (let k = 0; k < g; k++) {
|
|
2234
|
+
const P = k * 4;
|
|
2235
|
+
Oe(u[P], u[P + 1], u[P + 2], u[P + 3]) >= ce && (b[k] = 1, S = Math.imul(S ^ k, 16777619), m++);
|
|
2236
|
+
}
|
|
2237
|
+
const w = `${d}x${y}:${s.a * 1e3 | 0}:${t.dpi}:${S >>> 0}:${m}`, [v, M, C] = se(t.cut), [R, I, x] = se(t.coat), A = It.sig === w ? It.mask : null;
|
|
2238
|
+
for (let k = 0; k < g; k++) {
|
|
2239
|
+
const P = k * 4;
|
|
2240
|
+
b[k] ? A && A[k] ? (u[P] = _t[0], u[P + 1] = _t[1], u[P + 2] = _t[2]) : (u[P] = v, u[P + 1] = M, u[P + 2] = C) : (u[P] = R, u[P + 1] = I, u[P + 2] = x), u[P + 3] = 255;
|
|
2241
|
+
}
|
|
2242
|
+
T.putImageData(p, l, h), It.sig !== w && Bt !== w && ln(w, b, d, y, Ye(t.dpi) * s.a);
|
|
2243
|
+
}
|
|
2244
|
+
function ln(T, t, e, s, n) {
|
|
2245
|
+
Bt = T, Ht && clearTimeout(Ht), Ht = setTimeout(() => {
|
|
2246
|
+
if (Ht = null, Bt !== T) return;
|
|
2247
|
+
const o = Math.max(1, Math.ceil(Math.sqrt(e * s / an))), i = Math.ceil(e / o), a = Math.ceil(s / o), r = new Float32Array(i * a);
|
|
2248
|
+
for (let d = 0; d < s; d++) for (let y = 0; y < e; y++) t[d * e + y] && (r[(d / o | 0) * i + (y / o | 0)] += 1 / (o * o));
|
|
2249
|
+
const l = { width: i, height: a, value: r }, { mask: h, count: c } = Ge(l, ce, n / o);
|
|
2250
|
+
let f = null;
|
|
2251
|
+
if (c > 0) {
|
|
2252
|
+
f = new Uint8Array(e * s);
|
|
2253
|
+
for (let d = 0; d < s; d++) for (let y = 0; y < e; y++) f[d * e + y] = h[(d / o | 0) * i + (y / o | 0)];
|
|
2254
|
+
}
|
|
2255
|
+
It = { sig: T, mask: f, thinParts: c }, Bt = "", Xt = !0;
|
|
2256
|
+
}, on);
|
|
2257
|
+
}
|
|
2258
|
+
function hn(T) {
|
|
2259
|
+
const t = (T % 360 + 360) % 360;
|
|
2216
2260
|
if (t === 0) return [1, 0];
|
|
2217
2261
|
if (t === 90) return [0, 1];
|
|
2218
2262
|
if (t === 180) return [-1, 0];
|
|
@@ -2220,28 +2264,28 @@ function je(v) {
|
|
|
2220
2264
|
const e = t * Math.PI / 180;
|
|
2221
2265
|
return [Math.cos(e), Math.sin(e)];
|
|
2222
2266
|
}
|
|
2223
|
-
function
|
|
2224
|
-
const [s, n] =
|
|
2225
|
-
return { width: Math.abs(
|
|
2267
|
+
function oe(T, t, e) {
|
|
2268
|
+
const [s, n] = hn(e);
|
|
2269
|
+
return { width: Math.abs(T * s) + Math.abs(t * n), height: Math.abs(T * n) + Math.abs(t * s) };
|
|
2226
2270
|
}
|
|
2227
|
-
function
|
|
2228
|
-
if (
|
|
2229
|
-
const t = ((
|
|
2271
|
+
function ge(T) {
|
|
2272
|
+
if (T.naturalWidth && T.naturalHeight) return { width: T.naturalWidth, height: T.naturalHeight };
|
|
2273
|
+
const t = ((T.rotation ?? 0) % 360 + 360) % 360;
|
|
2230
2274
|
if (t % 90 !== 0)
|
|
2231
|
-
throw new Error(`E_PIECE_NATURAL_DIMS: piece "${
|
|
2232
|
-
return t === 90 || t === 270 ? { width:
|
|
2275
|
+
throw new Error(`E_PIECE_NATURAL_DIMS: piece "${T.id ?? "?"}" is turned ${t}° but carries no naturalWidth/naturalHeight — the displayed box of a non-right angle doesn't determine them. Send them with the piece (the /piece-guides endpoint does)`);
|
|
2276
|
+
return t === 90 || t === 270 ? { width: T.height, height: T.width } : { width: T.width, height: T.height };
|
|
2233
2277
|
}
|
|
2234
|
-
function
|
|
2235
|
-
const t = ((
|
|
2278
|
+
function Cn(T) {
|
|
2279
|
+
const t = ((T.rotation ?? 0) % 360 + 360) % 360;
|
|
2236
2280
|
if (!t) return "";
|
|
2237
|
-
const e =
|
|
2238
|
-
return `translate(${
|
|
2281
|
+
const e = ge(T);
|
|
2282
|
+
return `translate(${T.width / 2} ${T.height / 2}) rotate(${t}) translate(${-e.width / 2} ${-e.height / 2})`;
|
|
2239
2283
|
}
|
|
2240
|
-
function
|
|
2284
|
+
function kn(T, t) {
|
|
2241
2285
|
const e = ((t.rotation ?? 0) % 360 + 360) % 360;
|
|
2242
2286
|
if (!e) return;
|
|
2243
|
-
const s =
|
|
2244
|
-
|
|
2287
|
+
const s = ge(t);
|
|
2288
|
+
T.translate(t.width / 2, t.height / 2), T.rotate(e * Math.PI / 180), T.translate(-s.width / 2, -s.height / 2);
|
|
2245
2289
|
}
|
|
2246
2290
|
class wt {
|
|
2247
2291
|
/**
|
|
@@ -2265,40 +2309,40 @@ class wt {
|
|
|
2265
2309
|
*/
|
|
2266
2310
|
static renderPositionSizeInfo(t, e, s, n, o = 1) {
|
|
2267
2311
|
if (!e || !(s != null && s.rotationHandle) || (n == null ? void 0 : n.getMode()) !== "resize") return;
|
|
2268
|
-
const i = e.getVisualBoundingBox(), a = Math.round(i.width), r = Math.round(i.height), l = `${a} × ${r}`, h = s.rotationHandle, c = h.x * o,
|
|
2312
|
+
const i = e.getVisualBoundingBox(), a = Math.round(i.width), r = Math.round(i.height), l = `${a} × ${r}`, h = s.rotationHandle, c = h.x * o, f = h.y * o - 20;
|
|
2269
2313
|
t.save(), t.font = "10px system-ui, -apple-system, sans-serif";
|
|
2270
|
-
const
|
|
2271
|
-
t.shadowColor =
|
|
2272
|
-
c -
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2314
|
+
const y = t.measureText(l).width + 12, p = 18;
|
|
2315
|
+
t.shadowColor = Me(t.canvas), t.shadowBlur = 4, t.shadowOffsetY = 1, t.fillStyle = xe(t.canvas), t.beginPath(), t.roundRect(
|
|
2316
|
+
c - y / 2,
|
|
2317
|
+
f - p / 2,
|
|
2318
|
+
y,
|
|
2319
|
+
p,
|
|
2276
2320
|
3
|
|
2277
2321
|
// Smaller border radius
|
|
2278
|
-
), t.fill(), t.shadowColor = "transparent", t.shadowBlur = 0, t.shadowOffsetY = 0, t.fillStyle =
|
|
2322
|
+
), t.fill(), t.shadowColor = "transparent", t.shadowBlur = 0, t.shadowOffsetY = 0, t.fillStyle = Re(t.canvas), t.textAlign = "center", t.textBaseline = "middle", t.fillText(l, c, f + 0.5), t.restore();
|
|
2279
2323
|
}
|
|
2280
2324
|
/**
|
|
2281
2325
|
* Render transform handles layer
|
|
2282
2326
|
*/
|
|
2283
2327
|
static renderHandlesLayer(t, e, s, n, o, i, a, r = 1, l = !0) {
|
|
2284
2328
|
if (!e || e.visible === !1 || a.getMode() === "drag") return;
|
|
2285
|
-
const c = i.type === "rotation-handle",
|
|
2329
|
+
const c = i.type === "rotation-handle", f = i.type === "resize-handle" ? i.data : null, d = a.getMode() === "resize", y = d ? a.getActiveHandle() : null;
|
|
2286
2330
|
s.render(
|
|
2287
2331
|
t,
|
|
2288
2332
|
l,
|
|
2289
2333
|
n,
|
|
2290
2334
|
o,
|
|
2291
2335
|
c,
|
|
2336
|
+
f,
|
|
2292
2337
|
d,
|
|
2293
|
-
|
|
2294
|
-
b,
|
|
2338
|
+
y,
|
|
2295
2339
|
r,
|
|
2296
2340
|
!0
|
|
2297
2341
|
// Render rotation handle on canvas (not React)
|
|
2298
2342
|
);
|
|
2299
2343
|
}
|
|
2300
2344
|
}
|
|
2301
|
-
class
|
|
2345
|
+
class Nt {
|
|
2302
2346
|
/**
|
|
2303
2347
|
* Render hover highlights layer with fade-in animation
|
|
2304
2348
|
* Outlines the actual element shape instead of a rectangular border
|
|
@@ -2313,7 +2357,7 @@ class Ft {
|
|
|
2313
2357
|
const c = performance.now() - e.startTime;
|
|
2314
2358
|
h = Math.min(c / r, 1) * l;
|
|
2315
2359
|
}
|
|
2316
|
-
t.strokeStyle =
|
|
2360
|
+
t.strokeStyle = Ce(t.canvas), t.globalAlpha = h, t.lineWidth = 3, this.renderElementOutline(t, a, o, i), t.restore();
|
|
2317
2361
|
}
|
|
2318
2362
|
/**
|
|
2319
2363
|
* Render outline for a specific element type
|
|
@@ -2330,12 +2374,12 @@ class Ft {
|
|
|
2330
2374
|
const n = e.transformData, o = n.width * s, i = n.height * s, a = 2, l = a + a / 2;
|
|
2331
2375
|
switch (t.save(), t.translate(e.x * s, e.y * s), t.beginPath(), n.shapeType) {
|
|
2332
2376
|
case "rectangle": {
|
|
2333
|
-
const h = n.borderRadius || 0, c = -(o + l * 2) / 2,
|
|
2377
|
+
const h = n.borderRadius || 0, c = -(o + l * 2) / 2, f = -(i + l * 2) / 2, d = o + l * 2, y = i + l * 2;
|
|
2334
2378
|
if (h > 0) {
|
|
2335
|
-
const
|
|
2336
|
-
t.roundRect(c,
|
|
2379
|
+
const p = Math.min(h / 100 * Math.min(d, y), d / 2, y / 2);
|
|
2380
|
+
t.roundRect(c, f, d, y, p);
|
|
2337
2381
|
} else
|
|
2338
|
-
t.rect(c,
|
|
2382
|
+
t.rect(c, f, d, y);
|
|
2339
2383
|
break;
|
|
2340
2384
|
}
|
|
2341
2385
|
case "circle": {
|
|
@@ -2349,40 +2393,40 @@ class Ft {
|
|
|
2349
2393
|
break;
|
|
2350
2394
|
}
|
|
2351
2395
|
case "triangle": {
|
|
2352
|
-
const h = o / 2, c = i / 2,
|
|
2396
|
+
const h = o / 2, c = i / 2, f = [
|
|
2353
2397
|
{ x: 0, y: -c },
|
|
2354
2398
|
// top
|
|
2355
2399
|
{ x: h, y: c },
|
|
2356
2400
|
// bottom-right
|
|
2357
2401
|
{ x: -h, y: c }
|
|
2358
2402
|
// bottom-left
|
|
2359
|
-
],
|
|
2360
|
-
const
|
|
2361
|
-
return { x: S / m, y: -
|
|
2362
|
-
}),
|
|
2363
|
-
const
|
|
2403
|
+
], d = f.map((p, u) => {
|
|
2404
|
+
const g = f[(u + 1) % 3], b = g.x - p.x, S = g.y - p.y, m = Math.sqrt(b * b + S * S);
|
|
2405
|
+
return { x: S / m, y: -b / m };
|
|
2406
|
+
}), y = f.map((p, u) => {
|
|
2407
|
+
const g = d[(u + 2) % 3], b = d[u], S = g.x + b.x, m = g.y + b.y, w = Math.sqrt(S * S + m * m), v = (S * g.x + m * g.y) / w, M = l / v;
|
|
2364
2408
|
return {
|
|
2365
|
-
x:
|
|
2366
|
-
y:
|
|
2409
|
+
x: p.x + S / w * M,
|
|
2410
|
+
y: p.y + m / w * M
|
|
2367
2411
|
};
|
|
2368
2412
|
});
|
|
2369
|
-
t.moveTo(
|
|
2413
|
+
t.moveTo(y[0].x, y[0].y), t.lineTo(y[1].x, y[1].y), t.lineTo(y[2].x, y[2].y), t.closePath();
|
|
2370
2414
|
break;
|
|
2371
2415
|
}
|
|
2372
2416
|
case "star": {
|
|
2373
|
-
const h = n.points ?? 5, c = n.innerRadius ?? 0.4,
|
|
2374
|
-
for (let
|
|
2375
|
-
const
|
|
2376
|
-
|
|
2417
|
+
const h = n.points ?? 5, c = n.innerRadius ?? 0.4, f = Math.min(o, i) / 2 + l, d = f * c;
|
|
2418
|
+
for (let y = 0; y < h * 2; y++) {
|
|
2419
|
+
const p = y * Math.PI / h - Math.PI / 2, u = y % 2 === 0 ? f : d, g = u * Math.cos(p), b = u * Math.sin(p);
|
|
2420
|
+
y === 0 ? t.moveTo(g, b) : t.lineTo(g, b);
|
|
2377
2421
|
}
|
|
2378
2422
|
t.closePath();
|
|
2379
2423
|
break;
|
|
2380
2424
|
}
|
|
2381
2425
|
case "polygon": {
|
|
2382
2426
|
const h = n.sides ?? 5, c = Math.min(o, i) / 2 + l;
|
|
2383
|
-
for (let
|
|
2384
|
-
const
|
|
2385
|
-
|
|
2427
|
+
for (let f = 0; f < h; f++) {
|
|
2428
|
+
const d = f * 2 * Math.PI / h - Math.PI / 2, y = c * Math.cos(d), p = c * Math.sin(d);
|
|
2429
|
+
f === 0 ? t.moveTo(y, p) : t.lineTo(y, p);
|
|
2386
2430
|
}
|
|
2387
2431
|
t.closePath();
|
|
2388
2432
|
break;
|
|
@@ -2400,15 +2444,15 @@ class Ft {
|
|
|
2400
2444
|
* Creates a ring effect with a gap between the element and the stroke
|
|
2401
2445
|
*/
|
|
2402
2446
|
static renderImageOutline(t, e, s) {
|
|
2403
|
-
var
|
|
2404
|
-
const n = e.getVisualBoundingBox(), o = n.width * s, i = n.height * s, a = ((
|
|
2447
|
+
var p;
|
|
2448
|
+
const n = e.getVisualBoundingBox(), o = n.width * s, i = n.height * s, a = ((p = e.transformData) == null ? void 0 : p.borderRadius) || 0, r = 2, h = r + r / 2;
|
|
2405
2449
|
t.save(), t.translate(e.x * s, e.y * s);
|
|
2406
|
-
const c = -(o + h * 2) / 2,
|
|
2450
|
+
const c = -(o + h * 2) / 2, f = -(i + h * 2) / 2, d = o + h * 2, y = i + h * 2;
|
|
2407
2451
|
if (t.beginPath(), a > 0) {
|
|
2408
|
-
const
|
|
2409
|
-
t.roundRect(c,
|
|
2452
|
+
const u = Math.min(a / 100 * Math.min(d, y), d / 2, y / 2);
|
|
2453
|
+
t.roundRect(c, f, d, y, u);
|
|
2410
2454
|
} else
|
|
2411
|
-
t.rect(c,
|
|
2455
|
+
t.rect(c, f, d, y);
|
|
2412
2456
|
t.stroke(), t.restore();
|
|
2413
2457
|
}
|
|
2414
2458
|
/**
|
|
@@ -2441,100 +2485,100 @@ class Ft {
|
|
|
2441
2485
|
*/
|
|
2442
2486
|
static renderHoverRingEffect(t, e, s) {
|
|
2443
2487
|
t.save(), t.translate(e.x * s, e.y * s), s !== 1 && t.scale(s, s);
|
|
2444
|
-
const n = e.fontSize, o = e.fontFamily, i = e.bold || !1, a = e.italic || !1, r = e.textAlign || "center", l =
|
|
2445
|
-
|
|
2446
|
-
const
|
|
2447
|
-
if (!
|
|
2488
|
+
const n = e.fontSize, o = e.fontFamily, i = e.bold || !1, a = e.italic || !1, r = e.textAlign || "center", l = re(n, o, i, a), h = n * (e.lineHeight ?? 1.2), c = e.letterSpacing ?? 0, f = 4 / s, d = 4 / s, y = document.createElement("canvas");
|
|
2489
|
+
y.width = t.canvas.width, y.height = t.canvas.height;
|
|
2490
|
+
const p = y.getContext("2d");
|
|
2491
|
+
if (!p) {
|
|
2448
2492
|
t.restore();
|
|
2449
2493
|
return;
|
|
2450
2494
|
}
|
|
2451
|
-
|
|
2452
|
-
const
|
|
2453
|
-
if (
|
|
2454
|
-
const
|
|
2455
|
-
|
|
2495
|
+
p.setTransform(t.getTransform()), p.textBaseline = "alphabetic", p.lineJoin = "round";
|
|
2496
|
+
const u = e.getRichText ? e.getRichText() : null;
|
|
2497
|
+
if (u) {
|
|
2498
|
+
const g = le(u), b = [], S = [];
|
|
2499
|
+
g.forEach((v) => {
|
|
2456
2500
|
if (e.transformType === "custom" && e.transformData) {
|
|
2457
|
-
const
|
|
2501
|
+
const M = e.transformData.width - pt * 2, C = he(v, M, {
|
|
2458
2502
|
fontSize: n,
|
|
2459
2503
|
fontFamily: o,
|
|
2460
2504
|
bold: i,
|
|
2461
2505
|
italic: a,
|
|
2462
2506
|
letterSpacing: e.letterSpacing
|
|
2463
2507
|
});
|
|
2464
|
-
C.forEach((
|
|
2465
|
-
|
|
2508
|
+
C.forEach((R, I) => {
|
|
2509
|
+
b.push(R), S.push({
|
|
2466
2510
|
isParagraphStart: I === 0,
|
|
2467
2511
|
isParagraphEnd: I === C.length - 1
|
|
2468
2512
|
});
|
|
2469
2513
|
});
|
|
2470
2514
|
} else
|
|
2471
|
-
|
|
2515
|
+
b.push(v), S.push({
|
|
2472
2516
|
isParagraphStart: !0,
|
|
2473
2517
|
isParagraphEnd: !0
|
|
2474
2518
|
});
|
|
2475
2519
|
});
|
|
2476
2520
|
let m;
|
|
2477
|
-
|
|
2521
|
+
b.length === 0 ? m = 0 : b.length === 1 ? m = l.height : m = (b.length - 1) * h + l.height;
|
|
2478
2522
|
const w = -m / 2;
|
|
2479
|
-
|
|
2523
|
+
b.forEach((v, M) => {
|
|
2480
2524
|
var V, j;
|
|
2481
|
-
const C = S[
|
|
2525
|
+
const C = S[M].isParagraphStart, R = S[M].isParagraphEnd;
|
|
2482
2526
|
let I = 0;
|
|
2483
|
-
const
|
|
2484
|
-
let
|
|
2485
|
-
|
|
2486
|
-
const z =
|
|
2487
|
-
let
|
|
2488
|
-
const O =
|
|
2489
|
-
if (!C &&
|
|
2490
|
-
const
|
|
2491
|
-
|
|
2527
|
+
const x = v.map((B) => B.text).join(""), A = ((V = x.match(/^ +/)) == null ? void 0 : V[0].length) || 0, k = ((j = x.match(/ +$/)) == null ? void 0 : j[0].length) || 0;
|
|
2528
|
+
let P = 0;
|
|
2529
|
+
v.forEach((B) => {
|
|
2530
|
+
const z = B.style.fontSize !== void 0 ? B.style.fontSize : n, $ = B.style.fontFamily !== void 0 ? B.style.fontFamily : o, Q = B.style.bold !== void 0 ? B.style.bold : i, L = B.style.italic !== void 0 ? B.style.italic : a;
|
|
2531
|
+
let E = B.text;
|
|
2532
|
+
const O = P, X = P + B.text.length;
|
|
2533
|
+
if (!C && A > 0 && O < A) {
|
|
2534
|
+
const H = Math.min(A - O, B.text.length);
|
|
2535
|
+
E = E.substring(H);
|
|
2492
2536
|
}
|
|
2493
|
-
if (!
|
|
2494
|
-
const
|
|
2495
|
-
if (X >
|
|
2496
|
-
const
|
|
2497
|
-
|
|
2537
|
+
if (!R && k > 0) {
|
|
2538
|
+
const H = x.length - k;
|
|
2539
|
+
if (X > H) {
|
|
2540
|
+
const W = !C && O < A ? Math.min(A - O, B.text.length) : 0, U = Math.max(0, H - O - W);
|
|
2541
|
+
E = E.substring(0, U);
|
|
2498
2542
|
}
|
|
2499
2543
|
}
|
|
2500
|
-
if (
|
|
2501
|
-
const
|
|
2502
|
-
t.save(), t.font =
|
|
2544
|
+
if (E.length > 0) {
|
|
2545
|
+
const H = B.style.letterSpacing !== void 0 ? B.style.letterSpacing : c;
|
|
2546
|
+
t.save(), t.font = zt(z, $, Q, L), I += qt(t.measureText(E).width, E, H), t.restore();
|
|
2503
2547
|
}
|
|
2504
|
-
|
|
2548
|
+
P += B.text.length;
|
|
2505
2549
|
});
|
|
2506
|
-
const
|
|
2550
|
+
const D = e.transformType === "custom" && e.transformData ? e.transformData.width - pt * 2 : void 0;
|
|
2507
2551
|
let _;
|
|
2508
|
-
r === "center" ? _ = -I / 2 : r === "right" ? _ =
|
|
2509
|
-
const
|
|
2510
|
-
|
|
2511
|
-
const z =
|
|
2512
|
-
|
|
2513
|
-
const Q =
|
|
2514
|
-
let
|
|
2515
|
-
const O =
|
|
2516
|
-
if (!C &&
|
|
2517
|
-
const
|
|
2518
|
-
|
|
2552
|
+
r === "center" ? _ = -I / 2 : r === "right" ? _ = D !== void 0 ? D / 2 - I : -I : _ = D !== void 0 ? -D / 2 : 0;
|
|
2553
|
+
const Y = w + l.ascent + M * h;
|
|
2554
|
+
P = 0, v.forEach((B) => {
|
|
2555
|
+
const z = B.style.fontSize !== void 0 ? B.style.fontSize : n, $ = B.style.fontFamily !== void 0 ? B.style.fontFamily : o;
|
|
2556
|
+
B.style.color !== void 0 ? B.style.color : e.color;
|
|
2557
|
+
const Q = B.style.bold !== void 0 ? B.style.bold : i, L = B.style.italic !== void 0 ? B.style.italic : a;
|
|
2558
|
+
let E = B.text;
|
|
2559
|
+
const O = P, X = P + B.text.length;
|
|
2560
|
+
if (!C && A > 0 && O < A) {
|
|
2561
|
+
const H = Math.min(A - O, B.text.length);
|
|
2562
|
+
E = E.substring(H);
|
|
2519
2563
|
}
|
|
2520
|
-
if (!
|
|
2521
|
-
const
|
|
2522
|
-
if (X >
|
|
2523
|
-
const
|
|
2524
|
-
|
|
2564
|
+
if (!R && k > 0) {
|
|
2565
|
+
const H = x.length - k;
|
|
2566
|
+
if (X > H) {
|
|
2567
|
+
const W = !C && O < A ? Math.min(A - O, B.text.length) : 0, U = Math.max(0, H - O - W);
|
|
2568
|
+
E = E.substring(0, U);
|
|
2525
2569
|
}
|
|
2526
2570
|
}
|
|
2527
|
-
if (
|
|
2528
|
-
const
|
|
2529
|
-
|
|
2571
|
+
if (P += B.text.length, E.length > 0) {
|
|
2572
|
+
const H = B.style.letterSpacing !== void 0 ? B.style.letterSpacing : c;
|
|
2573
|
+
p.font = zt(z, $, Q, L), p.textAlign = "left", p.globalCompositeOperation = "source-over", p.strokeStyle = t.strokeStyle, p.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), p.lineWidth = (d + f) * 2, At(p, E, _, Y, H), p.globalCompositeOperation = "destination-out", p.globalAlpha = 1, p.lineWidth = d * 2, At(p, E, _, Y, H), Ut(p, E, _, Y, H), _ += qt(p.measureText(E).width, E, H);
|
|
2530
2574
|
}
|
|
2531
2575
|
});
|
|
2532
2576
|
});
|
|
2533
2577
|
} else {
|
|
2534
|
-
t.font =
|
|
2535
|
-
let
|
|
2578
|
+
t.font = zt(n, o, i, a), p.font = t.font, p.textAlign = r;
|
|
2579
|
+
let g, b;
|
|
2536
2580
|
if (e.transformType === "custom" && e.transformData) {
|
|
2537
|
-
const C = e.transformData.width - pt * 2, { lines:
|
|
2581
|
+
const C = e.transformData.width - pt * 2, { lines: R } = ke(
|
|
2538
2582
|
e.text,
|
|
2539
2583
|
C,
|
|
2540
2584
|
n,
|
|
@@ -2545,25 +2589,25 @@ class Ft {
|
|
|
2545
2589
|
!0,
|
|
2546
2590
|
{ letterSpacing: c, lineHeight: e.lineHeight }
|
|
2547
2591
|
);
|
|
2548
|
-
|
|
2592
|
+
g = R;
|
|
2549
2593
|
} else {
|
|
2550
|
-
|
|
2594
|
+
g = e.text.split(`
|
|
2551
2595
|
`);
|
|
2552
2596
|
const C = e.text.includes(`
|
|
2553
2597
|
`);
|
|
2554
|
-
|
|
2598
|
+
g = De(g, C);
|
|
2555
2599
|
}
|
|
2556
|
-
|
|
2557
|
-
const S = -
|
|
2558
|
-
`), w = e.transformType === "custom" && e.transformData ? e.transformData.width : 0,
|
|
2559
|
-
let
|
|
2560
|
-
r === "center" ?
|
|
2561
|
-
const I = S + l.ascent +
|
|
2562
|
-
let
|
|
2563
|
-
|
|
2600
|
+
g.length === 0 ? b = 0 : g.length === 1 ? b = l.height : b = (g.length - 1) * h + l.height;
|
|
2601
|
+
const S = -b / 2, m = e.text.includes(`
|
|
2602
|
+
`), w = e.transformType === "custom" && e.transformData ? e.transformData.width : 0, v = -w / 2;
|
|
2603
|
+
let M = v + pt;
|
|
2604
|
+
r === "center" ? M = v + w / 2 : r === "right" && (M = v + w - pt), g.forEach((C, R) => {
|
|
2605
|
+
const I = S + l.ascent + R * h, x = m || R === 0, A = m || R === g.length - 1;
|
|
2606
|
+
let k = C;
|
|
2607
|
+
x || (k = k.replace(/^ +/, "")), A || (k = k.replace(/ +$/, "")), p.globalCompositeOperation = "source-over", p.strokeStyle = t.strokeStyle, p.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), p.lineWidth = (d + f) * 2, p.lineJoin = "round", At(p, k, M, I, c), p.globalCompositeOperation = "destination-out", p.globalAlpha = 1, p.lineWidth = d * 2, At(p, k, M, I, c), Ut(p, k, M, I, c);
|
|
2564
2608
|
});
|
|
2565
2609
|
}
|
|
2566
|
-
t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(
|
|
2610
|
+
t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(y, 0, 0), t.restore();
|
|
2567
2611
|
}
|
|
2568
2612
|
/**
|
|
2569
2613
|
* HOVER RING EFFECT for transformed text (circle, wave, arch, lean, ascend, flag)
|
|
@@ -2591,19 +2635,19 @@ class Ft {
|
|
|
2591
2635
|
* Helper to render text along a transform path with hover effect
|
|
2592
2636
|
*/
|
|
2593
2637
|
static renderTransformWithHoverEffect(t, e, s, n, o) {
|
|
2594
|
-
const i = e, a = i.fontSize, r = i.fontFamily, l = i.bold || !1, h = i.italic || !1, c = l ? "bold" : "normal",
|
|
2595
|
-
if (t.font = `${
|
|
2596
|
-
const
|
|
2597
|
-
t.transform(1, 0, Math.tan(
|
|
2638
|
+
const i = e, a = i.fontSize, r = i.fontFamily, l = i.bold || !1, h = i.italic || !1, c = l ? "bold" : "normal", f = h ? "italic" : "normal";
|
|
2639
|
+
if (t.font = `${f} ${c} ${a}px ${r}`, t.textAlign = "center", t.textBaseline = "middle", i.transformType === "lean") {
|
|
2640
|
+
const b = -i.transformData.leanAmount * Math.PI / 4;
|
|
2641
|
+
t.transform(1, 0, Math.tan(b), 1, 0, 0), t.globalCompositeOperation = "source-over", t.strokeStyle = o, t.globalAlpha = 0.8, t.lineWidth = (n + s) * 2, t.lineJoin = "round", t.strokeText(i.text, 0, 0), t.globalCompositeOperation = "destination-out", t.globalAlpha = 1, t.lineWidth = n * 2, t.strokeText(i.text, 0, 0), t.fillText(i.text, 0, 0);
|
|
2598
2642
|
return;
|
|
2599
2643
|
}
|
|
2600
|
-
const
|
|
2601
|
-
t.translate(
|
|
2644
|
+
const d = i.text.split(""), y = d.map((g) => t.measureText(g).width), p = this.calculateCharPositions(e, d, y), u = (g) => {
|
|
2645
|
+
t.translate(g.x, g.y), g.angle && t.rotate(g.angle), g.skewY && t.transform(1, g.skewY, 0, 1, 0, 0);
|
|
2602
2646
|
};
|
|
2603
|
-
t.globalCompositeOperation = "source-over", t.strokeStyle = o, t.globalAlpha = 0.8, t.lineWidth = (n + s) * 2, t.lineJoin = "round",
|
|
2604
|
-
t.save(),
|
|
2605
|
-
}), t.globalCompositeOperation = "destination-out", t.globalAlpha = 1, t.lineWidth = n * 2,
|
|
2606
|
-
t.save(),
|
|
2647
|
+
t.globalCompositeOperation = "source-over", t.strokeStyle = o, t.globalAlpha = 0.8, t.lineWidth = (n + s) * 2, t.lineJoin = "round", p.forEach((g, b) => {
|
|
2648
|
+
t.save(), u(g), t.strokeText(d[b], 0, 0), t.restore();
|
|
2649
|
+
}), t.globalCompositeOperation = "destination-out", t.globalAlpha = 1, t.lineWidth = n * 2, p.forEach((g, b) => {
|
|
2650
|
+
t.save(), u(g), t.strokeText(d[b], 0, 0), t.fillText(d[b], 0, 0), t.restore();
|
|
2607
2651
|
});
|
|
2608
2652
|
}
|
|
2609
2653
|
/**
|
|
@@ -2623,14 +2667,14 @@ class Ft {
|
|
|
2623
2667
|
if (t.reverse) {
|
|
2624
2668
|
let a = Math.PI / 2 + o / (2 * i);
|
|
2625
2669
|
e.forEach((r, l) => {
|
|
2626
|
-
const c = s[l] / i,
|
|
2627
|
-
n.push({ x:
|
|
2670
|
+
const c = s[l] / i, f = Math.cos(a - c / 2) * i, d = Math.sin(a - c / 2) * i, y = a - c / 2 - Math.PI / 2;
|
|
2671
|
+
n.push({ x: f, y: d, angle: y }), a -= c;
|
|
2628
2672
|
});
|
|
2629
2673
|
} else {
|
|
2630
2674
|
let a = -Math.PI / 2 - o / (2 * i);
|
|
2631
2675
|
e.forEach((r, l) => {
|
|
2632
|
-
const c = s[l] / i,
|
|
2633
|
-
n.push({ x:
|
|
2676
|
+
const c = s[l] / i, f = Math.cos(a + c / 2) * i, d = Math.sin(a + c / 2) * i, y = a + c / 2 + Math.PI / 2;
|
|
2677
|
+
n.push({ x: f, y: d, angle: y }), a += c;
|
|
2634
2678
|
});
|
|
2635
2679
|
}
|
|
2636
2680
|
return n;
|
|
@@ -2642,8 +2686,8 @@ class Ft {
|
|
|
2642
2686
|
const o = [];
|
|
2643
2687
|
let a = -s.reduce((r, l) => r + l, 0) / 2;
|
|
2644
2688
|
return e.forEach((r, l) => {
|
|
2645
|
-
const h = s[l], c = a + h / 2,
|
|
2646
|
-
o.push({ x: c, y:
|
|
2689
|
+
const h = s[l], c = a + h / 2, f = c / (n.width / 2), d = n.amplitude * t.fontSize * Math.sin(n.frequency * Math.PI * f), y = n.amplitude * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * f);
|
|
2690
|
+
o.push({ x: c, y: d, angle: 0, skewY: y * Ae }), a += h;
|
|
2647
2691
|
}), o;
|
|
2648
2692
|
}
|
|
2649
2693
|
/**
|
|
@@ -2653,8 +2697,8 @@ class Ft {
|
|
|
2653
2697
|
const o = [], i = s.reduce((l, h) => l + h, 0), a = n.width / 2;
|
|
2654
2698
|
let r = -i / 2;
|
|
2655
2699
|
return e.forEach((l, h) => {
|
|
2656
|
-
const c = s[h],
|
|
2657
|
-
o.push({ x:
|
|
2700
|
+
const c = s[h], f = r + c / 2, d = f / a, y = (Math.pow(d, 2) - 1) * n.archHeight * t.fontSize, p = 2 * d * n.archHeight;
|
|
2701
|
+
o.push({ x: f, y, angle: 0, skewY: p * 0.3 }), r += c;
|
|
2658
2702
|
}), o;
|
|
2659
2703
|
}
|
|
2660
2704
|
/**
|
|
@@ -2675,8 +2719,8 @@ class Ft {
|
|
|
2675
2719
|
const o = [], i = s.reduce((h, c) => h + c, 0), a = n.ascendAngle * Math.PI / 180, r = Math.tan(a);
|
|
2676
2720
|
let l = -i / 2;
|
|
2677
2721
|
return e.forEach((h, c) => {
|
|
2678
|
-
const
|
|
2679
|
-
o.push({ x:
|
|
2722
|
+
const f = s[c], d = l + f / 2, y = d * r;
|
|
2723
|
+
o.push({ x: d, y, angle: 0, skewY: r * 1 }), l += f;
|
|
2680
2724
|
}), o;
|
|
2681
2725
|
}
|
|
2682
2726
|
/**
|
|
@@ -2686,8 +2730,8 @@ class Ft {
|
|
|
2686
2730
|
const o = [];
|
|
2687
2731
|
let a = -s.reduce((r, l) => r + l, 0) / 2;
|
|
2688
2732
|
return e.forEach((r, l) => {
|
|
2689
|
-
const h = s[l], c = a + h / 2,
|
|
2690
|
-
o.push({ x: c, y:
|
|
2733
|
+
const h = s[l], c = a + h / 2, f = c / (n.width / 2), d = Math.abs(f), y = n.amplitude * d, p = y * t.fontSize * Math.sin(n.frequency * Math.PI * f), u = y * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * f), g = n.amplitude * Math.sign(f) * Math.sin(n.frequency * Math.PI * f), b = u + g;
|
|
2734
|
+
o.push({ x: c, y: p, angle: 0, skewY: b * 0.3 }), a += h;
|
|
2691
2735
|
}), o;
|
|
2692
2736
|
}
|
|
2693
2737
|
}
|
|
@@ -2705,7 +2749,7 @@ class Rt {
|
|
|
2705
2749
|
*/
|
|
2706
2750
|
static renderSpacingIndicatorsLayer(t, e = []) {
|
|
2707
2751
|
e.length !== 0 && (t.save(), t.setLineDash([]), e.forEach((s) => {
|
|
2708
|
-
const n =
|
|
2752
|
+
const n = Zt(t.canvas);
|
|
2709
2753
|
if (t.strokeStyle = n, t.fillStyle = n, t.lineWidth = ct.canvas.spacingIndicatorWidth, t.beginPath(), s.type === "horizontal") {
|
|
2710
2754
|
const o = s.x1 ?? 0, i = s.x2 ?? 0, a = s.y ?? 0;
|
|
2711
2755
|
t.moveTo(o, a), t.lineTo(i, a), t.stroke();
|
|
@@ -2730,198 +2774,198 @@ class Rt {
|
|
|
2730
2774
|
const o = `${n}`;
|
|
2731
2775
|
t.font = `600 ${ct.canvas.spacingLabelFontSize}px ${ct.canvas.spacingLabelFontFamily}`;
|
|
2732
2776
|
const a = t.measureText(o).width, r = ct.canvas.spacingLabelFontSize, l = 4, h = a + l * 2, c = r + l * 2;
|
|
2733
|
-
t.fillStyle =
|
|
2777
|
+
t.fillStyle = Zt(t.canvas), t.beginPath(), t.roundRect(e - h / 2, s - c / 2, h, c, Pe), t.fill(), t.fillStyle = Ee, t.textAlign = "center", t.textBaseline = "middle", t.fillText(o, e, s);
|
|
2734
2778
|
}
|
|
2735
2779
|
}
|
|
2736
|
-
class
|
|
2780
|
+
class Yt {
|
|
2737
2781
|
/**
|
|
2738
2782
|
* Render edit mode features: cursor and text selection highlight
|
|
2739
2783
|
* This renders on the main canvas at world coordinates (same as the element)
|
|
2740
2784
|
*/
|
|
2741
2785
|
static renderEditModeLayer(t, e, s, n) {
|
|
2742
2786
|
if (!e || e.transformType === "image" || e.transformType === "group") return;
|
|
2743
|
-
const o = e, { cursorPosition: i, selectionStart: a, selectionEnd: r, editText: l, editRichText: h, cursorOpacity: c, isTouchDevice:
|
|
2744
|
-
if (
|
|
2745
|
-
this.renderTransformEditModeLayer(t, o, s,
|
|
2787
|
+
const o = e, { cursorPosition: i, selectionStart: a, selectionEnd: r, editText: l, editRichText: h, cursorOpacity: c, isTouchDevice: f, selectionHandlePositionsRef: d } = s, y = n || 1, p = o.transformType;
|
|
2788
|
+
if (p === "circle" || p === "wave" || p === "arch" || p === "lean" || p === "ascend" || p === "flag") {
|
|
2789
|
+
this.renderTransformEditModeLayer(t, o, s, y);
|
|
2746
2790
|
return;
|
|
2747
2791
|
}
|
|
2748
|
-
const
|
|
2792
|
+
const u = o.fontSize || 24, g = o.fontFamily || "Arial", b = o.bold || !1, S = o.italic || !1, m = o.underline || !1, w = o.strikethrough || !1, v = o.textAlign || "center", M = o.letterSpacing ?? 0;
|
|
2749
2793
|
t.save(), t.translate(o.x, o.y), t.rotate(-o.rotation * Math.PI / 180);
|
|
2750
|
-
const C =
|
|
2751
|
-
let
|
|
2794
|
+
const C = re(u, g, b, S), R = C.height, I = u * (o.lineHeight ?? 1.2);
|
|
2795
|
+
let x, A, k;
|
|
2752
2796
|
if (h && o.transformType === "custom" && o.transformData.width) {
|
|
2753
2797
|
const L = o.transformData.width - pt * 2;
|
|
2754
|
-
|
|
2755
|
-
const
|
|
2756
|
-
|
|
2757
|
-
const X =
|
|
2798
|
+
k = L;
|
|
2799
|
+
const E = le(h);
|
|
2800
|
+
x = [], A = [], E.forEach((O) => {
|
|
2801
|
+
const X = he(O, L, {
|
|
2758
2802
|
fontSize: o.fontSize,
|
|
2759
2803
|
fontFamily: o.fontFamily,
|
|
2760
2804
|
bold: o.bold,
|
|
2761
2805
|
italic: o.italic,
|
|
2762
2806
|
letterSpacing: o.letterSpacing
|
|
2763
2807
|
});
|
|
2764
|
-
X.forEach((
|
|
2765
|
-
|
|
2766
|
-
isParagraphStart:
|
|
2767
|
-
isParagraphEnd:
|
|
2808
|
+
X.forEach((H, W) => {
|
|
2809
|
+
x.push(H), A.push({
|
|
2810
|
+
isParagraphStart: W === 0,
|
|
2811
|
+
isParagraphEnd: W === X.length - 1
|
|
2768
2812
|
});
|
|
2769
2813
|
});
|
|
2770
2814
|
});
|
|
2771
2815
|
} else
|
|
2772
|
-
|
|
2773
|
-
`).map((
|
|
2816
|
+
x = l.split(`
|
|
2817
|
+
`).map((E) => [
|
|
2774
2818
|
{
|
|
2775
|
-
text:
|
|
2776
|
-
style: { fontSize:
|
|
2819
|
+
text: E,
|
|
2820
|
+
style: { fontSize: u, fontFamily: g, bold: b, italic: S }
|
|
2777
2821
|
}
|
|
2778
|
-
]),
|
|
2822
|
+
]), A = x.map(() => ({
|
|
2779
2823
|
isParagraphStart: !0,
|
|
2780
2824
|
// Each line is its own paragraph
|
|
2781
2825
|
isParagraphEnd: !0
|
|
2782
2826
|
}));
|
|
2783
|
-
const
|
|
2784
|
-
let
|
|
2827
|
+
const P = x.length > 1 ? C.height + (x.length - 1) * I : C.height;
|
|
2828
|
+
let D = -P / 2, _ = 0, Y = D, V = R;
|
|
2785
2829
|
const j = [];
|
|
2786
|
-
let
|
|
2787
|
-
|
|
2788
|
-
var
|
|
2789
|
-
const O =
|
|
2830
|
+
let B = 0;
|
|
2831
|
+
x.forEach((L, E) => {
|
|
2832
|
+
var W, U;
|
|
2833
|
+
const O = A[E].isParagraphStart, X = A[E].isParagraphEnd, H = [];
|
|
2790
2834
|
L.forEach((ot) => {
|
|
2791
2835
|
Array.from(ot.text).forEach((lt) => {
|
|
2792
|
-
let
|
|
2793
|
-
if (h &&
|
|
2794
|
-
const J = h.getStyleAt(
|
|
2795
|
-
|
|
2836
|
+
let G = u, ht = g, it = b, Z = S, st = M;
|
|
2837
|
+
if (h && B < l.length) {
|
|
2838
|
+
const J = h.getStyleAt(B);
|
|
2839
|
+
G = J.fontSize || u, ht = J.fontFamily || g, it = J.bold !== void 0 ? J.bold : b, Z = J.italic !== void 0 ? J.italic : S, st = J.letterSpacing !== void 0 ? J.letterSpacing : M;
|
|
2796
2840
|
}
|
|
2797
2841
|
t.save();
|
|
2798
2842
|
const F = it ? "bold" : "normal", q = Z ? "italic" : "normal";
|
|
2799
|
-
t.font = `${q} ${F} ${
|
|
2843
|
+
t.font = `${q} ${F} ${G}px "${ht}", Arial, sans-serif`;
|
|
2800
2844
|
const at = t.measureText(lt).width + st;
|
|
2801
|
-
t.restore(),
|
|
2845
|
+
t.restore(), H.push({ char: lt, width: at, fontSize: G, index: B }), B++;
|
|
2802
2846
|
});
|
|
2803
2847
|
});
|
|
2804
2848
|
{
|
|
2805
|
-
const ot =
|
|
2849
|
+
const ot = E === 0, et = E === x.length - 1, lt = H.map((F) => F.char).join(""), G = ((W = lt.match(/^ +/)) == null ? void 0 : W[0].length) || 0, ht = ((U = lt.match(/ +$/)) == null ? void 0 : U[0].length) || 0;
|
|
2806
2850
|
let it = 0;
|
|
2807
|
-
for (let F = 0; F <
|
|
2808
|
-
!ot && F <
|
|
2851
|
+
for (let F = 0; F < H.length; F++)
|
|
2852
|
+
!ot && F < G || !et && F >= H.length - ht || (it += H[F].width);
|
|
2809
2853
|
let Z;
|
|
2810
|
-
|
|
2854
|
+
v === "center" ? Z = -it / 2 : v === "right" ? Z = k !== void 0 ? k / 2 - it : -it : Z = k !== void 0 ? -k / 2 : 0;
|
|
2811
2855
|
let st = Z;
|
|
2812
|
-
for (let F = 0; F <
|
|
2813
|
-
const q =
|
|
2856
|
+
for (let F = 0; F < H.length; F++) {
|
|
2857
|
+
const q = H[F];
|
|
2814
2858
|
j[q.index] = {
|
|
2815
2859
|
x: st,
|
|
2816
|
-
y:
|
|
2860
|
+
y: D,
|
|
2817
2861
|
width: q.width,
|
|
2818
2862
|
// All characters keep their width for cursor navigation
|
|
2819
2863
|
height: q.fontSize
|
|
2820
2864
|
}, st += q.width;
|
|
2821
2865
|
}
|
|
2822
|
-
if (
|
|
2823
|
-
const F =
|
|
2866
|
+
if (H.length > 0) {
|
|
2867
|
+
const F = H[0].index, q = H[H.length - 1].index, ut = E < x.length - 1 && q + 1 === B ? q : q + 1;
|
|
2824
2868
|
if (i >= F && i <= ut)
|
|
2825
2869
|
if (i === F)
|
|
2826
|
-
_ = Z,
|
|
2870
|
+
_ = Z, Y = D, V = R;
|
|
2827
2871
|
else {
|
|
2828
2872
|
let yt = 0;
|
|
2829
|
-
for (let rt = 0; rt <
|
|
2830
|
-
const dt =
|
|
2873
|
+
for (let rt = 0; rt < H.length && H[rt].index < i; rt++) {
|
|
2874
|
+
const dt = H[rt], bt = dt.char === " ";
|
|
2831
2875
|
let St = !0;
|
|
2832
2876
|
if (bt) {
|
|
2833
|
-
const kt = rt <
|
|
2877
|
+
const kt = rt < G, N = rt >= H.length - ht, vt = !O && G > 0, Mt = !X && ht > 0;
|
|
2834
2878
|
St = !(kt && vt || N && Mt);
|
|
2835
2879
|
}
|
|
2836
2880
|
St && (yt += dt.width);
|
|
2837
2881
|
}
|
|
2838
|
-
_ = Z + yt,
|
|
2882
|
+
_ = Z + yt, Y = D, V = R;
|
|
2839
2883
|
}
|
|
2840
2884
|
}
|
|
2841
|
-
|
|
2885
|
+
E < x.length - 1 && (D += I);
|
|
2842
2886
|
}
|
|
2843
2887
|
});
|
|
2844
2888
|
const z = a !== r;
|
|
2845
|
-
let
|
|
2889
|
+
let $ = null, Q = null;
|
|
2846
2890
|
if (z) {
|
|
2847
|
-
const L = Math.min(a, r),
|
|
2848
|
-
t.save(), t.fillStyle =
|
|
2849
|
-
let O = 0, X = -
|
|
2850
|
-
if (
|
|
2891
|
+
const L = Math.min(a, r), E = Math.max(a, r);
|
|
2892
|
+
t.save(), t.fillStyle = He(t.canvas);
|
|
2893
|
+
let O = 0, X = -P / 2;
|
|
2894
|
+
if (x.forEach((H, W) => {
|
|
2851
2895
|
var ht, it;
|
|
2852
|
-
const U =
|
|
2853
|
-
if (
|
|
2896
|
+
const U = A[W].isParagraphStart, ot = A[W].isParagraphEnd, et = W === 0, lt = W === x.length - 1, G = [];
|
|
2897
|
+
if (H.forEach((Z) => {
|
|
2854
2898
|
Array.from(Z.text).forEach((st) => {
|
|
2855
|
-
const F = Z.style || {}, q = F.fontSize !== void 0 ? F.fontSize :
|
|
2899
|
+
const F = Z.style || {}, q = F.fontSize !== void 0 ? F.fontSize : u, at = F.fontFamily !== void 0 ? F.fontFamily : g, J = F.bold !== void 0 ? F.bold : b, ut = F.italic !== void 0 ? F.italic : S, yt = F.letterSpacing !== void 0 ? F.letterSpacing : M;
|
|
2856
2900
|
t.save();
|
|
2857
2901
|
const rt = J ? "bold" : "normal", dt = ut ? "italic" : "normal";
|
|
2858
2902
|
t.font = `${dt} ${rt} ${q}px "${at}", Arial, sans-serif`;
|
|
2859
2903
|
const bt = t.measureText(st).width + yt;
|
|
2860
|
-
t.restore(),
|
|
2904
|
+
t.restore(), G.push({ char: st, index: O, width: bt, style: F }), O++;
|
|
2861
2905
|
});
|
|
2862
|
-
}),
|
|
2863
|
-
const Z =
|
|
2864
|
-
if (
|
|
2906
|
+
}), G.length > 0) {
|
|
2907
|
+
const Z = G[0].index, st = G[G.length - 1].index;
|
|
2908
|
+
if (E > Z && L <= st) {
|
|
2865
2909
|
t.save();
|
|
2866
|
-
const F =
|
|
2910
|
+
const F = G.map((N) => N.char).join(""), q = ((ht = F.match(/^ +/)) == null ? void 0 : ht[0].length) || 0, at = ((it = F.match(/ +$/)) == null ? void 0 : it[0].length) || 0;
|
|
2867
2911
|
let J = 0;
|
|
2868
|
-
for (let N = 0; N <
|
|
2869
|
-
!et && N < q || !lt && N >=
|
|
2912
|
+
for (let N = 0; N < G.length; N++)
|
|
2913
|
+
!et && N < q || !lt && N >= G.length - at || (J += G[N].width);
|
|
2870
2914
|
let ut = 0;
|
|
2871
|
-
|
|
2872
|
-
const yt = Math.max(L, Z), rt = Math.min(
|
|
2915
|
+
v === "center" ? ut = -J / 2 : v === "right" && (ut = -J);
|
|
2916
|
+
const yt = Math.max(L, Z), rt = Math.min(E, st + 1);
|
|
2873
2917
|
let dt = 0;
|
|
2874
|
-
for (let N = 0; N <
|
|
2875
|
-
const vt =
|
|
2876
|
-
!(Mt &&
|
|
2918
|
+
for (let N = 0; N < G.length && G[N].index < yt; N++) {
|
|
2919
|
+
const vt = G[N], Mt = N < q, Lt = N >= G.length - at, Dt = !U && q > 0, Wt = !ot && at > 0;
|
|
2920
|
+
!(Mt && Dt || Lt && Wt) && (dt += vt.width);
|
|
2877
2921
|
}
|
|
2878
2922
|
let bt = 0;
|
|
2879
|
-
for (let N = 0; N <
|
|
2880
|
-
const vt =
|
|
2881
|
-
!(Mt &&
|
|
2923
|
+
for (let N = 0; N < G.length && G[N].index < rt; N++) {
|
|
2924
|
+
const vt = G[N], Mt = N < q, Lt = N >= G.length - at, Dt = !U && q > 0, Wt = !ot && at > 0;
|
|
2925
|
+
!(Mt && Dt || Lt && Wt) && (bt += vt.width);
|
|
2882
2926
|
}
|
|
2883
2927
|
const St = ut + dt, kt = bt - dt;
|
|
2884
|
-
t.fillRect(St, X, kt,
|
|
2928
|
+
t.fillRect(St, X, kt, R), $ === null && ($ = { x: St, y: X }), Q = { x: St + kt, y: X + R }, t.restore();
|
|
2885
2929
|
}
|
|
2886
2930
|
}
|
|
2887
|
-
|
|
2931
|
+
W < x.length - 1 && (X += I);
|
|
2888
2932
|
}), t.restore(), h) {
|
|
2889
2933
|
t.save();
|
|
2890
|
-
const
|
|
2891
|
-
|
|
2892
|
-
fontSize:
|
|
2893
|
-
fontFamily:
|
|
2934
|
+
const H = o.transformType === "custom" ? o.transformData : null, W = H != null && H.width ? H.width - pt * 2 : void 0;
|
|
2935
|
+
We(t, h, {
|
|
2936
|
+
fontSize: u,
|
|
2937
|
+
fontFamily: g,
|
|
2894
2938
|
color: o.color || "#000000",
|
|
2895
|
-
bold:
|
|
2939
|
+
bold: b,
|
|
2896
2940
|
italic: S,
|
|
2897
2941
|
underline: m,
|
|
2898
2942
|
strikethrough: w,
|
|
2899
|
-
textAlign:
|
|
2943
|
+
textAlign: v,
|
|
2900
2944
|
letterSpacing: o.letterSpacing,
|
|
2901
2945
|
lineHeight: o.lineHeight
|
|
2902
|
-
},
|
|
2946
|
+
}, W), t.restore();
|
|
2903
2947
|
}
|
|
2904
2948
|
}
|
|
2905
|
-
if (z &&
|
|
2906
|
-
const L =
|
|
2949
|
+
if (z && f && $ && Q) {
|
|
2950
|
+
const L = $, E = Q, O = 6 / y, X = 2 / y;
|
|
2907
2951
|
t.save();
|
|
2908
|
-
const
|
|
2909
|
-
t.fillStyle =
|
|
2910
|
-
const
|
|
2911
|
-
t.beginPath(), t.moveTo(L.x, L.y), t.lineTo(L.x, L.y +
|
|
2952
|
+
const H = nt(t.canvas);
|
|
2953
|
+
t.fillStyle = H, t.strokeStyle = H, t.lineWidth = X, t.lineCap = "round";
|
|
2954
|
+
const W = { x: L.x, y: L.y - O }, U = { x: E.x, y: E.y + O };
|
|
2955
|
+
t.beginPath(), t.moveTo(L.x, L.y), t.lineTo(L.x, L.y + R), t.stroke(), t.beginPath(), t.arc(W.x, W.y, O, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / y, t.stroke(), t.strokeStyle = H, t.lineWidth = X, t.beginPath(), t.moveTo(E.x, E.y - R), t.lineTo(E.x, E.y), t.stroke(), t.beginPath(), t.arc(U.x, U.y, O, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / y, t.stroke(), t.restore(), d && (d.current = {
|
|
2912
2956
|
start: {
|
|
2913
|
-
center:
|
|
2957
|
+
center: W,
|
|
2914
2958
|
textEdge: L
|
|
2915
2959
|
// Original selection edge (top-left of selection on first line)
|
|
2916
2960
|
},
|
|
2917
2961
|
end: {
|
|
2918
2962
|
center: U,
|
|
2919
|
-
textEdge:
|
|
2963
|
+
textEdge: E
|
|
2920
2964
|
// Original selection edge (bottom-right of selection on last line)
|
|
2921
2965
|
}
|
|
2922
2966
|
});
|
|
2923
|
-
} else
|
|
2924
|
-
!z && c > 0 && (t.save(), t.globalAlpha = c, t.strokeStyle = nt(t.canvas), t.lineWidth = 3 /
|
|
2967
|
+
} else d && (d.current = { start: null, end: null });
|
|
2968
|
+
!z && c > 0 && (t.save(), t.globalAlpha = c, t.strokeStyle = nt(t.canvas), t.lineWidth = 3 / y, t.lineCap = "round", t.beginPath(), t.moveTo(_, Y), t.lineTo(_, Y + V), t.stroke(), t.restore()), t.restore();
|
|
2925
2969
|
}
|
|
2926
2970
|
/**
|
|
2927
2971
|
* Render edit mode features for transformed text (circle, wave, arch, etc.)
|
|
@@ -2930,39 +2974,39 @@ class Vt {
|
|
|
2930
2974
|
static renderTransformEditModeLayer(t, e, s, n = 1) {
|
|
2931
2975
|
const { cursorPosition: o, cursorOpacity: i } = s, a = e.fontSize || 24, r = e.fontFamily || "Arial", l = e.bold || !1, h = e.italic || !1;
|
|
2932
2976
|
t.save(), t.translate(e.x, e.y), t.rotate(-e.rotation * Math.PI / 180);
|
|
2933
|
-
const c = l ? "bold" : "normal",
|
|
2934
|
-
t.font = `${
|
|
2935
|
-
const
|
|
2936
|
-
if (o >= 0 && o <=
|
|
2937
|
-
let
|
|
2977
|
+
const c = l ? "bold" : "normal", f = h ? "italic" : "normal";
|
|
2978
|
+
t.font = `${f} ${c} ${a}px ${r}`;
|
|
2979
|
+
const d = Array.from(e.text), y = d.map((u) => t.measureText(u).width), p = Nt.calculateCharPositions(e, d, y);
|
|
2980
|
+
if (o >= 0 && o <= d.length && i > 0) {
|
|
2981
|
+
let u;
|
|
2938
2982
|
if (o === 0)
|
|
2939
|
-
if (
|
|
2940
|
-
const
|
|
2941
|
-
|
|
2942
|
-
x:
|
|
2943
|
-
y:
|
|
2944
|
-
angle:
|
|
2983
|
+
if (p.length > 0) {
|
|
2984
|
+
const b = p[0], S = y[0];
|
|
2985
|
+
u = {
|
|
2986
|
+
x: b.x - Math.cos(b.angle) * (S / 2),
|
|
2987
|
+
y: b.y - Math.sin(b.angle) * (S / 2),
|
|
2988
|
+
angle: b.angle
|
|
2945
2989
|
};
|
|
2946
2990
|
} else
|
|
2947
|
-
|
|
2948
|
-
else if (o >=
|
|
2949
|
-
const
|
|
2950
|
-
|
|
2951
|
-
x:
|
|
2952
|
-
y:
|
|
2953
|
-
angle:
|
|
2991
|
+
u = { x: 0, y: 0, angle: 0 };
|
|
2992
|
+
else if (o >= p.length) {
|
|
2993
|
+
const b = p[p.length - 1], S = y[y.length - 1];
|
|
2994
|
+
u = {
|
|
2995
|
+
x: b.x + Math.cos(b.angle) * (S / 2),
|
|
2996
|
+
y: b.y + Math.sin(b.angle) * (S / 2),
|
|
2997
|
+
angle: b.angle
|
|
2954
2998
|
};
|
|
2955
2999
|
} else {
|
|
2956
|
-
const
|
|
2957
|
-
|
|
2958
|
-
x:
|
|
2959
|
-
y:
|
|
2960
|
-
angle:
|
|
3000
|
+
const b = p[o], S = y[o];
|
|
3001
|
+
u = {
|
|
3002
|
+
x: b.x - Math.cos(b.angle) * (S / 2),
|
|
3003
|
+
y: b.y - Math.sin(b.angle) * (S / 2),
|
|
3004
|
+
angle: b.angle
|
|
2961
3005
|
};
|
|
2962
3006
|
}
|
|
2963
|
-
t.save(), t.translate(
|
|
2964
|
-
const
|
|
2965
|
-
t.beginPath(), t.moveTo(0, -
|
|
3007
|
+
t.save(), t.translate(u.x, u.y), t.rotate(u.angle), t.globalAlpha = i, t.strokeStyle = nt(t.canvas), t.lineWidth = 2 / n;
|
|
3008
|
+
const g = a * 1.2;
|
|
3009
|
+
t.beginPath(), t.moveTo(0, -g / 2), t.lineTo(0, g / 2), t.stroke(), t.restore();
|
|
2966
3010
|
}
|
|
2967
3011
|
t.restore();
|
|
2968
3012
|
}
|
|
@@ -2971,30 +3015,30 @@ class Vt {
|
|
|
2971
3015
|
* Shows both image resize handles and crop handles
|
|
2972
3016
|
*/
|
|
2973
3017
|
static renderCropBoxLayer(t, e, s, n = 1) {
|
|
2974
|
-
if (!(e instanceof
|
|
3018
|
+
if (!(e instanceof Ie) || !e.isCropping) return;
|
|
2975
3019
|
const o = e, i = o.getCropBoxBounds();
|
|
2976
3020
|
if (!i) return;
|
|
2977
|
-
const a = 4 / n, r = 2 / n, l =
|
|
3021
|
+
const a = 4 / n, r = 2 / n, l = Be / n, h = Le / n, c = 1 / n;
|
|
2978
3022
|
t.save(), t.translate(e.x * n, e.y * n), t.rotate(gt.toRadians(e.rotation));
|
|
2979
|
-
const
|
|
2980
|
-
t.scale(
|
|
2981
|
-
const
|
|
2982
|
-
x:
|
|
2983
|
-
y:
|
|
3023
|
+
const f = o.transformData.flipHorizontal ? -1 : 1, d = o.transformData.flipVertical ? -1 : 1;
|
|
3024
|
+
t.scale(f * n, d * n);
|
|
3025
|
+
const y = o.transformData.width * o.transformData.cropWidth, p = o.transformData.height * o.transformData.cropHeight, u = o.transformData.width / 2 - (o.transformData.cropX * o.transformData.width + y / 2), g = o.transformData.height / 2 - (o.transformData.cropY * o.transformData.height + p / 2), b = o.transformData.width / 2, S = o.transformData.height / 2, m = {
|
|
3026
|
+
x: u - b,
|
|
3027
|
+
y: g - S,
|
|
2984
3028
|
width: o.transformData.width,
|
|
2985
3029
|
height: o.transformData.height
|
|
2986
3030
|
};
|
|
2987
3031
|
t.fillStyle = "rgba(0, 0, 0, 0.5)", i.y > m.y && t.fillRect(m.x, m.y, m.width, i.y - m.y);
|
|
2988
|
-
const w = i.y + i.height,
|
|
2989
|
-
w <
|
|
2990
|
-
const
|
|
2991
|
-
|
|
2992
|
-
const
|
|
2993
|
-
t.beginPath(), t.moveTo(i.x +
|
|
3032
|
+
const w = i.y + i.height, v = m.y + m.height;
|
|
3033
|
+
w < v && t.fillRect(m.x, w, m.width, v - w), i.x > m.x && t.fillRect(m.x, i.y, i.x - m.x, i.height);
|
|
3034
|
+
const M = i.x + i.width, C = m.x + m.width;
|
|
3035
|
+
M < C && t.fillRect(M, i.y, C - M, i.height), t.strokeStyle = nt(t.canvas), t.lineWidth = r, t.strokeRect(i.x, i.y, i.width, i.height), t.strokeStyle = "rgba(255, 255, 255, 0.5)", t.lineWidth = c;
|
|
3036
|
+
const R = i.width / 3;
|
|
3037
|
+
t.beginPath(), t.moveTo(i.x + R, i.y), t.lineTo(i.x + R, i.y + i.height), t.moveTo(i.x + 2 * R, i.y), t.lineTo(i.x + 2 * R, i.y + i.height), t.stroke();
|
|
2994
3038
|
const I = i.height / 3;
|
|
2995
3039
|
t.beginPath(), t.moveTo(i.x, i.y + I), t.lineTo(i.x + i.width, i.y + I), t.moveTo(i.x, i.y + 2 * I), t.lineTo(i.x + i.width, i.y + 2 * I), t.stroke();
|
|
2996
|
-
const
|
|
2997
|
-
if ((
|
|
3040
|
+
const x = o.isFrameLockedInCrop();
|
|
3041
|
+
if ((x ? [] : [
|
|
2998
3042
|
{ x: i.x, y: i.y },
|
|
2999
3043
|
// top-left
|
|
3000
3044
|
{ x: i.x + i.width, y: i.y },
|
|
@@ -3003,9 +3047,9 @@ class Vt {
|
|
|
3003
3047
|
// bottom-right
|
|
3004
3048
|
{ x: i.x, y: i.y + i.height }
|
|
3005
3049
|
// bottom-left
|
|
3006
|
-
]).forEach((
|
|
3007
|
-
t.beginPath(), t.arc(
|
|
3008
|
-
}), (
|
|
3050
|
+
]).forEach((P) => {
|
|
3051
|
+
t.beginPath(), t.arc(P.x, P.y, l + 1 / n, 0, Math.PI * 2), t.fillStyle = "#bbb", t.fill(), t.beginPath(), t.arc(P.x, P.y, l, 0, Math.PI * 2), t.fillStyle = "#fff", t.fill();
|
|
3052
|
+
}), (x ? [] : [
|
|
3009
3053
|
{ x: i.x + i.width / 2, y: i.y, orientation: "horizontal" },
|
|
3010
3054
|
// top
|
|
3011
3055
|
{ x: i.x + i.width / 2, y: i.y + i.height, orientation: "horizontal" },
|
|
@@ -3014,21 +3058,21 @@ class Vt {
|
|
|
3014
3058
|
// left
|
|
3015
3059
|
{ x: i.x + i.width, y: i.y + i.height / 2, orientation: "vertical" }
|
|
3016
3060
|
// right
|
|
3017
|
-
]).forEach((
|
|
3018
|
-
let
|
|
3019
|
-
|
|
3020
|
-
const
|
|
3021
|
-
t.fillStyle = "#fff", t.fillRect(
|
|
3061
|
+
]).forEach((P) => {
|
|
3062
|
+
let D, _;
|
|
3063
|
+
P.orientation === "horizontal" ? (D = h, _ = a) : (D = a, _ = h);
|
|
3064
|
+
const Y = P.x - D / 2, V = P.y - _ / 2;
|
|
3065
|
+
t.fillStyle = "#fff", t.fillRect(Y, V, D, _), t.strokeStyle = "#bbb", t.lineWidth = c, t.strokeRect(Y, V, D, _);
|
|
3022
3066
|
}), t.restore(), s && s.resizeHandles) {
|
|
3023
|
-
const
|
|
3067
|
+
const P = s.resizeHandles.filter(
|
|
3024
3068
|
(V) => V.anchor === "top-left" || V.anchor === "top-right" || V.anchor === "bottom-left" || V.anchor === "bottom-right"
|
|
3025
|
-
),
|
|
3026
|
-
|
|
3069
|
+
), D = o.getCropBoxWorldCorners(), _ = 6, Y = 20;
|
|
3070
|
+
P.forEach((V) => {
|
|
3027
3071
|
let j = !1;
|
|
3028
|
-
if (
|
|
3029
|
-
for (const
|
|
3030
|
-
const z = V.x -
|
|
3031
|
-
if (Math.sqrt(z * z +
|
|
3072
|
+
if (D)
|
|
3073
|
+
for (const B of D) {
|
|
3074
|
+
const z = V.x - B.x, $ = V.y - B.y;
|
|
3075
|
+
if (Math.sqrt(z * z + $ * $) < Y) {
|
|
3032
3076
|
j = !0;
|
|
3033
3077
|
break;
|
|
3034
3078
|
}
|
|
@@ -3038,8 +3082,8 @@ class Vt {
|
|
|
3038
3082
|
}
|
|
3039
3083
|
}
|
|
3040
3084
|
}
|
|
3041
|
-
|
|
3042
|
-
const
|
|
3085
|
+
Fe();
|
|
3086
|
+
const cn = ae("CanvasRenderer"), dn = 0.35, K = class K {
|
|
3043
3087
|
/**
|
|
3044
3088
|
* Get a pooled offscreen canvas for clipping content, only recreating
|
|
3045
3089
|
* when dimensions change. Eliminates per-frame canvas allocation.
|
|
@@ -3063,7 +3107,7 @@ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
|
|
|
3063
3107
|
e.render(t, s, n);
|
|
3064
3108
|
} catch (o) {
|
|
3065
3109
|
const i = o instanceof Error ? o : new Error(String(o));
|
|
3066
|
-
|
|
3110
|
+
cn.error(`Failed to render element ${e.id}:`, i), K.onRenderError && K.onRenderError({
|
|
3067
3111
|
category: "render",
|
|
3068
3112
|
message: `Failed to render element: ${i.message}`,
|
|
3069
3113
|
originalError: i,
|
|
@@ -3109,12 +3153,12 @@ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
|
|
|
3109
3153
|
try {
|
|
3110
3154
|
const l = new Path2D();
|
|
3111
3155
|
for (const h of a.pieces) {
|
|
3112
|
-
const c = new Path2D(h.d),
|
|
3113
|
-
if (
|
|
3114
|
-
const
|
|
3115
|
-
|
|
3156
|
+
const c = new Path2D(h.d), f = h.rotation ?? 0, d = new DOMMatrix();
|
|
3157
|
+
if (d.translateSelf(h.x, h.y), f !== 0) {
|
|
3158
|
+
const y = (h.baseWidth ?? 0) / 2, p = (h.baseHeight ?? 0) / 2, { width: u, height: g } = oe(h.baseWidth ?? 0, h.baseHeight ?? 0, f);
|
|
3159
|
+
d.translateSelf(u / 2, g / 2), d.rotateSelf(f), d.translateSelf(-y, -p);
|
|
3116
3160
|
}
|
|
3117
|
-
l.addPath(c,
|
|
3161
|
+
l.addPath(c, d);
|
|
3118
3162
|
}
|
|
3119
3163
|
t.translate(s, n), t.clip(l), t.translate(-s, -n);
|
|
3120
3164
|
return;
|
|
@@ -3130,21 +3174,21 @@ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
|
|
|
3130
3174
|
static renderElementWithOverflowDimming(t, e, s, n, o, i) {
|
|
3131
3175
|
const a = t.getTransform(), r = s.borderRadius || 0;
|
|
3132
3176
|
t.save(), t.globalAlpha = 0.3 * (i ? tt : 1), t.filter = "blur(4px)", t.beginPath();
|
|
3133
|
-
const h = t.getTransform().inverse(), c = t.canvas.width,
|
|
3177
|
+
const h = t.getTransform().inverse(), c = t.canvas.width, f = t.canvas.height, d = new DOMPoint(0, 0).matrixTransform(h), y = new DOMPoint(c, f).matrixTransform(h), p = Math.max(y.x - d.x, y.y - d.y), u = d.x - p, g = d.y - p, b = y.x + p, S = y.y + p, m = typeof s.clipShape == "object" && s.clipShape !== null && s.clipShape.type === "composite-path" ? s.clipShape : null;
|
|
3134
3178
|
if (m) {
|
|
3135
3179
|
const w = new Path2D();
|
|
3136
|
-
w.rect(
|
|
3137
|
-
for (const
|
|
3138
|
-
const
|
|
3139
|
-
if (
|
|
3140
|
-
const I = (
|
|
3141
|
-
|
|
3180
|
+
w.rect(u, g, b - u, S - g);
|
|
3181
|
+
for (const v of m.pieces) {
|
|
3182
|
+
const M = new Path2D(v.d), C = v.rotation ?? 0, R = new DOMMatrix();
|
|
3183
|
+
if (R.translateSelf(s.x + v.x, s.y + v.y), C !== 0) {
|
|
3184
|
+
const I = (v.baseWidth ?? 0) / 2, x = (v.baseHeight ?? 0) / 2, { width: A, height: k } = oe(v.baseWidth ?? 0, v.baseHeight ?? 0, C);
|
|
3185
|
+
R.translateSelf(A / 2, k / 2), R.rotateSelf(C), R.translateSelf(-I, -x);
|
|
3142
3186
|
}
|
|
3143
|
-
w.addPath(
|
|
3187
|
+
w.addPath(M, R);
|
|
3144
3188
|
}
|
|
3145
3189
|
t.clip(w, "evenodd");
|
|
3146
3190
|
} else
|
|
3147
|
-
t.rect(
|
|
3191
|
+
t.rect(u, g, b - u, S - g), r > 0 ? t.roundRect(s.x, s.y, s.width, s.height, r) : t.rect(s.x, s.y, s.width, s.height), t.clip("evenodd");
|
|
3148
3192
|
e.render(t, !1, !1), t.restore(), t.save(), this.applyArtboardClipPath(t, s), i && (t.globalAlpha = tt), e.render(t, n, o), t.restore(), t.setTransform(a);
|
|
3149
3193
|
}
|
|
3150
3194
|
/**
|
|
@@ -3157,62 +3201,62 @@ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
|
|
|
3157
3201
|
* clipped-only branch which respects `clipShape` correctly.
|
|
3158
3202
|
*/
|
|
3159
3203
|
static renderElementsLayer(t, e, s, n, o, i, a, r = !0, l = !1, h = !1) {
|
|
3160
|
-
const c = o != null && o.getMode() === "drag",
|
|
3161
|
-
e !==
|
|
3162
|
-
const
|
|
3163
|
-
|
|
3204
|
+
const c = o != null && o.getMode() === "drag", f = o == null ? void 0 : o._activeChildContext;
|
|
3205
|
+
e !== K._cachedElementsRef && (K._cachedElementConfigs = e.map((g) => g.toJSON()), K._cachedElementMap = new Map(e.map((g) => [g.id, g])), K._cachedElementsRef = e);
|
|
3206
|
+
const d = K._cachedElementConfigs, y = K._cachedElementMap, p = K._knockoutRenderedIds;
|
|
3207
|
+
p.clear(), e.forEach((g, b) => {
|
|
3164
3208
|
var S, m, w;
|
|
3165
|
-
if (
|
|
3166
|
-
const
|
|
3167
|
-
I && (C === "artboard" ||
|
|
3209
|
+
if (g.blendMode === "knockout" || g.blendMode === "clip") {
|
|
3210
|
+
const v = d[b], M = g.blendMode === "knockout" ? "destination-out" : "destination-in", C = ((S = v.knockoutParts) == null ? void 0 : S.scope) || "group", R = d.findIndex((k) => k.id === v.id), I = ((m = v.knockoutParts) == null ? void 0 : m.fill) || ((w = v.knockoutParts) == null ? void 0 : w.stroke), x = C === "artboard" && R !== -1 ? d.slice(0, R) : [];
|
|
3211
|
+
I && (C === "artboard" || x.length > 0) && (x.forEach((k) => k.id && p.add(k.id)), _e(
|
|
3168
3212
|
t,
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
(
|
|
3172
|
-
const
|
|
3173
|
-
|
|
3213
|
+
v,
|
|
3214
|
+
d,
|
|
3215
|
+
(k, P) => {
|
|
3216
|
+
const D = P.id && y.get(P.id);
|
|
3217
|
+
D && this.renderElement(k, D, r);
|
|
3174
3218
|
},
|
|
3175
3219
|
i,
|
|
3176
3220
|
a,
|
|
3177
|
-
|
|
3178
|
-
),
|
|
3221
|
+
M
|
|
3222
|
+
), p.add(g.id));
|
|
3179
3223
|
}
|
|
3180
|
-
}), e.some((
|
|
3224
|
+
}), e.some((g) => !p.has(g.id) && g.isClipping) ? this._renderWithClipping(
|
|
3181
3225
|
t,
|
|
3182
3226
|
e,
|
|
3183
|
-
|
|
3227
|
+
p,
|
|
3184
3228
|
s,
|
|
3185
3229
|
n,
|
|
3186
3230
|
c,
|
|
3231
|
+
f,
|
|
3187
3232
|
d,
|
|
3188
|
-
g,
|
|
3189
3233
|
r
|
|
3190
|
-
) : e.forEach((
|
|
3191
|
-
var
|
|
3192
|
-
if (
|
|
3193
|
-
const
|
|
3194
|
-
if (
|
|
3195
|
-
|
|
3196
|
-
const
|
|
3197
|
-
r && (
|
|
3234
|
+
) : e.forEach((g) => {
|
|
3235
|
+
var R, I;
|
|
3236
|
+
if (p.has(g.id) || g.visible === !1) return;
|
|
3237
|
+
const b = g.id === s, S = (n == null ? void 0 : n.type) === "element" && ((R = n == null ? void 0 : n.data) == null ? void 0 : R.id) === g.id, m = c && f && Ot(g) && g.id === s, w = b && !m, v = d[e.indexOf(g)], M = ((I = v == null ? void 0 : v.distressEffect) == null ? void 0 : I.enabled) && v.distressEffect.style === "custom" && v.distressEffect.textureUrl, C = (x) => {
|
|
3238
|
+
if (v && v.masks && v.masks.length > 0)
|
|
3239
|
+
Qt(g) && g.isCropping && (x.save(), x.globalAlpha *= dn, this.safeRender(x, g, w, S), x.restore()), Pt(x, v, (A) => {
|
|
3240
|
+
const k = (P) => {
|
|
3241
|
+
r && (P.save(), P.globalAlpha = tt), this.safeRender(P, g, w, S), r && P.restore();
|
|
3198
3242
|
};
|
|
3199
|
-
if (
|
|
3200
|
-
const
|
|
3201
|
-
|
|
3243
|
+
if (M) {
|
|
3244
|
+
const P = g.getVisualBoundingBox();
|
|
3245
|
+
Jt(A, v.distressEffect, P, k);
|
|
3202
3246
|
} else
|
|
3203
|
-
|
|
3247
|
+
k(A);
|
|
3204
3248
|
});
|
|
3205
|
-
else if (
|
|
3206
|
-
const
|
|
3207
|
-
|
|
3208
|
-
r && (
|
|
3249
|
+
else if (M) {
|
|
3250
|
+
const A = g.getVisualBoundingBox();
|
|
3251
|
+
Jt(x, v.distressEffect, A, (k) => {
|
|
3252
|
+
r && (k.save(), k.globalAlpha = tt), this.safeRender(k, g, w, S), r && k.restore();
|
|
3209
3253
|
});
|
|
3210
|
-
} else l && !h && a && w ? this.renderElementWithOverflowDimming(
|
|
3254
|
+
} else l && !h && a && w ? this.renderElementWithOverflowDimming(x, g, a, w, S, r) : l && a ? (x.save(), this.applyArtboardClipPath(x, a), r && (x.globalAlpha = tt), this.safeRender(x, g, w, S), x.restore()) : (r && (x.save(), x.globalAlpha = tt), this.safeRender(x, g, w, S), r && x.restore());
|
|
3211
3255
|
};
|
|
3212
|
-
|
|
3256
|
+
Ft(
|
|
3213
3257
|
t,
|
|
3214
|
-
|
|
3215
|
-
(
|
|
3258
|
+
v,
|
|
3259
|
+
(x) => C(x)
|
|
3216
3260
|
);
|
|
3217
3261
|
});
|
|
3218
3262
|
}
|
|
@@ -3221,57 +3265,57 @@ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
|
|
|
3221
3265
|
* Elements with isClipping=true clip all elements below them
|
|
3222
3266
|
*/
|
|
3223
3267
|
static _renderWithClipping(t, e, s, n, o, i, a, r, l = !0) {
|
|
3224
|
-
var
|
|
3225
|
-
const h = t.canvas, c = h.width,
|
|
3226
|
-
let
|
|
3227
|
-
for (let
|
|
3228
|
-
const S = e[
|
|
3229
|
-
s.has(S.id) || S.visible !== !1 && (S.isClipping ?
|
|
3230
|
-
content:
|
|
3268
|
+
var g;
|
|
3269
|
+
const h = t.canvas, c = h.width, f = h.height, d = t.getTransform(), y = [];
|
|
3270
|
+
let p = [], u = [];
|
|
3271
|
+
for (let b = 0; b < e.length; b++) {
|
|
3272
|
+
const S = e[b], m = r[b];
|
|
3273
|
+
s.has(S.id) || S.visible !== !1 && (S.isClipping ? p.length > 0 ? (y.push({
|
|
3274
|
+
content: p,
|
|
3231
3275
|
mask: S,
|
|
3232
|
-
contentConfigs:
|
|
3276
|
+
contentConfigs: u,
|
|
3233
3277
|
maskConfig: m
|
|
3234
|
-
}),
|
|
3278
|
+
}), p = [], u = []) : y.push({
|
|
3235
3279
|
content: [S],
|
|
3236
3280
|
contentConfigs: [m]
|
|
3237
|
-
}) : (
|
|
3281
|
+
}) : (p.push(S), u.push(m)));
|
|
3238
3282
|
}
|
|
3239
|
-
|
|
3240
|
-
content:
|
|
3241
|
-
contentConfigs:
|
|
3283
|
+
p.length > 0 && y.push({
|
|
3284
|
+
content: p,
|
|
3285
|
+
contentConfigs: u
|
|
3242
3286
|
});
|
|
3243
|
-
for (const
|
|
3244
|
-
if (!
|
|
3245
|
-
|
|
3287
|
+
for (const b of y)
|
|
3288
|
+
if (!b.mask)
|
|
3289
|
+
b.content.forEach((S, m) => {
|
|
3246
3290
|
var I;
|
|
3247
|
-
const w = S.id === n,
|
|
3248
|
-
|
|
3249
|
-
const
|
|
3250
|
-
|
|
3251
|
-
l && (
|
|
3252
|
-
}) : (l && (
|
|
3291
|
+
const w = S.id === n, v = (o == null ? void 0 : o.type) === "element" && ((I = o == null ? void 0 : o.data) == null ? void 0 : I.id) === S.id, M = i && a && Ot(S) && S.id === n, C = w && !M, R = b.contentConfigs[m];
|
|
3292
|
+
Ft(t, R, (x) => {
|
|
3293
|
+
const A = x;
|
|
3294
|
+
R && R.masks && R.masks.length > 0 ? Pt(A, R, (k) => {
|
|
3295
|
+
l && (k.save(), k.globalAlpha = tt), S.render(k, C, v), l && k.restore();
|
|
3296
|
+
}) : (l && (A.save(), A.globalAlpha = tt), S.render(A, C, v), l && A.restore());
|
|
3253
3297
|
});
|
|
3254
3298
|
});
|
|
3255
3299
|
else {
|
|
3256
|
-
const S = this._getContentCanvas(c,
|
|
3300
|
+
const S = this._getContentCanvas(c, f), m = S.getContext("2d");
|
|
3257
3301
|
if (!m) continue;
|
|
3258
|
-
m.setTransform(1, 0, 0, 1, 0, 0), m.clearRect(0, 0, c,
|
|
3302
|
+
m.setTransform(1, 0, 0, 1, 0, 0), m.clearRect(0, 0, c, f), m.globalCompositeOperation = "source-over", m.setTransform(d), b.content.forEach((R, I) => {
|
|
3259
3303
|
var _;
|
|
3260
|
-
const
|
|
3261
|
-
|
|
3262
|
-
const V =
|
|
3263
|
-
|
|
3264
|
-
l && (j.save(), j.globalAlpha = tt),
|
|
3265
|
-
}) : (l && (V.save(), V.globalAlpha = tt),
|
|
3304
|
+
const x = R.id === n, A = (o == null ? void 0 : o.type) === "element" && ((_ = o == null ? void 0 : o.data) == null ? void 0 : _.id) === R.id, k = i && a && Ot(R) && R.id === n, P = x && !k, D = b.contentConfigs[I];
|
|
3305
|
+
Ft(m, D, (Y) => {
|
|
3306
|
+
const V = Y;
|
|
3307
|
+
D && D.masks && D.masks.length > 0 ? Pt(V, D, (j) => {
|
|
3308
|
+
l && (j.save(), j.globalAlpha = tt), R.render(j, P, A), l && j.restore();
|
|
3309
|
+
}) : (l && (V.save(), V.globalAlpha = tt), R.render(V, P, A), l && V.restore());
|
|
3266
3310
|
});
|
|
3267
3311
|
});
|
|
3268
|
-
const w = this._getMaskCanvas(c,
|
|
3269
|
-
if (!
|
|
3270
|
-
|
|
3271
|
-
const
|
|
3272
|
-
|
|
3273
|
-
l && (
|
|
3274
|
-
}) : (l && (
|
|
3312
|
+
const w = this._getMaskCanvas(c, f), v = w.getContext("2d");
|
|
3313
|
+
if (!v) continue;
|
|
3314
|
+
v.setTransform(1, 0, 0, 1, 0, 0), v.clearRect(0, 0, c, f), v.globalCompositeOperation = "source-over", v.setTransform(d);
|
|
3315
|
+
const M = b.mask.id === n, C = (o == null ? void 0 : o.type) === "element" && ((g = o == null ? void 0 : o.data) == null ? void 0 : g.id) === b.mask.id;
|
|
3316
|
+
b.maskConfig && b.maskConfig.masks && b.maskConfig.masks.length > 0 ? Pt(v, b.maskConfig, (R) => {
|
|
3317
|
+
l && (R.save(), R.globalAlpha = tt), b.mask.render(R, M, C), l && R.restore();
|
|
3318
|
+
}) : (l && (v.save(), v.globalAlpha = tt), b.mask.render(v, M, C), l && v.restore()), m.globalCompositeOperation = "destination-in", m.setTransform(1, 0, 0, 1, 0, 0), m.drawImage(w, 0, 0), t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(S, 0, 0), t.restore();
|
|
3275
3319
|
}
|
|
3276
3320
|
}
|
|
3277
3321
|
// =========================================================================
|
|
@@ -3334,14 +3378,14 @@ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
|
|
|
3334
3378
|
* @see HoverRenderer.renderHoverLayer
|
|
3335
3379
|
*/
|
|
3336
3380
|
static renderHoverLayer(t, e, s, n = !1, o = 1, i) {
|
|
3337
|
-
|
|
3381
|
+
Nt.renderHoverLayer(t, e, s, n, o, i);
|
|
3338
3382
|
}
|
|
3339
3383
|
/**
|
|
3340
3384
|
* Render crop box layer (for images in crop mode)
|
|
3341
3385
|
* @see EditModeRenderer.renderCropBoxLayer
|
|
3342
3386
|
*/
|
|
3343
3387
|
static renderCropBoxLayer(t, e, s, n = 1) {
|
|
3344
|
-
|
|
3388
|
+
Yt.renderCropBoxLayer(t, e, s, n);
|
|
3345
3389
|
}
|
|
3346
3390
|
// =========================================================================
|
|
3347
3391
|
// Main Render Orchestration
|
|
@@ -3369,14 +3413,15 @@ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
|
|
|
3369
3413
|
spacingIndicators: l = [],
|
|
3370
3414
|
artboardBackgroundColor: h,
|
|
3371
3415
|
artboard: c,
|
|
3372
|
-
isPreview:
|
|
3373
|
-
zoom:
|
|
3374
|
-
paddingOffset:
|
|
3375
|
-
showOverflowDimmed:
|
|
3376
|
-
suppressOverflowDim:
|
|
3377
|
-
distressTexture:
|
|
3378
|
-
imageMask:
|
|
3379
|
-
|
|
3416
|
+
isPreview: f = !0,
|
|
3417
|
+
zoom: d = 1,
|
|
3418
|
+
paddingOffset: y = { x: 0, y: 0 },
|
|
3419
|
+
showOverflowDimmed: p = !1,
|
|
3420
|
+
suppressOverflowDim: u = !1,
|
|
3421
|
+
distressTexture: g,
|
|
3422
|
+
imageMask: b,
|
|
3423
|
+
engrave: S,
|
|
3424
|
+
editModeData: m
|
|
3380
3425
|
}) {
|
|
3381
3426
|
if (this.renderElementsLayer(
|
|
3382
3427
|
t,
|
|
@@ -3386,34 +3431,34 @@ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
|
|
|
3386
3431
|
a ?? void 0,
|
|
3387
3432
|
h,
|
|
3388
3433
|
c,
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
),
|
|
3434
|
+
f,
|
|
3435
|
+
p,
|
|
3436
|
+
u
|
|
3437
|
+
), g != null && g.enabled && c && ze(t, g, c, h), b != null && b.enabled && c && Ve(t, b, c, h), S && c && rn(t, S, c), i && m && n && Yt.renderEditModeLayer(t, n, m, d), d !== 1) {
|
|
3393
3438
|
t.save();
|
|
3394
|
-
const
|
|
3395
|
-
t.setTransform(
|
|
3439
|
+
const C = t.getTransform().a / d, R = y.x * d * C, I = y.y * d * C;
|
|
3440
|
+
t.setTransform(C, 0, 0, C, R, I);
|
|
3396
3441
|
}
|
|
3397
|
-
const
|
|
3398
|
-
...
|
|
3399
|
-
x:
|
|
3400
|
-
y:
|
|
3401
|
-
x1:
|
|
3402
|
-
y1:
|
|
3403
|
-
x2:
|
|
3404
|
-
y2:
|
|
3405
|
-
})),
|
|
3406
|
-
...
|
|
3407
|
-
x:
|
|
3408
|
-
y:
|
|
3409
|
-
x1:
|
|
3410
|
-
y1:
|
|
3411
|
-
x2:
|
|
3412
|
-
y2:
|
|
3413
|
-
labelX:
|
|
3414
|
-
labelY:
|
|
3442
|
+
const w = r.map((M) => ({
|
|
3443
|
+
...M,
|
|
3444
|
+
x: M.x !== void 0 ? M.x * d : void 0,
|
|
3445
|
+
y: M.y !== void 0 ? M.y * d : void 0,
|
|
3446
|
+
x1: M.x1 !== void 0 ? M.x1 * d : void 0,
|
|
3447
|
+
y1: M.y1 !== void 0 ? M.y1 * d : void 0,
|
|
3448
|
+
x2: M.x2 !== void 0 ? M.x2 * d : void 0,
|
|
3449
|
+
y2: M.y2 !== void 0 ? M.y2 * d : void 0
|
|
3450
|
+
})), v = l.map((M) => ({
|
|
3451
|
+
...M,
|
|
3452
|
+
x: M.x !== void 0 ? M.x * d : void 0,
|
|
3453
|
+
y: M.y !== void 0 ? M.y * d : void 0,
|
|
3454
|
+
x1: M.x1 !== void 0 ? M.x1 * d : void 0,
|
|
3455
|
+
y1: M.y1 !== void 0 ? M.y1 * d : void 0,
|
|
3456
|
+
x2: M.x2 !== void 0 ? M.x2 * d : void 0,
|
|
3457
|
+
y2: M.y2 !== void 0 ? M.y2 * d : void 0,
|
|
3458
|
+
labelX: M.labelX * d,
|
|
3459
|
+
labelY: M.labelY * d
|
|
3415
3460
|
}));
|
|
3416
|
-
Rt.renderSnapGuidesLayer(t,
|
|
3461
|
+
Rt.renderSnapGuidesLayer(t, w), Rt.renderSpacingIndicatorsLayer(t, v), d !== 1 && t.restore();
|
|
3417
3462
|
}
|
|
3418
3463
|
/**
|
|
3419
3464
|
* Single-selection interaction chrome: bbox, handles, position/size
|
|
@@ -3439,20 +3484,20 @@ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
|
|
|
3439
3484
|
hideHandles: l = !1,
|
|
3440
3485
|
isEditing: h,
|
|
3441
3486
|
isAltKeyPressed: c = !1,
|
|
3442
|
-
artboardBackgroundColor:
|
|
3443
|
-
hoverClipArtboard:
|
|
3444
|
-
showRotationHandle:
|
|
3445
|
-
zoom:
|
|
3446
|
-
paddingOffset:
|
|
3487
|
+
artboardBackgroundColor: f,
|
|
3488
|
+
hoverClipArtboard: d,
|
|
3489
|
+
showRotationHandle: y = !0,
|
|
3490
|
+
zoom: p = 1,
|
|
3491
|
+
paddingOffset: u = { x: 0, y: 0 }
|
|
3447
3492
|
}) {
|
|
3448
|
-
if (
|
|
3493
|
+
if (p !== 1) {
|
|
3449
3494
|
t.save();
|
|
3450
|
-
const S = t.getTransform().a /
|
|
3495
|
+
const S = t.getTransform().a / p, m = u.x * p * S, w = u.y * p * S;
|
|
3451
3496
|
t.setTransform(S, 0, 0, S, m, w);
|
|
3452
3497
|
}
|
|
3453
|
-
if (e &&
|
|
3454
|
-
s &&
|
|
3455
|
-
else if (!l && n && wt.renderSelectionLayer(t, e, n,
|
|
3498
|
+
if (e && Qt(e) && e.isCropping)
|
|
3499
|
+
s && Yt.renderCropBoxLayer(t, e, s, p);
|
|
3500
|
+
else if (!l && n && wt.renderSelectionLayer(t, e, n, p), s && n && wt.renderPositionSizeInfo(t, e, s, n, p), !l && s && n && wt.renderHandlesLayer(
|
|
3456
3501
|
t,
|
|
3457
3502
|
e,
|
|
3458
3503
|
s,
|
|
@@ -3460,37 +3505,38 @@ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
|
|
|
3460
3505
|
i,
|
|
3461
3506
|
a,
|
|
3462
3507
|
n,
|
|
3463
|
-
|
|
3464
|
-
|
|
3508
|
+
p,
|
|
3509
|
+
y
|
|
3465
3510
|
), !h) {
|
|
3466
|
-
if (
|
|
3511
|
+
if (d) {
|
|
3467
3512
|
t.save();
|
|
3468
|
-
const
|
|
3469
|
-
t.beginPath(),
|
|
3513
|
+
const b = d, S = b.x * p, m = b.y * p, w = b.width * p, v = b.height * p, M = (b.borderRadius ?? 0) * p;
|
|
3514
|
+
t.beginPath(), M > 0 ? t.roundRect(S, m, w, v, M) : t.rect(S, m, w, v), t.clip();
|
|
3470
3515
|
}
|
|
3471
|
-
|
|
3516
|
+
Nt.renderHoverLayer(t, a, r, c, p, f), d && t.restore();
|
|
3472
3517
|
}
|
|
3473
|
-
|
|
3518
|
+
p !== 1 && t.restore();
|
|
3474
3519
|
}
|
|
3475
3520
|
};
|
|
3476
|
-
|
|
3477
|
-
let
|
|
3521
|
+
K._contentCanvas = null, K._contentCanvasSize = { width: 0, height: 0 }, K._maskCanvas = null, K._maskCanvasSize = { width: 0, height: 0 }, K._cachedElementsRef = null, K._cachedElementConfigs = null, K._cachedElementMap = null, K._knockoutRenderedIds = /* @__PURE__ */ new Set(), K.onRenderError = null;
|
|
3522
|
+
let ie = K;
|
|
3478
3523
|
export {
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3524
|
+
Mn as A,
|
|
3525
|
+
ie as C,
|
|
3526
|
+
vn as I,
|
|
3527
|
+
nn as R,
|
|
3528
|
+
xn as S,
|
|
3529
|
+
Tn as T,
|
|
3530
|
+
fe as a,
|
|
3531
|
+
kn as b,
|
|
3532
|
+
Sn as c,
|
|
3533
|
+
bn as d,
|
|
3534
|
+
Je as e,
|
|
3535
|
+
wn as f,
|
|
3536
|
+
te as g,
|
|
3537
|
+
ge as n,
|
|
3538
|
+
Cn as p,
|
|
3539
|
+
mn as r,
|
|
3540
|
+
Rn as t
|
|
3495
3541
|
};
|
|
3496
|
-
//# sourceMappingURL=CanvasRenderer-
|
|
3542
|
+
//# sourceMappingURL=CanvasRenderer-B8BADU_r.js.map
|