leafer-ui 1.0.0-rc.6 → 1.0.0-rc.7
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/README.md +1 -1
- package/dist/web.esm.js +138 -96
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +1634 -1066
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +1616 -1064
- package/dist/web.module.min.js +1 -1
- package/package.json +4 -4
package/dist/web.module.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
const Platform = {
|
|
2
|
-
|
|
2
|
+
image: {
|
|
3
|
+
maxCacheSize: 2560 * 1600,
|
|
4
|
+
maxPatternSize: 4096 * 2160,
|
|
5
|
+
suffix: 'leaf'
|
|
6
|
+
}
|
|
3
7
|
};
|
|
4
8
|
|
|
5
9
|
const Creator = {};
|
|
@@ -24,6 +28,7 @@ const IncrementId = {
|
|
|
24
28
|
};
|
|
25
29
|
const I$2 = IncrementId;
|
|
26
30
|
|
|
31
|
+
const { round, pow: pow$1, PI: PI$4 } = Math;
|
|
27
32
|
const MathHelper = {
|
|
28
33
|
within(value, min, max) {
|
|
29
34
|
if (value < min)
|
|
@@ -32,20 +37,18 @@ const MathHelper = {
|
|
|
32
37
|
value = max;
|
|
33
38
|
return value;
|
|
34
39
|
},
|
|
35
|
-
fourNumber(num) {
|
|
36
|
-
let
|
|
40
|
+
fourNumber(num, maxValue) {
|
|
41
|
+
let data;
|
|
37
42
|
if (num instanceof Array) {
|
|
38
43
|
switch (num.length) {
|
|
39
44
|
case 4:
|
|
40
|
-
|
|
45
|
+
data = num;
|
|
46
|
+
break;
|
|
41
47
|
case 2:
|
|
42
|
-
|
|
43
|
-
two = four = num[1];
|
|
48
|
+
data = [num[0], num[1], num[0], num[1]];
|
|
44
49
|
break;
|
|
45
50
|
case 3:
|
|
46
|
-
|
|
47
|
-
two = four = num[1];
|
|
48
|
-
three = num[2];
|
|
51
|
+
data = [num[0], num[1], num[2], num[1]];
|
|
49
52
|
break;
|
|
50
53
|
case 1:
|
|
51
54
|
num = num[0];
|
|
@@ -54,7 +57,13 @@ const MathHelper = {
|
|
|
54
57
|
num = 0;
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
|
-
|
|
60
|
+
if (!data)
|
|
61
|
+
data = [num, num, num, num];
|
|
62
|
+
if (maxValue)
|
|
63
|
+
for (let i = 0; i < 4; i++)
|
|
64
|
+
if (data[i] > maxValue)
|
|
65
|
+
data[i] = maxValue;
|
|
66
|
+
return data;
|
|
58
67
|
},
|
|
59
68
|
formatRotation(rotation, unsign) {
|
|
60
69
|
rotation %= 360;
|
|
@@ -70,29 +79,37 @@ const MathHelper = {
|
|
|
70
79
|
}
|
|
71
80
|
return rotation;
|
|
72
81
|
},
|
|
73
|
-
getGapRotation(
|
|
82
|
+
getGapRotation(addRotation, gap, oldRotation = 0) {
|
|
83
|
+
let rotation = addRotation + oldRotation;
|
|
74
84
|
if (gap > 1) {
|
|
75
85
|
const r = Math.abs(rotation % gap);
|
|
76
86
|
if (r < 1 || r > gap - 1)
|
|
77
87
|
rotation = Math.round(rotation / gap) * gap;
|
|
78
88
|
}
|
|
79
|
-
return rotation;
|
|
89
|
+
return rotation - oldRotation;
|
|
80
90
|
},
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
float(num, maxLength) {
|
|
92
|
+
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
93
|
+
num = round(num * a) / a;
|
|
94
|
+
return num === -0 ? 0 : num;
|
|
83
95
|
}
|
|
84
96
|
};
|
|
85
|
-
const OneRadian =
|
|
86
|
-
const PI2 =
|
|
87
|
-
const PI_2 =
|
|
97
|
+
const OneRadian = PI$4 / 180;
|
|
98
|
+
const PI2 = PI$4 * 2;
|
|
99
|
+
const PI_2 = PI$4 / 2;
|
|
88
100
|
|
|
89
|
-
const { sin: sin$
|
|
90
|
-
const
|
|
101
|
+
const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
|
|
102
|
+
const { float } = MathHelper;
|
|
103
|
+
const tempPoint$2 = {};
|
|
91
104
|
function get$5() {
|
|
92
105
|
return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
|
|
93
106
|
}
|
|
107
|
+
function getWorld() {
|
|
108
|
+
return Object.assign(Object.assign({}, get$5()), { x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
|
|
109
|
+
}
|
|
94
110
|
const MatrixHelper = {
|
|
95
111
|
defaultMatrix: get$5(),
|
|
112
|
+
defaultWorld: getWorld(),
|
|
96
113
|
tempMatrix: {},
|
|
97
114
|
set(t, a = 1, b = 0, c = 0, d = 1, e = 0, f = 0) {
|
|
98
115
|
t.a = a;
|
|
@@ -103,6 +120,7 @@ const MatrixHelper = {
|
|
|
103
120
|
t.f = f;
|
|
104
121
|
},
|
|
105
122
|
get: get$5,
|
|
123
|
+
getWorld,
|
|
106
124
|
copy(t, matrix) {
|
|
107
125
|
t.a = matrix.a;
|
|
108
126
|
t.b = matrix.b;
|
|
@@ -119,115 +137,163 @@ const MatrixHelper = {
|
|
|
119
137
|
t.e += t.a * x + t.c * y;
|
|
120
138
|
t.f += t.b * x + t.d * y;
|
|
121
139
|
},
|
|
122
|
-
scale(t,
|
|
123
|
-
t.a *=
|
|
124
|
-
t.b *=
|
|
125
|
-
t.c *=
|
|
126
|
-
t.d *=
|
|
127
|
-
},
|
|
128
|
-
scaleOfOuter(t, origin, x, y = x) {
|
|
129
|
-
M$6.toInnerPoint(t, origin, tempPoint$1);
|
|
130
|
-
M$6.scaleOfInner(t, tempPoint$1, x, y);
|
|
131
|
-
},
|
|
132
|
-
scaleOfInner(t, origin, x, y = x) {
|
|
133
|
-
M$6.translateInner(t, origin.x, origin.y);
|
|
134
|
-
M$6.scale(t, x, y);
|
|
135
|
-
M$6.translateInner(t, -origin.x, -origin.y);
|
|
136
|
-
},
|
|
137
|
-
rotate(t, angle) {
|
|
138
|
-
angle *= OneRadian;
|
|
139
|
-
const cosR = cos$6(angle);
|
|
140
|
-
const sinR = sin$6(angle);
|
|
141
|
-
const { a, b, c, d } = t;
|
|
142
|
-
t.a = (a * cosR) - (b * sinR);
|
|
143
|
-
t.b = (a * sinR) + (b * cosR);
|
|
144
|
-
t.c = (c * cosR) - (d * sinR);
|
|
145
|
-
t.d = (c * sinR) + (d * cosR);
|
|
140
|
+
scale(t, scaleX, scaleY = scaleX) {
|
|
141
|
+
t.a *= scaleX;
|
|
142
|
+
t.b *= scaleX;
|
|
143
|
+
t.c *= scaleY;
|
|
144
|
+
t.d *= scaleY;
|
|
146
145
|
},
|
|
147
|
-
|
|
148
|
-
M$
|
|
149
|
-
M$
|
|
146
|
+
scaleOfOuter(t, origin, scaleX, scaleY) {
|
|
147
|
+
M$7.toInnerPoint(t, origin, tempPoint$2);
|
|
148
|
+
M$7.scaleOfInner(t, tempPoint$2, scaleX, scaleY);
|
|
150
149
|
},
|
|
151
|
-
|
|
152
|
-
M$
|
|
153
|
-
M$
|
|
154
|
-
M$
|
|
150
|
+
scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
|
|
151
|
+
M$7.translateInner(t, origin.x, origin.y);
|
|
152
|
+
M$7.scale(t, scaleX, scaleY);
|
|
153
|
+
M$7.translateInner(t, -origin.x, -origin.y);
|
|
155
154
|
},
|
|
156
|
-
|
|
155
|
+
rotate(t, rotation) {
|
|
156
|
+
const { a, b, c, d } = t;
|
|
157
|
+
rotation *= OneRadian;
|
|
158
|
+
const cosR = cos$5(rotation);
|
|
159
|
+
const sinR = sin$5(rotation);
|
|
160
|
+
t.a = a * cosR - b * sinR;
|
|
161
|
+
t.b = a * sinR + b * cosR;
|
|
162
|
+
t.c = c * cosR - d * sinR;
|
|
163
|
+
t.d = c * sinR + d * cosR;
|
|
164
|
+
},
|
|
165
|
+
rotateOfOuter(t, origin, rotation) {
|
|
166
|
+
M$7.toInnerPoint(t, origin, tempPoint$2);
|
|
167
|
+
M$7.rotateOfInner(t, tempPoint$2, rotation);
|
|
168
|
+
},
|
|
169
|
+
rotateOfInner(t, origin, rotation) {
|
|
170
|
+
M$7.translateInner(t, origin.x, origin.y);
|
|
171
|
+
M$7.rotate(t, rotation);
|
|
172
|
+
M$7.translateInner(t, -origin.x, -origin.y);
|
|
173
|
+
},
|
|
174
|
+
skew(t, skewX, skewY) {
|
|
157
175
|
const { a, b, c, d } = t;
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
t.a = a + c *
|
|
161
|
-
t.b = b + d *
|
|
176
|
+
if (skewY) {
|
|
177
|
+
skewY *= OneRadian;
|
|
178
|
+
t.a = a + c * skewY;
|
|
179
|
+
t.b = b + d * skewY;
|
|
162
180
|
}
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
t.c = c + a *
|
|
166
|
-
t.d = d + b *
|
|
181
|
+
if (skewX) {
|
|
182
|
+
skewX *= OneRadian;
|
|
183
|
+
t.c = c + a * skewX;
|
|
184
|
+
t.d = d + b * skewX;
|
|
167
185
|
}
|
|
168
186
|
},
|
|
169
|
-
skewOfOuter(t, origin,
|
|
170
|
-
M$
|
|
171
|
-
M$
|
|
187
|
+
skewOfOuter(t, origin, skewX, skewY) {
|
|
188
|
+
M$7.toInnerPoint(t, origin, tempPoint$2);
|
|
189
|
+
M$7.skewOfInner(t, tempPoint$2, skewX, skewY);
|
|
172
190
|
},
|
|
173
|
-
skewOfInner(t, origin,
|
|
174
|
-
M$
|
|
175
|
-
M$
|
|
176
|
-
M$
|
|
191
|
+
skewOfInner(t, origin, skewX, skewY = 0) {
|
|
192
|
+
M$7.translateInner(t, origin.x, origin.y);
|
|
193
|
+
M$7.skew(t, skewX, skewY);
|
|
194
|
+
M$7.translateInner(t, -origin.x, -origin.y);
|
|
177
195
|
},
|
|
178
|
-
multiply(t,
|
|
196
|
+
multiply(t, child) {
|
|
179
197
|
const { a, b, c, d, e, f } = t;
|
|
180
|
-
t.a =
|
|
181
|
-
t.b =
|
|
182
|
-
t.c =
|
|
183
|
-
t.d =
|
|
184
|
-
t.e =
|
|
185
|
-
t.f =
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
const {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
198
|
+
t.a = child.a * a + child.b * c;
|
|
199
|
+
t.b = child.a * b + child.b * d;
|
|
200
|
+
t.c = child.c * a + child.d * c;
|
|
201
|
+
t.d = child.c * b + child.d * d;
|
|
202
|
+
t.e = child.e * a + child.f * c + e;
|
|
203
|
+
t.f = child.e * b + child.f * d + f;
|
|
204
|
+
},
|
|
205
|
+
multiplyParent(t, parent, to, abcdChanged, childLayout) {
|
|
206
|
+
const { e, f } = t;
|
|
207
|
+
to || (to = t);
|
|
208
|
+
if (abcdChanged === undefined)
|
|
209
|
+
abcdChanged = t.a !== 1 || t.b || t.c || t.d !== 1;
|
|
210
|
+
if (abcdChanged) {
|
|
211
|
+
const { a, b, c, d } = t;
|
|
212
|
+
to.a = a * parent.a + b * parent.c;
|
|
213
|
+
to.b = a * parent.b + b * parent.d;
|
|
214
|
+
to.c = c * parent.a + d * parent.c;
|
|
215
|
+
to.d = c * parent.b + d * parent.d;
|
|
216
|
+
if (childLayout)
|
|
217
|
+
M$7.multiplyParentLayout(to, parent, childLayout);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
to.a = parent.a;
|
|
221
|
+
to.b = parent.b;
|
|
222
|
+
to.c = parent.c;
|
|
223
|
+
to.d = parent.d;
|
|
224
|
+
if (childLayout)
|
|
225
|
+
M$7.multiplyParentLayout(to, parent);
|
|
226
|
+
}
|
|
227
|
+
to.e = e * parent.a + f * parent.c + parent.e;
|
|
228
|
+
to.f = e * parent.b + f * parent.d + parent.f;
|
|
229
|
+
},
|
|
230
|
+
multiplyParentLayout(t, parent, child) {
|
|
231
|
+
if (child) {
|
|
232
|
+
t.scaleX = parent.scaleX * child.scaleX;
|
|
233
|
+
t.scaleY = parent.scaleY * child.scaleY;
|
|
234
|
+
t.rotation = parent.rotation + child.rotation;
|
|
235
|
+
t.skewX = parent.skewX + child.skewX;
|
|
236
|
+
t.skewY = parent.skewY + child.skewY;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
t.scaleX = parent.scaleX;
|
|
240
|
+
t.scaleY = parent.scaleY;
|
|
241
|
+
t.rotation = parent.rotation;
|
|
242
|
+
t.skewX = parent.skewX;
|
|
243
|
+
t.skewY = parent.skewY;
|
|
194
244
|
}
|
|
195
|
-
t.e = (e * matrix.a) + (f * matrix.c) + matrix.e;
|
|
196
|
-
t.f = (e * matrix.b) + (f * matrix.d) + matrix.f;
|
|
197
245
|
},
|
|
198
|
-
divide(t,
|
|
199
|
-
M$
|
|
246
|
+
divide(t, child) {
|
|
247
|
+
M$7.multiply(t, M$7.tempInvert(child));
|
|
248
|
+
},
|
|
249
|
+
divideParent(t, parent) {
|
|
250
|
+
M$7.multiplyParent(t, M$7.tempInvert(parent));
|
|
200
251
|
},
|
|
201
252
|
tempInvert(t) {
|
|
202
|
-
const { tempMatrix
|
|
203
|
-
M$
|
|
204
|
-
M$
|
|
205
|
-
return
|
|
253
|
+
const { tempMatrix } = M$7;
|
|
254
|
+
M$7.copy(tempMatrix, t);
|
|
255
|
+
M$7.invert(tempMatrix);
|
|
256
|
+
return tempMatrix;
|
|
206
257
|
},
|
|
207
258
|
invert(t) {
|
|
208
259
|
const { a, b, c, d, e, f } = t;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
260
|
+
if (!b && !c) {
|
|
261
|
+
if (a === 1 && d === 1) {
|
|
262
|
+
t.e = -e;
|
|
263
|
+
t.f = -f;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
const s = 1 / (a * d);
|
|
267
|
+
t.a = d * s;
|
|
268
|
+
t.d = a * s;
|
|
269
|
+
t.e = -e * d * s;
|
|
270
|
+
t.f = -f * a * s;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
const s = 1 / (a * d - b * c);
|
|
275
|
+
t.a = d * s;
|
|
276
|
+
t.b = -b * s;
|
|
277
|
+
t.c = -c * s;
|
|
278
|
+
t.d = a * s;
|
|
279
|
+
t.e = -(e * d - f * c) * s;
|
|
280
|
+
t.f = -(f * a - e * b) * s;
|
|
281
|
+
}
|
|
216
282
|
},
|
|
217
283
|
toOuterPoint(t, inner, to, distance) {
|
|
218
284
|
const { x, y } = inner;
|
|
219
285
|
to || (to = inner);
|
|
220
|
-
to.x =
|
|
221
|
-
to.y =
|
|
286
|
+
to.x = x * t.a + y * t.c;
|
|
287
|
+
to.y = x * t.b + y * t.d;
|
|
222
288
|
if (!distance) {
|
|
223
289
|
to.x += t.e;
|
|
224
290
|
to.y += t.f;
|
|
225
291
|
}
|
|
226
292
|
},
|
|
227
293
|
toInnerPoint(t, outer, to, distance) {
|
|
228
|
-
const { x, y } = outer;
|
|
229
294
|
const { a, b, c, d } = t;
|
|
230
295
|
const s = 1 / (a * d - b * c);
|
|
296
|
+
const { x, y } = outer;
|
|
231
297
|
to || (to = outer);
|
|
232
298
|
to.x = (x * d - y * c) * s;
|
|
233
299
|
to.y = (y * a - x * b) * s;
|
|
@@ -237,40 +303,84 @@ const MatrixHelper = {
|
|
|
237
303
|
to.y -= (f * a - e * b) * s;
|
|
238
304
|
}
|
|
239
305
|
},
|
|
240
|
-
|
|
241
|
-
const {
|
|
242
|
-
|
|
306
|
+
setLayout(t, layout, origin, bcChanged) {
|
|
307
|
+
const { x, y, scaleX, scaleY } = layout;
|
|
308
|
+
if (bcChanged === undefined)
|
|
309
|
+
bcChanged = layout.rotation || layout.skewX || layout.skewY;
|
|
310
|
+
if (bcChanged) {
|
|
311
|
+
const { rotation, skewX, skewY } = layout;
|
|
312
|
+
const r = rotation * OneRadian;
|
|
313
|
+
const cosR = cos$5(r);
|
|
314
|
+
const sinR = sin$5(r);
|
|
315
|
+
if (skewX || skewY) {
|
|
316
|
+
const sx = skewX * OneRadian;
|
|
317
|
+
const sy = skewY * OneRadian;
|
|
318
|
+
t.a = (cosR + sy * -sinR) * scaleX;
|
|
319
|
+
t.b = (sinR + sy * cosR) * scaleX;
|
|
320
|
+
t.c = (-sinR + sx * cosR) * scaleY;
|
|
321
|
+
t.d = (cosR + sx * sinR) * scaleY;
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
t.a = cosR * scaleX;
|
|
325
|
+
t.b = sinR * scaleX;
|
|
326
|
+
t.c = -sinR * scaleY;
|
|
327
|
+
t.d = cosR * scaleY;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
t.a = scaleX;
|
|
332
|
+
t.b = 0;
|
|
333
|
+
t.c = 0;
|
|
334
|
+
t.d = scaleY;
|
|
335
|
+
}
|
|
336
|
+
t.e = x;
|
|
337
|
+
t.f = y;
|
|
338
|
+
if (origin)
|
|
339
|
+
M$7.translateInner(t, -origin.x, -origin.y);
|
|
340
|
+
},
|
|
341
|
+
getLayout(t, origin, firstSkewY) {
|
|
342
|
+
const { a, b, c, d, e, f } = t;
|
|
343
|
+
let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
|
|
243
344
|
if (b || c) {
|
|
244
345
|
const s = a * d - b * c;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const ab = a * a + b * b;
|
|
248
|
-
scaleX = sqrt$3(ab);
|
|
346
|
+
if (c && !firstSkewY) {
|
|
347
|
+
scaleX = sqrt$3(a * a + b * b);
|
|
249
348
|
scaleY = s / scaleX;
|
|
250
|
-
const
|
|
251
|
-
rotation = b > 0 ? acos(
|
|
252
|
-
skewX = atan(k / ab) / OneRadian;
|
|
349
|
+
const cosR = a / scaleX;
|
|
350
|
+
rotation = b > 0 ? acos(cosR) : -acos(cosR);
|
|
253
351
|
}
|
|
254
352
|
else {
|
|
255
|
-
|
|
256
|
-
scaleY = sqrt$3(cd);
|
|
353
|
+
scaleY = sqrt$3(c * c + d * d);
|
|
257
354
|
scaleX = s / scaleY;
|
|
258
|
-
const
|
|
259
|
-
rotation =
|
|
260
|
-
skewY = atan(k / cd) / OneRadian;
|
|
355
|
+
const cosR = c / scaleY;
|
|
356
|
+
rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
|
|
261
357
|
}
|
|
262
|
-
|
|
358
|
+
const cosR = cos$5(rotation);
|
|
359
|
+
const sinR = sin$5(rotation);
|
|
360
|
+
scaleX = float(scaleX), scaleY = float(scaleY);
|
|
361
|
+
skewX = float((c / scaleY + sinR) / cosR / OneRadian);
|
|
362
|
+
skewY = float((b / scaleX - sinR) / cosR / OneRadian);
|
|
363
|
+
rotation = float(rotation / OneRadian);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
scaleX = a;
|
|
367
|
+
scaleY = d;
|
|
368
|
+
rotation = skewX = skewY = 0;
|
|
369
|
+
}
|
|
370
|
+
if (origin) {
|
|
371
|
+
x += origin.x * a + origin.y * c;
|
|
372
|
+
y += origin.x * b + origin.y * d;
|
|
263
373
|
}
|
|
264
|
-
return { x
|
|
374
|
+
return { x, y, scaleX, scaleY, rotation, skewX, skewY };
|
|
265
375
|
},
|
|
266
376
|
reset(t) {
|
|
267
|
-
M$
|
|
377
|
+
M$7.set(t);
|
|
268
378
|
}
|
|
269
379
|
};
|
|
270
|
-
const M$
|
|
380
|
+
const M$7 = MatrixHelper;
|
|
271
381
|
|
|
272
382
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
273
|
-
const { sin: sin$
|
|
383
|
+
const { sin: sin$4, cos: cos$4, abs: abs$3, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
274
384
|
const PointHelper = {
|
|
275
385
|
defaultPoint: { x: 0, y: 0 },
|
|
276
386
|
tempPoint: {},
|
|
@@ -291,32 +401,33 @@ const PointHelper = {
|
|
|
291
401
|
t.x += x;
|
|
292
402
|
t.y += y;
|
|
293
403
|
},
|
|
294
|
-
rotate(t, rotation,
|
|
295
|
-
if (!
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const
|
|
299
|
-
const
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
t.
|
|
404
|
+
rotate(t, rotation, origin) {
|
|
405
|
+
if (!origin)
|
|
406
|
+
origin = P$6.defaultPoint;
|
|
407
|
+
rotation *= OneRadian;
|
|
408
|
+
const cosR = cos$4(rotation);
|
|
409
|
+
const sinR = sin$4(rotation);
|
|
410
|
+
const rx = t.x - origin.x;
|
|
411
|
+
const ry = t.y - origin.y;
|
|
412
|
+
t.x = origin.x + rx * cosR - ry * sinR;
|
|
413
|
+
t.y = origin.y + rx * sinR + ry * cosR;
|
|
303
414
|
},
|
|
304
415
|
tempToInnerOf(t, matrix) {
|
|
305
|
-
const { tempPoint: temp } = P$
|
|
306
|
-
P$
|
|
416
|
+
const { tempPoint: temp } = P$6;
|
|
417
|
+
P$6.copy(temp, t);
|
|
307
418
|
toInnerPoint$2(matrix, temp, temp);
|
|
308
419
|
return temp;
|
|
309
420
|
},
|
|
310
421
|
tempToOuterOf(t, matrix) {
|
|
311
|
-
const { tempPoint: temp } = P$
|
|
312
|
-
P$
|
|
422
|
+
const { tempPoint: temp } = P$6;
|
|
423
|
+
P$6.copy(temp, t);
|
|
313
424
|
toOuterPoint$2(matrix, temp, temp);
|
|
314
425
|
return temp;
|
|
315
426
|
},
|
|
316
427
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
317
|
-
const { tempRadiusPoint: temp } = P$
|
|
318
|
-
P$
|
|
319
|
-
P$
|
|
428
|
+
const { tempRadiusPoint: temp } = P$6;
|
|
429
|
+
P$6.copy(temp, t);
|
|
430
|
+
P$6.toInnerRadiusPointOf(t, matrix, temp);
|
|
320
431
|
return temp;
|
|
321
432
|
},
|
|
322
433
|
toInnerRadiusPointOf(t, matrix, to) {
|
|
@@ -334,53 +445,78 @@ const PointHelper = {
|
|
|
334
445
|
getCenter(t, to) {
|
|
335
446
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
336
447
|
},
|
|
448
|
+
getCenterX(x1, x2) {
|
|
449
|
+
return x1 + (x2 - x1) / 2;
|
|
450
|
+
},
|
|
451
|
+
getCenterY(y1, y2) {
|
|
452
|
+
return y1 + (y2 - y1) / 2;
|
|
453
|
+
},
|
|
337
454
|
getDistance(t, point) {
|
|
338
|
-
|
|
339
|
-
|
|
455
|
+
return P$6.getDistanceFrom(t.x, t.y, point.x, point.y);
|
|
456
|
+
},
|
|
457
|
+
getDistanceFrom(x1, y1, x2, y2) {
|
|
458
|
+
const x = abs$3(x2 - x1);
|
|
459
|
+
const y = abs$3(y2 - y1);
|
|
340
460
|
return sqrt$2(x * x + y * y);
|
|
341
461
|
},
|
|
462
|
+
getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
|
|
463
|
+
return min$1(P$6.getDistanceFrom(x1, y1, x2, y2), P$6.getDistanceFrom(x2, y2, x3, y3));
|
|
464
|
+
},
|
|
342
465
|
getAngle(t, to) {
|
|
343
|
-
return P$
|
|
466
|
+
return P$6.getAtan2(t, to) / OneRadian;
|
|
344
467
|
},
|
|
345
|
-
|
|
468
|
+
getRotation(t, origin, to, toOrigin) {
|
|
346
469
|
if (!toOrigin)
|
|
347
|
-
toOrigin =
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
470
|
+
toOrigin = origin;
|
|
471
|
+
return P$6.getRadianFrom(t.x, t.y, origin.x, origin.y, to.x, to.y, toOrigin.x, toOrigin.y) / OneRadian;
|
|
472
|
+
},
|
|
473
|
+
getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
|
|
474
|
+
if (toOriginX === undefined)
|
|
475
|
+
toOriginX = originX, toOriginY = originY;
|
|
476
|
+
let fromAngle = atan2$2(fromY - originY, fromX - originX);
|
|
477
|
+
let toAngle = atan2$2(toY - toOriginY, toX - toOriginX);
|
|
478
|
+
const radian = toAngle - fromAngle;
|
|
479
|
+
return radian < -PI$3 ? radian + PI2 : radian;
|
|
352
480
|
},
|
|
353
481
|
getAtan2(t, to) {
|
|
354
482
|
return atan2$2(to.y - t.y, to.x - t.x);
|
|
355
483
|
},
|
|
356
484
|
getDistancePoint(t, to, distance) {
|
|
357
|
-
const r = P$
|
|
358
|
-
return { x: t.x + cos$
|
|
485
|
+
const r = P$6.getAtan2(t, to);
|
|
486
|
+
return { x: t.x + cos$4(r) * distance, y: t.y + sin$4(r) * distance };
|
|
359
487
|
},
|
|
360
488
|
reset(t) {
|
|
361
|
-
P$
|
|
489
|
+
P$6.reset(t);
|
|
362
490
|
}
|
|
363
491
|
};
|
|
364
|
-
const P$
|
|
492
|
+
const P$6 = PointHelper;
|
|
365
493
|
|
|
366
494
|
class Point {
|
|
367
495
|
constructor(x, y) {
|
|
368
|
-
|
|
496
|
+
this.set(x, y);
|
|
369
497
|
}
|
|
370
498
|
set(x, y) {
|
|
371
|
-
PointHelper.set(this, x, y);
|
|
372
|
-
}
|
|
373
|
-
copy(point) {
|
|
374
|
-
PointHelper.copy(this, point);
|
|
499
|
+
typeof x === 'object' ? PointHelper.copy(this, x) : PointHelper.set(this, x, y);
|
|
375
500
|
return this;
|
|
376
501
|
}
|
|
502
|
+
get() {
|
|
503
|
+
const { x, y } = this;
|
|
504
|
+
return { x, y };
|
|
505
|
+
}
|
|
377
506
|
clone() {
|
|
378
507
|
return new Point(this);
|
|
379
508
|
}
|
|
380
|
-
rotate(
|
|
381
|
-
PointHelper.rotate(this,
|
|
509
|
+
rotate(rotation, origin) {
|
|
510
|
+
PointHelper.rotate(this, rotation, origin);
|
|
511
|
+
return this;
|
|
512
|
+
}
|
|
513
|
+
rotateOf(origin, rotation) {
|
|
514
|
+
PointHelper.rotate(this, rotation, origin);
|
|
382
515
|
return this;
|
|
383
516
|
}
|
|
517
|
+
getRotation(origin, to, toOrigin) {
|
|
518
|
+
return PointHelper.getRotation(this, origin, to, toOrigin);
|
|
519
|
+
}
|
|
384
520
|
toInnerOf(matrix, to) {
|
|
385
521
|
PointHelper.toInnerOf(this, matrix, to);
|
|
386
522
|
return this;
|
|
@@ -390,11 +526,14 @@ class Point {
|
|
|
390
526
|
return this;
|
|
391
527
|
}
|
|
392
528
|
getCenter(to) {
|
|
393
|
-
return PointHelper.getCenter(this, to);
|
|
529
|
+
return new Point(PointHelper.getCenter(this, to));
|
|
394
530
|
}
|
|
395
531
|
getDistance(to) {
|
|
396
532
|
return PointHelper.getDistance(this, to);
|
|
397
533
|
}
|
|
534
|
+
getDistancePoint(to, distance) {
|
|
535
|
+
return new Point(PointHelper.getDistancePoint(this, to, distance));
|
|
536
|
+
}
|
|
398
537
|
getAngle(to) {
|
|
399
538
|
return PointHelper.getAngle(this, to);
|
|
400
539
|
}
|
|
@@ -403,20 +542,22 @@ class Point {
|
|
|
403
542
|
}
|
|
404
543
|
reset() {
|
|
405
544
|
PointHelper.reset(this);
|
|
545
|
+
return this;
|
|
406
546
|
}
|
|
407
547
|
}
|
|
408
548
|
|
|
409
549
|
class Matrix {
|
|
410
550
|
constructor(a, b, c, d, e, f) {
|
|
411
|
-
|
|
551
|
+
this.set(a, b, c, d, e, f);
|
|
412
552
|
}
|
|
413
553
|
set(a, b, c, d, e, f) {
|
|
414
|
-
MatrixHelper.set(this, a, b, c, d, e, f);
|
|
415
|
-
}
|
|
416
|
-
copy(matrix) {
|
|
417
|
-
MatrixHelper.copy(this, matrix);
|
|
554
|
+
typeof a === 'object' ? MatrixHelper.copy(this, a) : MatrixHelper.set(this, a, b, c, d, e, f);
|
|
418
555
|
return this;
|
|
419
556
|
}
|
|
557
|
+
get() {
|
|
558
|
+
const { a, b, c, d, e, f } = this;
|
|
559
|
+
return { a, b, c, d, e, f };
|
|
560
|
+
}
|
|
420
561
|
clone() {
|
|
421
562
|
return new Matrix(this);
|
|
422
563
|
}
|
|
@@ -464,16 +605,20 @@ class Matrix {
|
|
|
464
605
|
MatrixHelper.skewOfInner(this, origin, x, y);
|
|
465
606
|
return this;
|
|
466
607
|
}
|
|
467
|
-
multiply(
|
|
468
|
-
MatrixHelper.multiply(this,
|
|
608
|
+
multiply(child) {
|
|
609
|
+
MatrixHelper.multiply(this, child);
|
|
469
610
|
return this;
|
|
470
611
|
}
|
|
471
|
-
|
|
472
|
-
MatrixHelper.
|
|
612
|
+
multiplyParent(parent) {
|
|
613
|
+
MatrixHelper.multiplyParent(this, parent);
|
|
473
614
|
return this;
|
|
474
615
|
}
|
|
475
|
-
divide(
|
|
476
|
-
MatrixHelper.divide(this,
|
|
616
|
+
divide(child) {
|
|
617
|
+
MatrixHelper.divide(this, child);
|
|
618
|
+
return this;
|
|
619
|
+
}
|
|
620
|
+
divideParent(parent) {
|
|
621
|
+
MatrixHelper.divideParent(this, parent);
|
|
477
622
|
return this;
|
|
478
623
|
}
|
|
479
624
|
invert() {
|
|
@@ -486,8 +631,12 @@ class Matrix {
|
|
|
486
631
|
toInnerPoint(outer, to, distance) {
|
|
487
632
|
MatrixHelper.toInnerPoint(this, outer, to, distance);
|
|
488
633
|
}
|
|
489
|
-
|
|
490
|
-
|
|
634
|
+
setLayout(data, origin) {
|
|
635
|
+
MatrixHelper.setLayout(this, data, origin);
|
|
636
|
+
return this;
|
|
637
|
+
}
|
|
638
|
+
getLayout(origin, firstSkewY) {
|
|
639
|
+
return MatrixHelper.getLayout(this, origin, firstSkewY);
|
|
491
640
|
}
|
|
492
641
|
reset() {
|
|
493
642
|
MatrixHelper.reset(this);
|
|
@@ -516,7 +665,7 @@ const TwoPointBoundsHelper = {
|
|
|
516
665
|
t.maxX = pb.maxX;
|
|
517
666
|
t.maxY = pb.maxY;
|
|
518
667
|
},
|
|
519
|
-
|
|
668
|
+
addPointBounds(t, pb) {
|
|
520
669
|
t.minX = pb.minX < t.minX ? pb.minX : t.minX;
|
|
521
670
|
t.minY = pb.minY < t.minY ? pb.minY : t.minY;
|
|
522
671
|
t.maxX = pb.maxX > t.maxX ? pb.maxX : t.maxX;
|
|
@@ -531,11 +680,11 @@ const TwoPointBoundsHelper = {
|
|
|
531
680
|
};
|
|
532
681
|
const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
|
|
533
682
|
|
|
534
|
-
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$
|
|
683
|
+
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
535
684
|
const { toOuterPoint: toOuterPoint$1 } = MatrixHelper;
|
|
536
685
|
let right, bottom, boundsRight, boundsBottom;
|
|
537
686
|
const point = {};
|
|
538
|
-
const toPoint = {};
|
|
687
|
+
const toPoint$1 = {};
|
|
539
688
|
const BoundsHelper = {
|
|
540
689
|
tempBounds: {},
|
|
541
690
|
set(t, x = 0, y = 0, width = 0, height = 0) {
|
|
@@ -555,12 +704,10 @@ const BoundsHelper = {
|
|
|
555
704
|
spreadY = spreadX;
|
|
556
705
|
B.set(t, bounds.x - spreadX, bounds.y - spreadY, bounds.width + spreadX * 2, bounds.height + spreadY * 2);
|
|
557
706
|
},
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
},
|
|
561
|
-
|
|
562
|
-
return t.y + t.height;
|
|
563
|
-
},
|
|
707
|
+
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
708
|
+
minY(t) { return t.height > 0 ? t.y : t.y + t.height; },
|
|
709
|
+
maxX(t) { return t.width > 0 ? t.x + t.width : t.x; },
|
|
710
|
+
maxY(t) { return t.height > 0 ? t.y + t.height : t.y; },
|
|
564
711
|
move(t, x, y) {
|
|
565
712
|
t.x += x;
|
|
566
713
|
t.y += y;
|
|
@@ -578,8 +725,8 @@ const BoundsHelper = {
|
|
|
578
725
|
copy$7(to, t);
|
|
579
726
|
}
|
|
580
727
|
if (parent) {
|
|
581
|
-
to.offsetX = -(B.
|
|
582
|
-
to.offsetY = -(B.
|
|
728
|
+
to.offsetX = -(B.maxX(parent) - t.x);
|
|
729
|
+
to.offsetY = -(B.maxY(parent) - t.y);
|
|
583
730
|
}
|
|
584
731
|
else {
|
|
585
732
|
to.offsetX = t.x + t.width;
|
|
@@ -635,18 +782,18 @@ const BoundsHelper = {
|
|
|
635
782
|
else {
|
|
636
783
|
point.x = t.x;
|
|
637
784
|
point.y = t.y;
|
|
638
|
-
toOuterPoint$1(matrix, point, toPoint);
|
|
639
|
-
setPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
|
|
785
|
+
toOuterPoint$1(matrix, point, toPoint$1);
|
|
786
|
+
setPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
|
|
640
787
|
point.x = t.x + t.width;
|
|
641
|
-
toOuterPoint$1(matrix, point, toPoint);
|
|
642
|
-
addPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
|
|
788
|
+
toOuterPoint$1(matrix, point, toPoint$1);
|
|
789
|
+
addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
|
|
643
790
|
point.y = t.y + t.height;
|
|
644
|
-
toOuterPoint$1(matrix, point, toPoint);
|
|
645
|
-
addPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
|
|
791
|
+
toOuterPoint$1(matrix, point, toPoint$1);
|
|
792
|
+
addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
|
|
646
793
|
point.x = t.x;
|
|
647
|
-
toOuterPoint$1(matrix, point, toPoint);
|
|
648
|
-
addPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
|
|
649
|
-
toBounds$
|
|
794
|
+
toOuterPoint$1(matrix, point, toPoint$1);
|
|
795
|
+
addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
|
|
796
|
+
toBounds$3(tempPointBounds$1, to);
|
|
650
797
|
}
|
|
651
798
|
},
|
|
652
799
|
getFitMatrix(t, put) {
|
|
@@ -690,18 +837,18 @@ const BoundsHelper = {
|
|
|
690
837
|
t.height = bottom - t.y;
|
|
691
838
|
},
|
|
692
839
|
addList(t, list) {
|
|
693
|
-
B.
|
|
840
|
+
B.setListWithFn(t, list, undefined, true);
|
|
694
841
|
},
|
|
695
|
-
|
|
696
|
-
B.
|
|
842
|
+
setList(t, list, addMode = false) {
|
|
843
|
+
B.setListWithFn(t, list, undefined, addMode);
|
|
697
844
|
},
|
|
698
|
-
|
|
699
|
-
B.
|
|
845
|
+
addListWithFn(t, list, boundsDataFn) {
|
|
846
|
+
B.setListWithFn(t, list, boundsDataFn, true);
|
|
700
847
|
},
|
|
701
|
-
|
|
848
|
+
setListWithFn(t, list, boundsDataFn, addMode = false) {
|
|
702
849
|
let bounds, first = true;
|
|
703
850
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
704
|
-
bounds =
|
|
851
|
+
bounds = boundsDataFn ? boundsDataFn(list[i]) : list[i];
|
|
705
852
|
if (bounds && (bounds.width || bounds.height)) {
|
|
706
853
|
if (first) {
|
|
707
854
|
first = false;
|
|
@@ -709,18 +856,25 @@ const BoundsHelper = {
|
|
|
709
856
|
copy$7(t, bounds);
|
|
710
857
|
}
|
|
711
858
|
else {
|
|
712
|
-
add$
|
|
859
|
+
add$1(t, bounds);
|
|
713
860
|
}
|
|
714
861
|
}
|
|
715
862
|
}
|
|
716
863
|
if (first)
|
|
717
864
|
B.reset(t);
|
|
718
865
|
},
|
|
719
|
-
|
|
720
|
-
points.forEach((point, index) =>
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
866
|
+
setPoints(t, points) {
|
|
867
|
+
points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
|
|
868
|
+
toBounds$3(tempPointBounds$1, t);
|
|
869
|
+
},
|
|
870
|
+
getPoints(t) {
|
|
871
|
+
const { x, y, width, height } = t;
|
|
872
|
+
return [
|
|
873
|
+
{ x, y },
|
|
874
|
+
{ x: x + width, y },
|
|
875
|
+
{ x: x + width, y: y + height },
|
|
876
|
+
{ x, y: y + height }
|
|
877
|
+
];
|
|
724
878
|
},
|
|
725
879
|
hitRadiusPoint(t, point, pointMatrix) {
|
|
726
880
|
if (pointMatrix)
|
|
@@ -772,19 +926,24 @@ const BoundsHelper = {
|
|
|
772
926
|
}
|
|
773
927
|
};
|
|
774
928
|
const B = BoundsHelper;
|
|
775
|
-
const { add: add$
|
|
929
|
+
const { add: add$1, copy: copy$7 } = B;
|
|
776
930
|
|
|
777
931
|
class Bounds {
|
|
932
|
+
get minX() { return BoundsHelper.minX(this); }
|
|
933
|
+
get minY() { return BoundsHelper.minY(this); }
|
|
934
|
+
get maxX() { return BoundsHelper.maxX(this); }
|
|
935
|
+
get maxY() { return BoundsHelper.maxY(this); }
|
|
778
936
|
constructor(x, y, width, height) {
|
|
779
|
-
|
|
937
|
+
this.set(x, y, width, height);
|
|
780
938
|
}
|
|
781
939
|
set(x, y, width, height) {
|
|
782
|
-
BoundsHelper.set(this, x, y, width, height);
|
|
783
|
-
}
|
|
784
|
-
copy(bounds) {
|
|
785
|
-
BoundsHelper.copy(this, bounds);
|
|
940
|
+
typeof x === 'object' ? BoundsHelper.copy(this, x) : BoundsHelper.set(this, x, y, width, height);
|
|
786
941
|
return this;
|
|
787
942
|
}
|
|
943
|
+
get() {
|
|
944
|
+
const { x, y, width, height } = this;
|
|
945
|
+
return { x, y, width, height };
|
|
946
|
+
}
|
|
788
947
|
clone() {
|
|
789
948
|
return new Bounds(this);
|
|
790
949
|
}
|
|
@@ -820,25 +979,28 @@ class Bounds {
|
|
|
820
979
|
return this;
|
|
821
980
|
}
|
|
822
981
|
addList(boundsList) {
|
|
823
|
-
BoundsHelper.
|
|
982
|
+
BoundsHelper.setList(this, boundsList, true);
|
|
824
983
|
return this;
|
|
825
984
|
}
|
|
826
|
-
|
|
827
|
-
BoundsHelper.
|
|
985
|
+
setList(boundsList) {
|
|
986
|
+
BoundsHelper.setList(this, boundsList);
|
|
828
987
|
return this;
|
|
829
988
|
}
|
|
830
|
-
|
|
831
|
-
BoundsHelper.
|
|
989
|
+
addListWithFn(list, boundsDataFn) {
|
|
990
|
+
BoundsHelper.setListWithFn(this, list, boundsDataFn, true);
|
|
832
991
|
return this;
|
|
833
992
|
}
|
|
834
|
-
|
|
835
|
-
BoundsHelper.
|
|
993
|
+
setListWithFn(list, boundsDataFn) {
|
|
994
|
+
BoundsHelper.setListWithFn(this, list, boundsDataFn);
|
|
836
995
|
return this;
|
|
837
996
|
}
|
|
838
|
-
|
|
839
|
-
BoundsHelper.
|
|
997
|
+
setPoints(points) {
|
|
998
|
+
BoundsHelper.setPoints(this, points);
|
|
840
999
|
return this;
|
|
841
1000
|
}
|
|
1001
|
+
getPoints() {
|
|
1002
|
+
return BoundsHelper.getPoints(this);
|
|
1003
|
+
}
|
|
842
1004
|
hitPoint(point, pointMatrix) {
|
|
843
1005
|
return BoundsHelper.hitPoint(this, point, pointMatrix);
|
|
844
1006
|
}
|
|
@@ -891,20 +1053,25 @@ class AutoBounds {
|
|
|
891
1053
|
}
|
|
892
1054
|
}
|
|
893
1055
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1056
|
+
const center = { x: 0.5, y: 0.5 };
|
|
1057
|
+
const AroundHelper = {
|
|
1058
|
+
center,
|
|
1059
|
+
tempPoint: {},
|
|
1060
|
+
toPoint(around, bounds, to, onlySize) {
|
|
1061
|
+
to || (to = {});
|
|
1062
|
+
switch (around) {
|
|
1063
|
+
case 'center':
|
|
1064
|
+
around = center;
|
|
1065
|
+
break;
|
|
1066
|
+
}
|
|
1067
|
+
to.x = around.x * bounds.width;
|
|
1068
|
+
to.y = around.y * bounds.height;
|
|
1069
|
+
if (!onlySize) {
|
|
1070
|
+
to.x += bounds.x;
|
|
1071
|
+
to.y += bounds.y;
|
|
1072
|
+
}
|
|
906
1073
|
}
|
|
907
|
-
}
|
|
1074
|
+
};
|
|
908
1075
|
|
|
909
1076
|
const StringNumberMap = {
|
|
910
1077
|
'0': 1,
|
|
@@ -945,18 +1112,21 @@ class Debug {
|
|
|
945
1112
|
this.excludeList = name;
|
|
946
1113
|
}
|
|
947
1114
|
log(...messages) {
|
|
948
|
-
if (D$
|
|
949
|
-
if (D$
|
|
1115
|
+
if (D$5.enable) {
|
|
1116
|
+
if (D$5.filterList.length && D$5.filterList.every(name => name !== this.name))
|
|
950
1117
|
return;
|
|
951
|
-
if (D$
|
|
1118
|
+
if (D$5.excludeList.length && D$5.excludeList.some(name => name === this.name))
|
|
952
1119
|
return;
|
|
953
1120
|
console.log('%c' + this.name, 'color:#21ae62', ...messages);
|
|
954
1121
|
}
|
|
955
1122
|
}
|
|
956
|
-
|
|
957
|
-
if (D$
|
|
1123
|
+
tip(...messages) {
|
|
1124
|
+
if (D$5.enable)
|
|
958
1125
|
console.warn(this.name, ...messages);
|
|
959
1126
|
}
|
|
1127
|
+
warn(...messages) {
|
|
1128
|
+
console.warn(this.name, ...messages);
|
|
1129
|
+
}
|
|
960
1130
|
repeat(name, ...messages) {
|
|
961
1131
|
if (!this.repeatMap[name]) {
|
|
962
1132
|
this.warn('repeat:' + name, ...messages);
|
|
@@ -974,46 +1144,43 @@ class Debug {
|
|
|
974
1144
|
}
|
|
975
1145
|
Debug.filterList = [];
|
|
976
1146
|
Debug.excludeList = [];
|
|
977
|
-
const D$
|
|
978
|
-
|
|
979
|
-
const debug$
|
|
980
|
-
|
|
981
|
-
|
|
1147
|
+
const D$5 = Debug;
|
|
1148
|
+
|
|
1149
|
+
const debug$g = Debug.get('RunTime');
|
|
1150
|
+
const Run = {
|
|
1151
|
+
currentId: 0,
|
|
1152
|
+
currentName: '',
|
|
1153
|
+
idMap: {},
|
|
1154
|
+
nameMap: {},
|
|
1155
|
+
nameToIdMap: {},
|
|
1156
|
+
start(name, microsecond) {
|
|
982
1157
|
const id = IncrementId.create(IncrementId.RUNTIME);
|
|
983
1158
|
R.currentId = R.idMap[id] = microsecond ? performance.now() : Date.now();
|
|
984
1159
|
R.currentName = R.nameMap[id] = name;
|
|
985
1160
|
R.nameToIdMap[name] = id;
|
|
986
1161
|
return id;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
const time = R.idMap[id];
|
|
990
|
-
const
|
|
1162
|
+
},
|
|
1163
|
+
end(id, microsecond) {
|
|
1164
|
+
const time = R.idMap[id], name = R.nameMap[id];
|
|
1165
|
+
const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
|
|
991
1166
|
R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
else {
|
|
996
|
-
debug$f.log(name, Date.now() - time, 'ms');
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
static endOfName(name, microsecond) {
|
|
1167
|
+
debug$g.log(name, duration, 'ms');
|
|
1168
|
+
},
|
|
1169
|
+
endOfName(name, microsecond) {
|
|
1000
1170
|
const id = R.nameToIdMap[name];
|
|
1001
1171
|
if (id !== undefined)
|
|
1002
1172
|
R.end(id, microsecond);
|
|
1003
1173
|
}
|
|
1004
|
-
}
|
|
1005
|
-
Run.idMap = {};
|
|
1006
|
-
Run.nameMap = {};
|
|
1007
|
-
Run.nameToIdMap = {};
|
|
1174
|
+
};
|
|
1008
1175
|
const R = Run;
|
|
1009
1176
|
|
|
1010
|
-
const debug$
|
|
1177
|
+
const debug$f = Debug.get('UICreator');
|
|
1011
1178
|
const UICreator = {
|
|
1012
1179
|
list: {},
|
|
1013
1180
|
register(UI) {
|
|
1014
1181
|
const { __tag: tag } = UI.prototype;
|
|
1015
1182
|
if (list$2[tag]) {
|
|
1016
|
-
debug$
|
|
1183
|
+
debug$f.repeat(tag);
|
|
1017
1184
|
}
|
|
1018
1185
|
else {
|
|
1019
1186
|
list$2[tag] = UI;
|
|
@@ -1035,7 +1202,7 @@ const UICreator = {
|
|
|
1035
1202
|
};
|
|
1036
1203
|
const { list: list$2 } = UICreator;
|
|
1037
1204
|
|
|
1038
|
-
const debug$
|
|
1205
|
+
const debug$e = Debug.get('EventCreator');
|
|
1039
1206
|
const EventCreator = {
|
|
1040
1207
|
nameList: {},
|
|
1041
1208
|
register(Event) {
|
|
@@ -1043,7 +1210,7 @@ const EventCreator = {
|
|
|
1043
1210
|
Object.keys(Event).forEach(key => {
|
|
1044
1211
|
name = Event[key];
|
|
1045
1212
|
if (typeof name === 'string')
|
|
1046
|
-
nameList[name] ? debug$
|
|
1213
|
+
nameList[name] ? debug$e.repeat(name) : nameList[name] = Event;
|
|
1047
1214
|
});
|
|
1048
1215
|
},
|
|
1049
1216
|
changeName(oldName, newName) {
|
|
@@ -1117,7 +1284,7 @@ class LeafList {
|
|
|
1117
1284
|
constructor(item) {
|
|
1118
1285
|
this.reset();
|
|
1119
1286
|
if (item)
|
|
1120
|
-
item instanceof Array ? this.
|
|
1287
|
+
item instanceof Array ? this.addList(item) : this.add(item);
|
|
1121
1288
|
}
|
|
1122
1289
|
has(leaf) {
|
|
1123
1290
|
return leaf && this.keys[leaf.innerId] !== undefined;
|
|
@@ -1129,36 +1296,34 @@ class LeafList {
|
|
|
1129
1296
|
const index = this.keys[leaf.innerId];
|
|
1130
1297
|
return index === undefined ? -1 : index;
|
|
1131
1298
|
}
|
|
1132
|
-
|
|
1133
|
-
list.forEach(leaf => { this.push(leaf); });
|
|
1134
|
-
}
|
|
1135
|
-
unshift(leaf) {
|
|
1136
|
-
const { keys } = this;
|
|
1137
|
-
if (keys[leaf.innerId] === undefined) {
|
|
1138
|
-
this.list.unshift(leaf);
|
|
1139
|
-
Object.keys(keys).forEach(innerId => {
|
|
1140
|
-
if (keys[innerId] !== undefined)
|
|
1141
|
-
keys[innerId]++;
|
|
1142
|
-
});
|
|
1143
|
-
keys[leaf.innerId] = 0;
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
push(leaf) {
|
|
1299
|
+
add(leaf) {
|
|
1147
1300
|
const { list, keys } = this;
|
|
1148
1301
|
if (keys[leaf.innerId] === undefined) {
|
|
1149
1302
|
list.push(leaf);
|
|
1150
1303
|
keys[leaf.innerId] = list.length - 1;
|
|
1151
1304
|
}
|
|
1152
1305
|
}
|
|
1153
|
-
|
|
1154
|
-
const {
|
|
1155
|
-
if (
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1306
|
+
addAt(leaf, index = 0) {
|
|
1307
|
+
const { keys } = this;
|
|
1308
|
+
if (keys[leaf.innerId] === undefined) {
|
|
1309
|
+
const { list } = this;
|
|
1310
|
+
for (let i = index, len = list.length; i < len; i++)
|
|
1311
|
+
keys[list[i].innerId]++;
|
|
1312
|
+
if (index === 0) {
|
|
1313
|
+
list.unshift(leaf);
|
|
1314
|
+
}
|
|
1315
|
+
else {
|
|
1316
|
+
if (index > list.length)
|
|
1317
|
+
index = list.length;
|
|
1318
|
+
list.splice(index, 0, leaf);
|
|
1319
|
+
}
|
|
1320
|
+
keys[leaf.innerId] = index;
|
|
1160
1321
|
}
|
|
1161
1322
|
}
|
|
1323
|
+
addList(list) {
|
|
1324
|
+
for (let i = 0; i < list.length; i++)
|
|
1325
|
+
this.add(list[i]);
|
|
1326
|
+
}
|
|
1162
1327
|
remove(leaf) {
|
|
1163
1328
|
const { list } = this;
|
|
1164
1329
|
let findIndex;
|
|
@@ -1174,20 +1339,36 @@ class LeafList {
|
|
|
1174
1339
|
if (findIndex !== undefined)
|
|
1175
1340
|
list.splice(findIndex, 1);
|
|
1176
1341
|
}
|
|
1342
|
+
sort(reverse) {
|
|
1343
|
+
const { list } = this;
|
|
1344
|
+
if (reverse) {
|
|
1345
|
+
list.sort((a, b) => b.__level - a.__level);
|
|
1346
|
+
}
|
|
1347
|
+
else {
|
|
1348
|
+
list.sort((a, b) => a.__level - b.__level);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1177
1351
|
forEach(itemCallback) {
|
|
1178
1352
|
this.list.forEach(itemCallback);
|
|
1179
1353
|
}
|
|
1180
1354
|
clone() {
|
|
1181
1355
|
const list = new LeafList();
|
|
1182
|
-
|
|
1356
|
+
list.list = [...this.list];
|
|
1357
|
+
list.keys = Object.assign({}, this.keys);
|
|
1183
1358
|
return list;
|
|
1184
1359
|
}
|
|
1360
|
+
update() {
|
|
1361
|
+
this.keys = {};
|
|
1362
|
+
const { list, keys } = this;
|
|
1363
|
+
for (let i = 0, len = list.length; i < len; i++)
|
|
1364
|
+
keys[list[i].innerId] = i;
|
|
1365
|
+
}
|
|
1185
1366
|
reset() {
|
|
1186
1367
|
this.list = [];
|
|
1187
1368
|
this.keys = {};
|
|
1188
1369
|
}
|
|
1189
1370
|
destroy() {
|
|
1190
|
-
this.
|
|
1371
|
+
this.reset();
|
|
1191
1372
|
}
|
|
1192
1373
|
}
|
|
1193
1374
|
|
|
@@ -1197,7 +1378,7 @@ class LeafLevelList {
|
|
|
1197
1378
|
this._length = 0;
|
|
1198
1379
|
this.reset();
|
|
1199
1380
|
if (item)
|
|
1200
|
-
item instanceof Array ? this.
|
|
1381
|
+
item instanceof Array ? this.addList(item) : this.add(item);
|
|
1201
1382
|
}
|
|
1202
1383
|
has(leaf) {
|
|
1203
1384
|
return this.keys[leaf.innerId] !== undefined;
|
|
@@ -1214,10 +1395,10 @@ class LeafLevelList {
|
|
|
1214
1395
|
levels.sort((a, b) => a - b);
|
|
1215
1396
|
}
|
|
1216
1397
|
}
|
|
1217
|
-
|
|
1218
|
-
list.forEach(leaf => { this.
|
|
1398
|
+
addList(list) {
|
|
1399
|
+
list.forEach(leaf => { this.add(leaf); });
|
|
1219
1400
|
}
|
|
1220
|
-
|
|
1401
|
+
add(leaf) {
|
|
1221
1402
|
const { keys, levelMap } = this;
|
|
1222
1403
|
if (!keys[leaf.innerId]) {
|
|
1223
1404
|
keys[leaf.innerId] = 1;
|
|
@@ -1258,11 +1439,11 @@ class HitCanvasManager extends CanvasManager {
|
|
|
1258
1439
|
this.imageTypeList = new LeafList();
|
|
1259
1440
|
}
|
|
1260
1441
|
getImageType(leaf, size) {
|
|
1261
|
-
this.imageTypeList.
|
|
1442
|
+
this.imageTypeList.add(leaf);
|
|
1262
1443
|
return Creator.hitCanvas(size);
|
|
1263
1444
|
}
|
|
1264
1445
|
getPathType(leaf) {
|
|
1265
|
-
this.pathTypeList.
|
|
1446
|
+
this.pathTypeList.add(leaf);
|
|
1266
1447
|
return Creator.hitCanvas();
|
|
1267
1448
|
}
|
|
1268
1449
|
clearImageType() {
|
|
@@ -1332,6 +1513,17 @@ class LeafData {
|
|
|
1332
1513
|
}
|
|
1333
1514
|
return this[name];
|
|
1334
1515
|
}
|
|
1516
|
+
__getData() {
|
|
1517
|
+
const data = { tag: this.__leaf.tag }, { __input } = this;
|
|
1518
|
+
let inputValue;
|
|
1519
|
+
for (let key in this) {
|
|
1520
|
+
if (key[0] !== '_') {
|
|
1521
|
+
inputValue = __input ? __input[key] : undefined;
|
|
1522
|
+
data[key] = (inputValue === undefined) ? this[key] : inputValue;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
return data;
|
|
1526
|
+
}
|
|
1335
1527
|
__setInput(name, value) {
|
|
1336
1528
|
this.__input || (this.__input = {});
|
|
1337
1529
|
this.__input[name] = value;
|
|
@@ -1348,21 +1540,15 @@ class LeafData {
|
|
|
1348
1540
|
if (this.__input && this.__input[name] !== undefined)
|
|
1349
1541
|
this.__input[name] = undefined;
|
|
1350
1542
|
}
|
|
1351
|
-
__getInputData(
|
|
1543
|
+
__getInputData() {
|
|
1352
1544
|
const data = { tag: this.__leaf.tag }, { __input } = this;
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
let realKey, value;
|
|
1361
|
-
for (let key in this) {
|
|
1362
|
-
realKey = key.substring(1);
|
|
1363
|
-
if (this[realKey] !== undefined) {
|
|
1364
|
-
value = __input ? __input[realKey] : undefined;
|
|
1365
|
-
data[realKey] = value === undefined ? this[key] : value;
|
|
1545
|
+
let value, inputValue;
|
|
1546
|
+
for (let key in this) {
|
|
1547
|
+
if (key[0] !== '_') {
|
|
1548
|
+
value = this['_' + key];
|
|
1549
|
+
if (value !== undefined) {
|
|
1550
|
+
inputValue = __input ? __input[key] : undefined;
|
|
1551
|
+
data[key] = (inputValue === undefined) ? value : inputValue;
|
|
1366
1552
|
}
|
|
1367
1553
|
}
|
|
1368
1554
|
}
|
|
@@ -1453,11 +1639,10 @@ function contextAttr(realName) {
|
|
|
1453
1639
|
return (target, key) => {
|
|
1454
1640
|
if (!realName)
|
|
1455
1641
|
realName = key;
|
|
1456
|
-
|
|
1642
|
+
Object.defineProperty(target, key, {
|
|
1457
1643
|
get() { return this.context[realName]; },
|
|
1458
1644
|
set(value) { this.context[realName] = value; }
|
|
1459
|
-
};
|
|
1460
|
-
Object.defineProperty(target, key, property);
|
|
1645
|
+
});
|
|
1461
1646
|
};
|
|
1462
1647
|
}
|
|
1463
1648
|
const contextMethodNameList = [];
|
|
@@ -1735,7 +1920,7 @@ __decorate([
|
|
|
1735
1920
|
|
|
1736
1921
|
const temp = new Bounds();
|
|
1737
1922
|
const minSize = { width: 1, height: 1, pixelRatio: 1 };
|
|
1738
|
-
const debug$
|
|
1923
|
+
const debug$d = Debug.get('LeaferCanvasBase');
|
|
1739
1924
|
const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
|
|
1740
1925
|
class LeaferCanvasBase extends Canvas$1 {
|
|
1741
1926
|
get pixelWidth() { return this.width * this.pixelRatio; }
|
|
@@ -1768,7 +1953,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
1768
1953
|
canvas.recycle();
|
|
1769
1954
|
resolve(blob);
|
|
1770
1955
|
}).catch((e) => {
|
|
1771
|
-
debug$
|
|
1956
|
+
debug$d.error(e);
|
|
1772
1957
|
resolve(null);
|
|
1773
1958
|
});
|
|
1774
1959
|
});
|
|
@@ -1786,7 +1971,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
1786
1971
|
canvas.recycle();
|
|
1787
1972
|
resolve(true);
|
|
1788
1973
|
}).catch((e) => {
|
|
1789
|
-
debug$
|
|
1974
|
+
debug$d.error(e);
|
|
1790
1975
|
resolve(false);
|
|
1791
1976
|
});
|
|
1792
1977
|
});
|
|
@@ -1937,7 +2122,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
1937
2122
|
if (blendMode)
|
|
1938
2123
|
this.blendMode = blendMode;
|
|
1939
2124
|
this.fillStyle = color;
|
|
1940
|
-
temp.
|
|
2125
|
+
temp.set(bounds).scale(this.pixelRatio);
|
|
1941
2126
|
this.fillRect(temp.x, temp.y, temp.width, temp.height);
|
|
1942
2127
|
if (blendMode)
|
|
1943
2128
|
this.blendMode = 'source-over';
|
|
@@ -1946,20 +2131,20 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
1946
2131
|
if (blendMode)
|
|
1947
2132
|
this.blendMode = blendMode;
|
|
1948
2133
|
this.strokeStyle = color;
|
|
1949
|
-
temp.
|
|
2134
|
+
temp.set(bounds).scale(this.pixelRatio);
|
|
1950
2135
|
this.strokeRect(temp.x, temp.y, temp.width, temp.height);
|
|
1951
2136
|
if (blendMode)
|
|
1952
2137
|
this.blendMode = 'source-over';
|
|
1953
2138
|
}
|
|
1954
2139
|
clearWorld(bounds, ceilPixel) {
|
|
1955
|
-
temp.
|
|
2140
|
+
temp.set(bounds).scale(this.pixelRatio);
|
|
1956
2141
|
if (ceilPixel)
|
|
1957
2142
|
temp.ceil();
|
|
1958
2143
|
this.clearRect(temp.x, temp.y, temp.width, temp.height);
|
|
1959
2144
|
}
|
|
1960
2145
|
clipWorld(bounds, ceilPixel) {
|
|
1961
2146
|
this.beginPath();
|
|
1962
|
-
temp.
|
|
2147
|
+
temp.set(bounds).scale(this.pixelRatio);
|
|
1963
2148
|
if (ceilPixel)
|
|
1964
2149
|
temp.ceil();
|
|
1965
2150
|
this.rect(temp.x, temp.y, temp.width, temp.height);
|
|
@@ -1972,13 +2157,15 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
1972
2157
|
isSameSize(size) {
|
|
1973
2158
|
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
1974
2159
|
}
|
|
1975
|
-
getSameCanvas(useSameWorldTransform) {
|
|
2160
|
+
getSameCanvas(useSameWorldTransform, useSameSmooth) {
|
|
1976
2161
|
const { width, height, pixelRatio } = this;
|
|
1977
2162
|
const options = { width, height, pixelRatio };
|
|
1978
2163
|
const canvas = this.manager ? this.manager.get(options) : Creator.canvas(options);
|
|
1979
2164
|
canvas.save();
|
|
1980
2165
|
if (useSameWorldTransform)
|
|
1981
2166
|
canvas.useWorldTransform(Object.assign({}, this.worldTransform));
|
|
2167
|
+
if (useSameSmooth)
|
|
2168
|
+
canvas.smooth = this.smooth;
|
|
1982
2169
|
return canvas;
|
|
1983
2170
|
}
|
|
1984
2171
|
getBiggerCanvas(addWidth, addHeight) {
|
|
@@ -2069,44 +2256,37 @@ const NeedConvertToCanvasCommandMap = {
|
|
|
2069
2256
|
a: 90,
|
|
2070
2257
|
};
|
|
2071
2258
|
const NeedConvertToCurveCommandMap = Object.assign(Object.assign({}, NeedConvertToCanvasCommandMap), CanvasCommandOnlyMap);
|
|
2072
|
-
const P$
|
|
2259
|
+
const P$5 = PathCommandMap;
|
|
2073
2260
|
const PathNumberCommandMap = {};
|
|
2074
|
-
for (let key in P$
|
|
2075
|
-
PathNumberCommandMap[P$
|
|
2261
|
+
for (let key in P$5) {
|
|
2262
|
+
PathNumberCommandMap[P$5[key]] = key;
|
|
2076
2263
|
}
|
|
2077
2264
|
const PathNumberCommandLengthMap = {};
|
|
2078
|
-
for (let key in P$
|
|
2079
|
-
PathNumberCommandLengthMap[P$
|
|
2265
|
+
for (let key in P$5) {
|
|
2266
|
+
PathNumberCommandLengthMap[P$5[key]] = PathCommandLengthMap[key];
|
|
2080
2267
|
}
|
|
2081
2268
|
|
|
2082
2269
|
const RectHelper = {
|
|
2083
2270
|
drawRoundRect(drawer, x, y, width, height, cornerRadius) {
|
|
2084
|
-
|
|
2085
|
-
const
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
if (bottomLeft > max)
|
|
2093
|
-
bottomLeft = max;
|
|
2094
|
-
topLeft ? drawer.moveTo(x + topLeft, y) : drawer.moveTo(x, y);
|
|
2095
|
-
topRight ? drawer.arcTo(x + width, y, x + width, y + height, topRight) : drawer.lineTo(x + width, y);
|
|
2096
|
-
bottomRight ? drawer.arcTo(x + width, y + height, x, y + height, bottomRight) : drawer.lineTo(x + width, y + height);
|
|
2097
|
-
bottomLeft ? drawer.arcTo(x, y + height, x, y, bottomLeft) : drawer.lineTo(x, y + height);
|
|
2098
|
-
topLeft ? drawer.arcTo(x, y, x + width, y, topLeft) : drawer.lineTo(x, y);
|
|
2271
|
+
const data = MathHelper.fourNumber(cornerRadius, Math.min(width / 2, height / 2));
|
|
2272
|
+
const right = x + width;
|
|
2273
|
+
const bottom = y + height;
|
|
2274
|
+
data[0] ? drawer.moveTo(x + data[0], y) : drawer.moveTo(x, y);
|
|
2275
|
+
data[1] ? drawer.arcTo(right, y, right, bottom, data[1]) : drawer.lineTo(right, y);
|
|
2276
|
+
data[2] ? drawer.arcTo(right, bottom, x, bottom, data[2]) : drawer.lineTo(right, bottom);
|
|
2277
|
+
data[3] ? drawer.arcTo(x, bottom, x, y, data[3]) : drawer.lineTo(x, bottom);
|
|
2278
|
+
data[0] ? drawer.arcTo(x, y, right, y, data[0]) : drawer.lineTo(x, y);
|
|
2099
2279
|
}
|
|
2100
2280
|
};
|
|
2101
2281
|
|
|
2102
|
-
const { sin: sin$
|
|
2282
|
+
const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow } = Math;
|
|
2103
2283
|
const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
|
|
2104
2284
|
const { set: set$2 } = PointHelper;
|
|
2105
|
-
const { M: M$
|
|
2106
|
-
const tempPoint = {};
|
|
2285
|
+
const { M: M$6, L: L$7, C: C$6, Q: Q$5, Z: Z$6 } = PathCommandMap;
|
|
2286
|
+
const tempPoint$1 = {};
|
|
2107
2287
|
const BezierHelper = {
|
|
2108
2288
|
points(data, points, curve, close) {
|
|
2109
|
-
data.push(M$
|
|
2289
|
+
data.push(M$6, points[0], points[1]);
|
|
2110
2290
|
if (curve && points.length > 5) {
|
|
2111
2291
|
let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
|
|
2112
2292
|
let ba, cb, d, len = points.length;
|
|
@@ -2133,24 +2313,24 @@ const BezierHelper = {
|
|
|
2133
2313
|
c1Y = bY - ba * cY;
|
|
2134
2314
|
if (i === 2) {
|
|
2135
2315
|
if (!close)
|
|
2136
|
-
data.push(Q$
|
|
2316
|
+
data.push(Q$5, c1X, c1Y, bX, bY);
|
|
2137
2317
|
}
|
|
2138
2318
|
else {
|
|
2139
|
-
data.push(C$
|
|
2319
|
+
data.push(C$6, c2X, c2Y, c1X, c1Y, bX, bY);
|
|
2140
2320
|
}
|
|
2141
2321
|
c2X = bX + cb * cX;
|
|
2142
2322
|
c2Y = bY + cb * cY;
|
|
2143
2323
|
}
|
|
2144
2324
|
if (!close)
|
|
2145
|
-
data.push(Q$
|
|
2325
|
+
data.push(Q$5, c2X, c2Y, points[len - 2], points[len - 1]);
|
|
2146
2326
|
}
|
|
2147
2327
|
else {
|
|
2148
2328
|
for (let i = 2, len = points.length; i < len; i += 2) {
|
|
2149
|
-
data.push(L$
|
|
2329
|
+
data.push(L$7, points[i], points[i + 1]);
|
|
2150
2330
|
}
|
|
2151
2331
|
}
|
|
2152
2332
|
if (close)
|
|
2153
|
-
data.push(Z$
|
|
2333
|
+
data.push(Z$6);
|
|
2154
2334
|
},
|
|
2155
2335
|
rect(data, x, y, width, height) {
|
|
2156
2336
|
PathHelper.creator.path = data;
|
|
@@ -2171,9 +2351,9 @@ const BezierHelper = {
|
|
|
2171
2351
|
let totalRadian = endRadian - startRadian;
|
|
2172
2352
|
if (totalRadian < 0)
|
|
2173
2353
|
totalRadian += PI2;
|
|
2174
|
-
if (totalRadian === PI$2 || (abs(BAx + BAy) < 1.e-12) || (abs(CBx + CBy) < 1.e-12)) {
|
|
2354
|
+
if (totalRadian === PI$2 || (abs$2(BAx + BAy) < 1.e-12) || (abs$2(CBx + CBy) < 1.e-12)) {
|
|
2175
2355
|
if (data)
|
|
2176
|
-
data.push(L$
|
|
2356
|
+
data.push(L$7, x1, y1);
|
|
2177
2357
|
if (setPointBounds) {
|
|
2178
2358
|
setPoint$1(setPointBounds, fromX, fromY);
|
|
2179
2359
|
addPoint$1(setPointBounds, x1, y1);
|
|
@@ -2186,9 +2366,9 @@ const BezierHelper = {
|
|
|
2186
2366
|
}
|
|
2187
2367
|
const anticlockwise = BAx * CBy - CBx * BAy < 0;
|
|
2188
2368
|
const sign = anticlockwise ? -1 : 1;
|
|
2189
|
-
const c = radius / cos$
|
|
2190
|
-
const centerX = x1 + c * cos$
|
|
2191
|
-
const centerY = y1 + c * sin$
|
|
2369
|
+
const c = radius / cos$3(totalRadian / 2);
|
|
2370
|
+
const centerX = x1 + c * cos$3(startRadian + totalRadian / 2 + PI_2 * sign);
|
|
2371
|
+
const centerY = y1 + c * sin$3(startRadian + totalRadian / 2 + PI_2 * sign);
|
|
2192
2372
|
startRadian -= PI_2 * sign;
|
|
2193
2373
|
endRadian -= PI_2 * sign;
|
|
2194
2374
|
return ellipse$6(data, centerX, centerY, radius, radius, 0, startRadian / OneRadian, endRadian / OneRadian, anticlockwise, setPointBounds, setEndPoint, setStartPoint);
|
|
@@ -2198,8 +2378,8 @@ const BezierHelper = {
|
|
|
2198
2378
|
},
|
|
2199
2379
|
ellipse(data, cx, cy, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise, setPointBounds, setEndPoint, setStartPoint) {
|
|
2200
2380
|
const rotationRadian = rotation * OneRadian;
|
|
2201
|
-
const rotationSin = sin$
|
|
2202
|
-
const rotationCos = cos$
|
|
2381
|
+
const rotationSin = sin$3(rotationRadian);
|
|
2382
|
+
const rotationCos = cos$3(rotationRadian);
|
|
2203
2383
|
let startRadian = startAngle * OneRadian;
|
|
2204
2384
|
let endRadian = endAngle * OneRadian;
|
|
2205
2385
|
if (startRadian > PI$2)
|
|
@@ -2213,27 +2393,27 @@ const BezierHelper = {
|
|
|
2213
2393
|
totalRadian -= PI2;
|
|
2214
2394
|
if (anticlockwise)
|
|
2215
2395
|
totalRadian -= PI2;
|
|
2216
|
-
const parts = ceil(abs(totalRadian / PI_2));
|
|
2396
|
+
const parts = ceil(abs$2(totalRadian / PI_2));
|
|
2217
2397
|
const partRadian = totalRadian / parts;
|
|
2218
|
-
const partRadian4Sin = sin$
|
|
2219
|
-
const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$
|
|
2398
|
+
const partRadian4Sin = sin$3(partRadian / 4);
|
|
2399
|
+
const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
|
|
2220
2400
|
endRadian = startRadian + partRadian;
|
|
2221
|
-
let startCos = cos$
|
|
2222
|
-
let startSin = sin$
|
|
2401
|
+
let startCos = cos$3(startRadian);
|
|
2402
|
+
let startSin = sin$3(startRadian);
|
|
2223
2403
|
let endCos, endSin;
|
|
2224
2404
|
let x, y, x1, y1, x2, y2;
|
|
2225
2405
|
let startX = x = rotationCos * radiusX * startCos - rotationSin * radiusY * startSin;
|
|
2226
2406
|
let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
|
|
2227
2407
|
let fromX = cx + x, fromY = cy + y;
|
|
2228
2408
|
if (data)
|
|
2229
|
-
data.push(L$
|
|
2409
|
+
data.push(L$7, fromX, fromY);
|
|
2230
2410
|
if (setPointBounds)
|
|
2231
2411
|
setPoint$1(setPointBounds, fromX, fromY);
|
|
2232
2412
|
if (setStartPoint)
|
|
2233
2413
|
set$2(setStartPoint, fromX, fromY);
|
|
2234
2414
|
for (let i = 0; i < parts; i++) {
|
|
2235
|
-
endCos = cos$
|
|
2236
|
-
endSin = sin$
|
|
2415
|
+
endCos = cos$3(endRadian);
|
|
2416
|
+
endSin = sin$3(endRadian);
|
|
2237
2417
|
x = rotationCos * radiusX * endCos - rotationSin * radiusY * endSin;
|
|
2238
2418
|
y = rotationSin * radiusX * endCos + rotationCos * radiusY * endSin;
|
|
2239
2419
|
x1 = cx + startX - control * (rotationCos * radiusX * startSin + rotationSin * radiusY * startCos);
|
|
@@ -2241,7 +2421,7 @@ const BezierHelper = {
|
|
|
2241
2421
|
x2 = cx + x + control * (rotationCos * radiusX * endSin + rotationSin * radiusY * endCos);
|
|
2242
2422
|
y2 = cy + y + control * (rotationSin * radiusX * endSin - rotationCos * radiusY * endCos);
|
|
2243
2423
|
if (data)
|
|
2244
|
-
data.push(C$
|
|
2424
|
+
data.push(C$6, x1, y1, x2, y2, cx + x, cy + y);
|
|
2245
2425
|
if (setPointBounds)
|
|
2246
2426
|
toTwoPointBounds$1(cx + startX, cy + startY, x1, y1, x2, y2, cx + x, cy + y, setPointBounds, true);
|
|
2247
2427
|
startX = x;
|
|
@@ -2255,7 +2435,7 @@ const BezierHelper = {
|
|
|
2255
2435
|
set$2(setEndPoint, cx + x, cy + y);
|
|
2256
2436
|
},
|
|
2257
2437
|
quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
|
|
2258
|
-
data.push(C$
|
|
2438
|
+
data.push(C$6, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
|
|
2259
2439
|
},
|
|
2260
2440
|
toTwoPointBoundsByQuadraticCurve(fromX, fromY, x1, y1, toX, toY, pointBounds, addMode) {
|
|
2261
2441
|
toTwoPointBounds$1(fromX, fromY, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY, pointBounds, addMode);
|
|
@@ -2293,8 +2473,8 @@ const BezierHelper = {
|
|
|
2293
2473
|
addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
|
|
2294
2474
|
addPoint$1(pointBounds, toX, toY);
|
|
2295
2475
|
for (let i = 0, len = tList.length; i < len; i++) {
|
|
2296
|
-
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint);
|
|
2297
|
-
addPoint$1(pointBounds, tempPoint.x, tempPoint.y);
|
|
2476
|
+
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
|
|
2477
|
+
addPoint$1(pointBounds, tempPoint$1.x, tempPoint$1.y);
|
|
2298
2478
|
}
|
|
2299
2479
|
},
|
|
2300
2480
|
getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
|
|
@@ -2310,15 +2490,15 @@ const BezierHelper = {
|
|
|
2310
2490
|
};
|
|
2311
2491
|
const { getPointAndSet, toTwoPointBounds: toTwoPointBounds$1, ellipse: ellipse$6 } = BezierHelper;
|
|
2312
2492
|
|
|
2313
|
-
const { sin: sin$
|
|
2493
|
+
const { sin: sin$2, cos: cos$2, sqrt, atan2 } = Math;
|
|
2314
2494
|
const { ellipse: ellipse$5 } = BezierHelper;
|
|
2315
2495
|
const EllipseHelper = {
|
|
2316
2496
|
ellipticalArc(data, fromX, fromY, radiusX, radiusY, rotation, largeFlag, sweepFlag, toX, toY, curveMode) {
|
|
2317
2497
|
const halfX = (toX - fromX) / 2;
|
|
2318
2498
|
const halfY = (toY - fromY) / 2;
|
|
2319
2499
|
const rotationRadian = rotation * OneRadian;
|
|
2320
|
-
const rotationSin = sin$
|
|
2321
|
-
const rotationCos = cos$
|
|
2500
|
+
const rotationSin = sin$2(rotationRadian);
|
|
2501
|
+
const rotationCos = cos$2(rotationRadian);
|
|
2322
2502
|
const px = -rotationCos * halfX - rotationSin * halfY;
|
|
2323
2503
|
const py = -rotationCos * halfY + rotationSin * halfX;
|
|
2324
2504
|
const rxSquare = radiusX * radiusX;
|
|
@@ -2363,10 +2543,10 @@ const EllipseHelper = {
|
|
|
2363
2543
|
}
|
|
2364
2544
|
};
|
|
2365
2545
|
|
|
2366
|
-
const { M: M$
|
|
2367
|
-
const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$
|
|
2546
|
+
const { M: M$5, m, L: L$6, l, H, h, V, v, C: C$5, c, S, s, Q: Q$4, q, T, t, A, a, Z: Z$5, z, N: N$4, D: D$4, X: X$4, G: G$4, F: F$4, O: O$4, P: P$4, U: U$4 } = PathCommandMap;
|
|
2547
|
+
const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2368
2548
|
const { ellipticalArc } = EllipseHelper;
|
|
2369
|
-
const debug$
|
|
2549
|
+
const debug$c = Debug.get('PathConvert');
|
|
2370
2550
|
const setEndPoint$1 = {};
|
|
2371
2551
|
const PathConvert = {
|
|
2372
2552
|
current: { dot: 0 },
|
|
@@ -2451,33 +2631,33 @@ const PathConvert = {
|
|
|
2451
2631
|
case m:
|
|
2452
2632
|
old[i + 1] += x;
|
|
2453
2633
|
old[i + 2] += y;
|
|
2454
|
-
case M$
|
|
2634
|
+
case M$5:
|
|
2455
2635
|
x = old[i + 1];
|
|
2456
2636
|
y = old[i + 2];
|
|
2457
|
-
data.push(M$
|
|
2637
|
+
data.push(M$5, x, y);
|
|
2458
2638
|
i += 3;
|
|
2459
2639
|
break;
|
|
2460
2640
|
case h:
|
|
2461
2641
|
old[i + 1] += x;
|
|
2462
2642
|
case H:
|
|
2463
2643
|
x = old[i + 1];
|
|
2464
|
-
data.push(L$
|
|
2644
|
+
data.push(L$6, x, y);
|
|
2465
2645
|
i += 2;
|
|
2466
2646
|
break;
|
|
2467
2647
|
case v:
|
|
2468
2648
|
old[i + 1] += y;
|
|
2469
2649
|
case V:
|
|
2470
2650
|
y = old[i + 1];
|
|
2471
|
-
data.push(L$
|
|
2651
|
+
data.push(L$6, x, y);
|
|
2472
2652
|
i += 2;
|
|
2473
2653
|
break;
|
|
2474
2654
|
case l:
|
|
2475
2655
|
old[i + 1] += x;
|
|
2476
2656
|
old[i + 2] += y;
|
|
2477
|
-
case L$
|
|
2657
|
+
case L$6:
|
|
2478
2658
|
x = old[i + 1];
|
|
2479
2659
|
y = old[i + 2];
|
|
2480
|
-
data.push(L$
|
|
2660
|
+
data.push(L$6, x, y);
|
|
2481
2661
|
i += 3;
|
|
2482
2662
|
break;
|
|
2483
2663
|
case s:
|
|
@@ -2487,14 +2667,14 @@ const PathConvert = {
|
|
|
2487
2667
|
old[i + 4] += y;
|
|
2488
2668
|
command = S;
|
|
2489
2669
|
case S:
|
|
2490
|
-
smooth = (lastCommand === C$
|
|
2670
|
+
smooth = (lastCommand === C$5) || (lastCommand === S);
|
|
2491
2671
|
x1 = smooth ? (x * 2 - controlX) : old[i + 1];
|
|
2492
2672
|
y1 = smooth ? (y * 2 - controlY) : old[i + 2];
|
|
2493
2673
|
controlX = old[i + 1];
|
|
2494
2674
|
controlY = old[i + 2];
|
|
2495
2675
|
x = old[i + 3];
|
|
2496
2676
|
y = old[i + 4];
|
|
2497
|
-
data.push(C$
|
|
2677
|
+
data.push(C$5, x1, y1, controlX, controlY, x, y);
|
|
2498
2678
|
i += 5;
|
|
2499
2679
|
break;
|
|
2500
2680
|
case c:
|
|
@@ -2504,13 +2684,13 @@ const PathConvert = {
|
|
|
2504
2684
|
old[i + 4] += y;
|
|
2505
2685
|
old[i + 5] += x;
|
|
2506
2686
|
old[i + 6] += y;
|
|
2507
|
-
command = C$
|
|
2508
|
-
case C$
|
|
2687
|
+
command = C$5;
|
|
2688
|
+
case C$5:
|
|
2509
2689
|
controlX = old[i + 3];
|
|
2510
2690
|
controlY = old[i + 4];
|
|
2511
2691
|
x = old[i + 5];
|
|
2512
2692
|
y = old[i + 6];
|
|
2513
|
-
data.push(C$
|
|
2693
|
+
data.push(C$5, old[i + 1], old[i + 2], controlX, controlY, x, y);
|
|
2514
2694
|
i += 7;
|
|
2515
2695
|
break;
|
|
2516
2696
|
case t:
|
|
@@ -2518,10 +2698,10 @@ const PathConvert = {
|
|
|
2518
2698
|
old[i + 2] += y;
|
|
2519
2699
|
command = T;
|
|
2520
2700
|
case T:
|
|
2521
|
-
smooth = (lastCommand === Q$
|
|
2701
|
+
smooth = (lastCommand === Q$4) || (lastCommand === T);
|
|
2522
2702
|
controlX = smooth ? (x * 2 - controlX) : old[i + 1];
|
|
2523
2703
|
controlY = smooth ? (y * 2 - controlY) : old[i + 2];
|
|
2524
|
-
curveMode ? quadraticCurveTo$1(data, x, y, controlX, controlY, old[i + 1], old[i + 2]) : data.push(Q$
|
|
2704
|
+
curveMode ? quadraticCurveTo$1(data, x, y, controlX, controlY, old[i + 1], old[i + 2]) : data.push(Q$4, controlX, controlY, old[i + 1], old[i + 2]);
|
|
2525
2705
|
x = old[i + 1];
|
|
2526
2706
|
y = old[i + 2];
|
|
2527
2707
|
i += 3;
|
|
@@ -2531,11 +2711,11 @@ const PathConvert = {
|
|
|
2531
2711
|
old[i + 2] += y;
|
|
2532
2712
|
old[i + 3] += x;
|
|
2533
2713
|
old[i + 4] += y;
|
|
2534
|
-
command = Q$
|
|
2535
|
-
case Q$
|
|
2714
|
+
command = Q$4;
|
|
2715
|
+
case Q$4:
|
|
2536
2716
|
controlX = old[i + 1];
|
|
2537
2717
|
controlY = old[i + 2];
|
|
2538
|
-
curveMode ? quadraticCurveTo$1(data, x, y, controlX, controlY, old[i + 3], old[i + 4]) : data.push(Q$
|
|
2718
|
+
curveMode ? quadraticCurveTo$1(data, x, y, controlX, controlY, old[i + 3], old[i + 4]) : data.push(Q$4, controlX, controlY, old[i + 3], old[i + 4]);
|
|
2539
2719
|
x = old[i + 3];
|
|
2540
2720
|
y = old[i + 4];
|
|
2541
2721
|
i += 5;
|
|
@@ -2550,60 +2730,60 @@ const PathConvert = {
|
|
|
2550
2730
|
i += 8;
|
|
2551
2731
|
break;
|
|
2552
2732
|
case z:
|
|
2553
|
-
case Z$
|
|
2554
|
-
data.push(Z$
|
|
2733
|
+
case Z$5:
|
|
2734
|
+
data.push(Z$5);
|
|
2555
2735
|
i++;
|
|
2556
2736
|
break;
|
|
2557
|
-
case N$
|
|
2737
|
+
case N$4:
|
|
2558
2738
|
x = old[i + 1];
|
|
2559
2739
|
y = old[i + 2];
|
|
2560
2740
|
curveMode ? rect$2(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
|
|
2561
2741
|
i += 5;
|
|
2562
2742
|
break;
|
|
2563
|
-
case D$
|
|
2743
|
+
case D$4:
|
|
2564
2744
|
x = old[i + 1];
|
|
2565
2745
|
y = old[i + 2];
|
|
2566
2746
|
curveMode ? roundRect$2(data, x, y, old[i + 3], old[i + 4], [old[i + 5], old[i + 6], old[i + 7], old[i + 8]]) : copyData(data, old, i, 9);
|
|
2567
2747
|
i += 9;
|
|
2568
2748
|
break;
|
|
2569
|
-
case X$
|
|
2749
|
+
case X$4:
|
|
2570
2750
|
x = old[i + 1];
|
|
2571
2751
|
y = old[i + 2];
|
|
2572
2752
|
curveMode ? roundRect$2(data, x, y, old[i + 3], old[i + 4], old[i + 5]) : copyData(data, old, i, 6);
|
|
2573
2753
|
i += 6;
|
|
2574
2754
|
break;
|
|
2575
|
-
case G$
|
|
2755
|
+
case G$4:
|
|
2576
2756
|
ellipse$4(curveMode ? data : copyData(data, old, i, 9), old[i + 1], old[i + 2], old[i + 3], old[i + 4], old[i + 5], old[i + 6], old[i + 7], old[i + 8], null, setEndPoint$1);
|
|
2577
2757
|
x = setEndPoint$1.x;
|
|
2578
2758
|
y = setEndPoint$1.y;
|
|
2579
2759
|
i += 9;
|
|
2580
2760
|
break;
|
|
2581
|
-
case F$
|
|
2761
|
+
case F$4:
|
|
2582
2762
|
curveMode ? ellipse$4(data, old[i + 1], old[i + 2], old[i + 3], old[i + 4], 0, 0, 360, false) : copyData(data, old, i, 5);
|
|
2583
2763
|
x = old[i + 1] + old[i + 3];
|
|
2584
2764
|
y = old[i + 2];
|
|
2585
2765
|
i += 5;
|
|
2586
2766
|
break;
|
|
2587
|
-
case O$
|
|
2767
|
+
case O$4:
|
|
2588
2768
|
arc$3(curveMode ? data : copyData(data, old, i, 7), old[i + 1], old[i + 2], old[i + 3], old[i + 4], old[i + 5], old[i + 6], null, setEndPoint$1);
|
|
2589
2769
|
x = setEndPoint$1.x;
|
|
2590
2770
|
y = setEndPoint$1.y;
|
|
2591
2771
|
i += 7;
|
|
2592
2772
|
break;
|
|
2593
|
-
case P$
|
|
2773
|
+
case P$4:
|
|
2594
2774
|
curveMode ? arc$3(data, old[i + 1], old[i + 2], old[i + 3], 0, 360, false) : copyData(data, old, i, 4);
|
|
2595
2775
|
x = old[i + 1] + old[i + 3];
|
|
2596
2776
|
y = old[i + 2];
|
|
2597
2777
|
i += 4;
|
|
2598
2778
|
break;
|
|
2599
2779
|
case U$4:
|
|
2600
|
-
arcTo$
|
|
2780
|
+
arcTo$3(curveMode ? data : copyData(data, old, i, 6), x, y, old[i + 1], old[i + 2], old[i + 3], old[i + 4], old[i + 5], null, setEndPoint$1);
|
|
2601
2781
|
x = setEndPoint$1.x;
|
|
2602
2782
|
y = setEndPoint$1.y;
|
|
2603
2783
|
i += 6;
|
|
2604
2784
|
break;
|
|
2605
2785
|
default:
|
|
2606
|
-
debug$
|
|
2786
|
+
debug$c.error(`command: ${command} [index:${i}]`, old);
|
|
2607
2787
|
return data;
|
|
2608
2788
|
}
|
|
2609
2789
|
lastCommand = command;
|
|
@@ -2627,68 +2807,76 @@ const PathConvert = {
|
|
|
2627
2807
|
};
|
|
2628
2808
|
const { current, pushData, copyData } = PathConvert;
|
|
2629
2809
|
|
|
2630
|
-
const { M: M$
|
|
2810
|
+
const { M: M$4, L: L$5, C: C$4, Q: Q$3, Z: Z$4, N: N$3, D: D$3, X: X$3, G: G$3, F: F$3, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
|
|
2811
|
+
const { getMinDistanceFrom, getRadianFrom } = PointHelper;
|
|
2812
|
+
const { tan, min, abs: abs$1 } = Math;
|
|
2631
2813
|
const startPoint = {};
|
|
2632
2814
|
const PathCommandDataHelper = {
|
|
2633
2815
|
beginPath(data) {
|
|
2634
2816
|
data.length = 0;
|
|
2635
2817
|
},
|
|
2636
2818
|
moveTo(data, x, y) {
|
|
2637
|
-
data.push(M$
|
|
2819
|
+
data.push(M$4, x, y);
|
|
2638
2820
|
},
|
|
2639
2821
|
lineTo(data, x, y) {
|
|
2640
|
-
data.push(L$
|
|
2822
|
+
data.push(L$5, x, y);
|
|
2641
2823
|
},
|
|
2642
2824
|
bezierCurveTo(data, x1, y1, x2, y2, x, y) {
|
|
2643
|
-
data.push(C$
|
|
2825
|
+
data.push(C$4, x1, y1, x2, y2, x, y);
|
|
2644
2826
|
},
|
|
2645
2827
|
quadraticCurveTo(data, x1, y1, x, y) {
|
|
2646
|
-
data.push(Q$
|
|
2828
|
+
data.push(Q$3, x1, y1, x, y);
|
|
2647
2829
|
},
|
|
2648
2830
|
closePath(data) {
|
|
2649
|
-
data.push(Z$
|
|
2831
|
+
data.push(Z$4);
|
|
2650
2832
|
},
|
|
2651
2833
|
rect(data, x, y, width, height) {
|
|
2652
|
-
data.push(N$
|
|
2834
|
+
data.push(N$3, x, y, width, height);
|
|
2653
2835
|
},
|
|
2654
2836
|
roundRect(data, x, y, width, height, cornerRadius) {
|
|
2655
2837
|
if (typeof cornerRadius === 'number') {
|
|
2656
|
-
data.push(X$
|
|
2838
|
+
data.push(X$3, x, y, width, height, cornerRadius);
|
|
2657
2839
|
}
|
|
2658
2840
|
else {
|
|
2659
2841
|
const fourCorners = MathHelper.fourNumber(cornerRadius);
|
|
2660
2842
|
if (fourCorners) {
|
|
2661
|
-
data.push(D$
|
|
2843
|
+
data.push(D$3, x, y, width, height, ...fourCorners);
|
|
2662
2844
|
}
|
|
2663
2845
|
else {
|
|
2664
|
-
data.push(N$
|
|
2846
|
+
data.push(N$3, x, y, width, height);
|
|
2665
2847
|
}
|
|
2666
2848
|
}
|
|
2667
2849
|
},
|
|
2668
2850
|
ellipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2669
2851
|
if (rotation === undefined) {
|
|
2670
|
-
data.push(F$
|
|
2852
|
+
data.push(F$3, x, y, radiusX, radiusY);
|
|
2671
2853
|
}
|
|
2672
2854
|
else {
|
|
2673
2855
|
if (startAngle === undefined)
|
|
2674
2856
|
startAngle = 0;
|
|
2675
2857
|
if (endAngle === undefined)
|
|
2676
2858
|
endAngle = 360;
|
|
2677
|
-
data.push(G$
|
|
2859
|
+
data.push(G$3, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise ? 1 : 0);
|
|
2678
2860
|
}
|
|
2679
2861
|
},
|
|
2680
2862
|
arc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2681
2863
|
if (startAngle === undefined) {
|
|
2682
|
-
data.push(P$
|
|
2864
|
+
data.push(P$3, x, y, radius);
|
|
2683
2865
|
}
|
|
2684
2866
|
else {
|
|
2685
2867
|
if (endAngle === undefined)
|
|
2686
2868
|
endAngle = 360;
|
|
2687
|
-
data.push(O$
|
|
2869
|
+
data.push(O$3, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
|
|
2688
2870
|
}
|
|
2689
2871
|
},
|
|
2690
|
-
arcTo(data, x1, y1, x2, y2, radius) {
|
|
2691
|
-
|
|
2872
|
+
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
|
|
2873
|
+
if (lastX !== undefined) {
|
|
2874
|
+
const maxRadius = tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2) * (getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / 2);
|
|
2875
|
+
data.push(U$3, x1, y1, x2, y2, min(radius, abs$1(maxRadius)));
|
|
2876
|
+
}
|
|
2877
|
+
else {
|
|
2878
|
+
data.push(U$3, x1, y1, x2, y2, radius);
|
|
2879
|
+
}
|
|
2692
2880
|
},
|
|
2693
2881
|
drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2694
2882
|
if (rotation === undefined)
|
|
@@ -2698,7 +2886,7 @@ const PathCommandDataHelper = {
|
|
|
2698
2886
|
if (endAngle === undefined)
|
|
2699
2887
|
endAngle = 360;
|
|
2700
2888
|
BezierHelper.ellipse(null, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise, null, null, startPoint);
|
|
2701
|
-
data.push(M$
|
|
2889
|
+
data.push(M$4, startPoint.x, startPoint.y);
|
|
2702
2890
|
ellipse$3(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2703
2891
|
},
|
|
2704
2892
|
drawArc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
@@ -2707,7 +2895,7 @@ const PathCommandDataHelper = {
|
|
|
2707
2895
|
if (endAngle === undefined)
|
|
2708
2896
|
endAngle = 360;
|
|
2709
2897
|
BezierHelper.arc(null, x, y, radius, startAngle, endAngle, anticlockwise, null, null, startPoint);
|
|
2710
|
-
data.push(M$
|
|
2898
|
+
data.push(M$4, startPoint.x, startPoint.y);
|
|
2711
2899
|
arc$2(data, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2712
2900
|
},
|
|
2713
2901
|
drawPoints(data, points, curve, close) {
|
|
@@ -2716,7 +2904,7 @@ const PathCommandDataHelper = {
|
|
|
2716
2904
|
};
|
|
2717
2905
|
const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
|
|
2718
2906
|
|
|
2719
|
-
const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$1, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$
|
|
2907
|
+
const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$1, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
|
|
2720
2908
|
class PathCreator {
|
|
2721
2909
|
constructor(path) {
|
|
2722
2910
|
if (path) {
|
|
@@ -2767,7 +2955,7 @@ class PathCreator {
|
|
|
2767
2955
|
return this;
|
|
2768
2956
|
}
|
|
2769
2957
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2770
|
-
arcTo$
|
|
2958
|
+
arcTo$2(this.path, x1, y1, x2, y2, radius);
|
|
2771
2959
|
return this;
|
|
2772
2960
|
}
|
|
2773
2961
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
@@ -2784,8 +2972,8 @@ class PathCreator {
|
|
|
2784
2972
|
}
|
|
2785
2973
|
}
|
|
2786
2974
|
|
|
2787
|
-
const { M: M$
|
|
2788
|
-
const debug$
|
|
2975
|
+
const { M: M$3, L: L$4, C: C$3, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$2, O: O$2, P: P$2, U: U$2 } = PathCommandMap;
|
|
2976
|
+
const debug$b = Debug.get('PathDrawer');
|
|
2789
2977
|
const PathDrawer = {
|
|
2790
2978
|
drawPathByData(drawer, data) {
|
|
2791
2979
|
if (!data)
|
|
@@ -2795,51 +2983,51 @@ const PathDrawer = {
|
|
|
2795
2983
|
while (i < len) {
|
|
2796
2984
|
command = data[i];
|
|
2797
2985
|
switch (command) {
|
|
2798
|
-
case M$
|
|
2986
|
+
case M$3:
|
|
2799
2987
|
drawer.moveTo(data[i + 1], data[i + 2]);
|
|
2800
2988
|
i += 3;
|
|
2801
2989
|
break;
|
|
2802
|
-
case L$
|
|
2990
|
+
case L$4:
|
|
2803
2991
|
drawer.lineTo(data[i + 1], data[i + 2]);
|
|
2804
2992
|
i += 3;
|
|
2805
2993
|
break;
|
|
2806
|
-
case C$
|
|
2994
|
+
case C$3:
|
|
2807
2995
|
drawer.bezierCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
|
|
2808
2996
|
i += 7;
|
|
2809
2997
|
break;
|
|
2810
|
-
case Q$
|
|
2998
|
+
case Q$2:
|
|
2811
2999
|
drawer.quadraticCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4]);
|
|
2812
3000
|
i += 5;
|
|
2813
3001
|
break;
|
|
2814
|
-
case Z$
|
|
3002
|
+
case Z$3:
|
|
2815
3003
|
drawer.closePath();
|
|
2816
3004
|
i += 1;
|
|
2817
3005
|
break;
|
|
2818
|
-
case N$
|
|
3006
|
+
case N$2:
|
|
2819
3007
|
drawer.rect(data[i + 1], data[i + 2], data[i + 3], data[i + 4]);
|
|
2820
3008
|
i += 5;
|
|
2821
3009
|
break;
|
|
2822
|
-
case D$
|
|
3010
|
+
case D$2:
|
|
2823
3011
|
drawer.roundRect(data[i + 1], data[i + 2], data[i + 3], data[i + 4], [data[i + 5], data[i + 6], data[i + 7], data[i + 8]]);
|
|
2824
3012
|
i += 9;
|
|
2825
3013
|
break;
|
|
2826
|
-
case X$
|
|
3014
|
+
case X$2:
|
|
2827
3015
|
drawer.roundRect(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5]);
|
|
2828
3016
|
i += 6;
|
|
2829
3017
|
break;
|
|
2830
|
-
case G$
|
|
3018
|
+
case G$2:
|
|
2831
3019
|
drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5] * OneRadian, data[i + 6] * OneRadian, data[i + 7] * OneRadian, data[i + 8]);
|
|
2832
3020
|
i += 9;
|
|
2833
3021
|
break;
|
|
2834
|
-
case F$
|
|
3022
|
+
case F$2:
|
|
2835
3023
|
drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], 0, 0, PI2, false);
|
|
2836
3024
|
i += 5;
|
|
2837
3025
|
break;
|
|
2838
|
-
case O$
|
|
3026
|
+
case O$2:
|
|
2839
3027
|
drawer.arc(data[i + 1], data[i + 2], data[i + 3], data[i + 4] * OneRadian, data[i + 5] * OneRadian, data[i + 6]);
|
|
2840
3028
|
i += 7;
|
|
2841
3029
|
break;
|
|
2842
|
-
case P$
|
|
3030
|
+
case P$2:
|
|
2843
3031
|
drawer.arc(data[i + 1], data[i + 2], data[i + 3], 0, PI2, false);
|
|
2844
3032
|
i += 4;
|
|
2845
3033
|
break;
|
|
@@ -2848,17 +3036,97 @@ const PathDrawer = {
|
|
|
2848
3036
|
i += 6;
|
|
2849
3037
|
break;
|
|
2850
3038
|
default:
|
|
2851
|
-
debug$
|
|
3039
|
+
debug$b.error(`command: ${command} [index:${i}]`, data);
|
|
2852
3040
|
return;
|
|
2853
3041
|
}
|
|
2854
3042
|
}
|
|
2855
3043
|
}
|
|
2856
3044
|
};
|
|
2857
3045
|
|
|
2858
|
-
const { M: M$
|
|
2859
|
-
const
|
|
2860
|
-
|
|
2861
|
-
|
|
3046
|
+
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
3047
|
+
const PathScaler = {
|
|
3048
|
+
scale(data, scaleX, scaleY) {
|
|
3049
|
+
if (!data)
|
|
3050
|
+
return;
|
|
3051
|
+
let command;
|
|
3052
|
+
let i = 0, len = data.length;
|
|
3053
|
+
while (i < len) {
|
|
3054
|
+
command = data[i];
|
|
3055
|
+
switch (command) {
|
|
3056
|
+
case M$2:
|
|
3057
|
+
scalePoints(data, scaleX, scaleY, i, 1);
|
|
3058
|
+
i += 3;
|
|
3059
|
+
break;
|
|
3060
|
+
case L$3:
|
|
3061
|
+
scalePoints(data, scaleX, scaleY, i, 1);
|
|
3062
|
+
i += 3;
|
|
3063
|
+
break;
|
|
3064
|
+
case C$2:
|
|
3065
|
+
scalePoints(data, scaleX, scaleY, i, 3);
|
|
3066
|
+
i += 7;
|
|
3067
|
+
break;
|
|
3068
|
+
case Q$1:
|
|
3069
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3070
|
+
i += 5;
|
|
3071
|
+
break;
|
|
3072
|
+
case Z$2:
|
|
3073
|
+
i += 1;
|
|
3074
|
+
break;
|
|
3075
|
+
case N$1:
|
|
3076
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3077
|
+
i += 5;
|
|
3078
|
+
break;
|
|
3079
|
+
case D$1:
|
|
3080
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3081
|
+
i += 9;
|
|
3082
|
+
break;
|
|
3083
|
+
case X$1:
|
|
3084
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3085
|
+
i += 6;
|
|
3086
|
+
break;
|
|
3087
|
+
case G$1:
|
|
3088
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3089
|
+
console.log('G');
|
|
3090
|
+
i += 9;
|
|
3091
|
+
break;
|
|
3092
|
+
case F$1:
|
|
3093
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3094
|
+
i += 5;
|
|
3095
|
+
break;
|
|
3096
|
+
case O$1:
|
|
3097
|
+
data[i] = G$1;
|
|
3098
|
+
data.splice(i + 4, 0, data[i + 3], 0);
|
|
3099
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3100
|
+
i += 7 + 2;
|
|
3101
|
+
len += 2;
|
|
3102
|
+
break;
|
|
3103
|
+
case P$1:
|
|
3104
|
+
data[i] = F$1;
|
|
3105
|
+
data.splice(i + 4, 0, data[i + 3]);
|
|
3106
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3107
|
+
i += 4 + 1;
|
|
3108
|
+
len += 1;
|
|
3109
|
+
break;
|
|
3110
|
+
case U$1:
|
|
3111
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
3112
|
+
i += 6;
|
|
3113
|
+
break;
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
},
|
|
3117
|
+
scalePoints(data, scaleX, scaleY, start, pointCount) {
|
|
3118
|
+
for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
|
|
3119
|
+
data[i] *= scaleX;
|
|
3120
|
+
data[i + 1] *= scaleY;
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
};
|
|
3124
|
+
const { scalePoints } = PathScaler;
|
|
3125
|
+
|
|
3126
|
+
const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F, O, P, U } = PathCommandMap;
|
|
3127
|
+
const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
|
|
3128
|
+
const { addPointBounds, copy: copy$6, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
|
|
3129
|
+
const debug$a = Debug.get('PathBounds');
|
|
2862
3130
|
let radius, radiusX, radiusY;
|
|
2863
3131
|
const tempPointBounds = {};
|
|
2864
3132
|
const setPointBounds = {};
|
|
@@ -2866,7 +3134,7 @@ const setEndPoint = {};
|
|
|
2866
3134
|
const PathBounds = {
|
|
2867
3135
|
toBounds(data, setBounds) {
|
|
2868
3136
|
PathBounds.toTwoPointBounds(data, setPointBounds);
|
|
2869
|
-
toBounds$
|
|
3137
|
+
toBounds$2(setPointBounds, setBounds);
|
|
2870
3138
|
},
|
|
2871
3139
|
toTwoPointBounds(data, setPointBounds) {
|
|
2872
3140
|
if (!data || !data.length)
|
|
@@ -2896,7 +3164,7 @@ const PathBounds = {
|
|
|
2896
3164
|
toX = data[i + 5];
|
|
2897
3165
|
toY = data[i + 6];
|
|
2898
3166
|
toTwoPointBounds(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY, tempPointBounds);
|
|
2899
|
-
|
|
3167
|
+
addPointBounds(setPointBounds, tempPointBounds);
|
|
2900
3168
|
x = toX;
|
|
2901
3169
|
y = toY;
|
|
2902
3170
|
i += 7;
|
|
@@ -2907,7 +3175,7 @@ const PathBounds = {
|
|
|
2907
3175
|
toX = data[i + 3];
|
|
2908
3176
|
toY = data[i + 4];
|
|
2909
3177
|
toTwoPointBoundsByQuadraticCurve(x, y, x1, y1, toX, toY, tempPointBounds);
|
|
2910
|
-
|
|
3178
|
+
addPointBounds(setPointBounds, tempPointBounds);
|
|
2911
3179
|
x = toX;
|
|
2912
3180
|
y = toY;
|
|
2913
3181
|
i += 5;
|
|
@@ -2930,7 +3198,7 @@ const PathBounds = {
|
|
|
2930
3198
|
break;
|
|
2931
3199
|
case G:
|
|
2932
3200
|
ellipse$1(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], data[i + 7], data[i + 8], tempPointBounds, setEndPoint);
|
|
2933
|
-
i === 0 ? copy$6(setPointBounds, tempPointBounds) :
|
|
3201
|
+
i === 0 ? copy$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
2934
3202
|
x = setEndPoint.x;
|
|
2935
3203
|
y = setEndPoint.y;
|
|
2936
3204
|
i += 9;
|
|
@@ -2946,7 +3214,7 @@ const PathBounds = {
|
|
|
2946
3214
|
break;
|
|
2947
3215
|
case O:
|
|
2948
3216
|
arc(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], tempPointBounds, setEndPoint);
|
|
2949
|
-
i === 0 ? copy$6(setPointBounds, tempPointBounds) :
|
|
3217
|
+
i === 0 ? copy$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
2950
3218
|
x = setEndPoint.x;
|
|
2951
3219
|
y = setEndPoint.y;
|
|
2952
3220
|
i += 7;
|
|
@@ -2959,39 +3227,41 @@ const PathBounds = {
|
|
|
2959
3227
|
x += radius;
|
|
2960
3228
|
i += 4;
|
|
2961
3229
|
break;
|
|
2962
|
-
case U
|
|
2963
|
-
arcTo(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
|
|
2964
|
-
i === 0 ? copy$6(setPointBounds, tempPointBounds) :
|
|
3230
|
+
case U:
|
|
3231
|
+
arcTo$1(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
|
|
3232
|
+
i === 0 ? copy$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
2965
3233
|
x = setEndPoint.x;
|
|
2966
3234
|
y = setEndPoint.y;
|
|
2967
3235
|
i += 6;
|
|
2968
3236
|
break;
|
|
2969
3237
|
default:
|
|
2970
|
-
debug$
|
|
3238
|
+
debug$a.error(`command: ${command} [index:${i}]`, data);
|
|
2971
3239
|
return;
|
|
2972
3240
|
}
|
|
2973
3241
|
}
|
|
2974
3242
|
}
|
|
2975
3243
|
};
|
|
2976
3244
|
|
|
2977
|
-
const { M, L: L$1, C, Z
|
|
3245
|
+
const { M, L: L$1, C, Z } = PathCommandMap;
|
|
3246
|
+
const { getCenterX, getCenterY } = PointHelper;
|
|
3247
|
+
const { arcTo } = PathCommandDataHelper;
|
|
2978
3248
|
const PathCorner = {
|
|
2979
3249
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
2980
3250
|
let command;
|
|
2981
|
-
let i = 0, x = 0, y = 0, startX, startY = 0,
|
|
3251
|
+
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
2982
3252
|
const len = data.length;
|
|
2983
3253
|
const smooth = [];
|
|
2984
3254
|
while (i < len) {
|
|
2985
3255
|
command = data[i];
|
|
2986
3256
|
switch (command) {
|
|
2987
3257
|
case M:
|
|
2988
|
-
startX = data[i + 1];
|
|
2989
|
-
startY = data[i + 2];
|
|
3258
|
+
startX = lastX = data[i + 1];
|
|
3259
|
+
startY = lastY = data[i + 2];
|
|
2990
3260
|
i += 3;
|
|
2991
3261
|
if (data[i] === L$1) {
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
smooth.push(M,
|
|
3262
|
+
secondX = data[i + 1];
|
|
3263
|
+
secondY = data[i + 2];
|
|
3264
|
+
smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
|
|
2995
3265
|
}
|
|
2996
3266
|
else {
|
|
2997
3267
|
smooth.push(M, startX, startY);
|
|
@@ -3003,21 +3273,23 @@ const PathCorner = {
|
|
|
3003
3273
|
i += 3;
|
|
3004
3274
|
switch (data[i]) {
|
|
3005
3275
|
case L$1:
|
|
3006
|
-
smooth
|
|
3276
|
+
arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
|
|
3007
3277
|
break;
|
|
3008
3278
|
case Z:
|
|
3009
|
-
smooth
|
|
3279
|
+
arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
|
|
3010
3280
|
break;
|
|
3011
3281
|
default:
|
|
3012
3282
|
smooth.push(L$1, x, y);
|
|
3013
3283
|
}
|
|
3284
|
+
lastX = x;
|
|
3285
|
+
lastY = y;
|
|
3014
3286
|
break;
|
|
3015
3287
|
case C:
|
|
3016
3288
|
smooth.push(C, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
|
|
3017
3289
|
i += 7;
|
|
3018
3290
|
break;
|
|
3019
3291
|
case Z:
|
|
3020
|
-
smooth
|
|
3292
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3021
3293
|
smooth.push(Z);
|
|
3022
3294
|
i += 1;
|
|
3023
3295
|
break;
|
|
@@ -3048,7 +3320,7 @@ function canvasPatch(drawer) {
|
|
|
3048
3320
|
roundRect(drawer);
|
|
3049
3321
|
}
|
|
3050
3322
|
|
|
3051
|
-
const debug$
|
|
3323
|
+
const debug$9 = Debug.get('TaskProcessor');
|
|
3052
3324
|
class TaskItem {
|
|
3053
3325
|
constructor(task) {
|
|
3054
3326
|
this.parallel = true;
|
|
@@ -3063,7 +3335,7 @@ class TaskItem {
|
|
|
3063
3335
|
yield this.task();
|
|
3064
3336
|
}
|
|
3065
3337
|
catch (error) {
|
|
3066
|
-
debug$
|
|
3338
|
+
debug$9.error(error);
|
|
3067
3339
|
}
|
|
3068
3340
|
});
|
|
3069
3341
|
}
|
|
@@ -3301,7 +3573,7 @@ const ImageManager = {
|
|
|
3301
3573
|
recycledList: [],
|
|
3302
3574
|
tasker: new TaskProcessor(),
|
|
3303
3575
|
patternTasker: new TaskProcessor(),
|
|
3304
|
-
get isComplete() { return I$1.tasker.isComplete
|
|
3576
|
+
get isComplete() { return I$1.tasker.isComplete; },
|
|
3305
3577
|
get(config) {
|
|
3306
3578
|
let image = I$1.map[config.url];
|
|
3307
3579
|
if (!image) {
|
|
@@ -3632,16 +3904,6 @@ function getNames(object) {
|
|
|
3632
3904
|
return Object.getOwnPropertyNames(object);
|
|
3633
3905
|
}
|
|
3634
3906
|
|
|
3635
|
-
function aliasType(name) {
|
|
3636
|
-
return (target, key) => {
|
|
3637
|
-
defineKey(target, key, {
|
|
3638
|
-
get() { return this.__getAttr(name); },
|
|
3639
|
-
set(value) {
|
|
3640
|
-
this.__setAttr(name, value);
|
|
3641
|
-
}
|
|
3642
|
-
});
|
|
3643
|
-
};
|
|
3644
|
-
}
|
|
3645
3907
|
function defineLeafAttr(target, key, defaultValue, mergeDescriptor) {
|
|
3646
3908
|
const defaultDescriptor = {
|
|
3647
3909
|
get() { return this.__getAttr(key); },
|
|
@@ -3667,6 +3929,17 @@ function positionType(defaultValue) {
|
|
|
3667
3929
|
});
|
|
3668
3930
|
};
|
|
3669
3931
|
}
|
|
3932
|
+
function autoLayoutType(defaultValue) {
|
|
3933
|
+
return (target, key) => {
|
|
3934
|
+
defineLeafAttr(target, key, defaultValue, {
|
|
3935
|
+
set(value) {
|
|
3936
|
+
this.__setAttr(key, value);
|
|
3937
|
+
this.__layout.matrixChanged || this.__layout.matrixChange();
|
|
3938
|
+
this.__hasAutoLayout = !!value;
|
|
3939
|
+
}
|
|
3940
|
+
});
|
|
3941
|
+
};
|
|
3942
|
+
}
|
|
3670
3943
|
function scaleType(defaultValue) {
|
|
3671
3944
|
return (target, key) => {
|
|
3672
3945
|
defineLeafAttr(target, key, defaultValue, {
|
|
@@ -3693,7 +3966,7 @@ function boundsType(defaultValue) {
|
|
|
3693
3966
|
set(value) {
|
|
3694
3967
|
this.__setAttr(key, value);
|
|
3695
3968
|
this.__layout.boxChanged || this.__layout.boxChange();
|
|
3696
|
-
if (this.
|
|
3969
|
+
if (this.__hasAutoLayout)
|
|
3697
3970
|
this.__layout.matrixChanged || this.__layout.matrixChange();
|
|
3698
3971
|
}
|
|
3699
3972
|
});
|
|
@@ -3815,9 +4088,6 @@ function layoutProcessor(processor) {
|
|
|
3815
4088
|
function getSetMethodName(key) {
|
|
3816
4089
|
return 'set' + key.charAt(0).toUpperCase() + key.slice(1);
|
|
3817
4090
|
}
|
|
3818
|
-
function setDefaultValue(target, key, defaultValue) {
|
|
3819
|
-
defineDataProcessor(target.prototype, key, defaultValue);
|
|
3820
|
-
}
|
|
3821
4091
|
function defineDataProcessor(target, key, defaultValue) {
|
|
3822
4092
|
const data = target.__DataProcessor.prototype;
|
|
3823
4093
|
const computedKey = '_' + key;
|
|
@@ -3848,7 +4118,11 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
3848
4118
|
return v === undefined ? (this.__naturalHeight || defaultValue) : v;
|
|
3849
4119
|
};
|
|
3850
4120
|
}
|
|
3851
|
-
|
|
4121
|
+
let descriptor, find = data;
|
|
4122
|
+
while (!descriptor && find) {
|
|
4123
|
+
descriptor = getDescriptor(find, key);
|
|
4124
|
+
find = find.__proto__;
|
|
4125
|
+
}
|
|
3852
4126
|
if (descriptor && descriptor.set)
|
|
3853
4127
|
property.set = descriptor.set;
|
|
3854
4128
|
if (data[setMethodName]) {
|
|
@@ -3858,7 +4132,7 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
3858
4132
|
Object.defineProperty(data, key, property);
|
|
3859
4133
|
}
|
|
3860
4134
|
|
|
3861
|
-
const debug$
|
|
4135
|
+
const debug$8 = new Debug('rewrite');
|
|
3862
4136
|
const list$1 = [];
|
|
3863
4137
|
const excludeNames = ['destroy', 'constructor'];
|
|
3864
4138
|
function rewrite(method) {
|
|
@@ -3875,7 +4149,7 @@ function doRewrite(error) {
|
|
|
3875
4149
|
if (list$1.length) {
|
|
3876
4150
|
list$1.forEach(item => {
|
|
3877
4151
|
if (error)
|
|
3878
|
-
debug$
|
|
4152
|
+
debug$8.error(item.name, '需在Class上装饰@rewriteAble()');
|
|
3879
4153
|
item.run();
|
|
3880
4154
|
});
|
|
3881
4155
|
list$1.length = 0;
|
|
@@ -4118,17 +4392,43 @@ class Transformer {
|
|
|
4118
4392
|
}
|
|
4119
4393
|
}
|
|
4120
4394
|
|
|
4121
|
-
const { copy: copy$5, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter } = MatrixHelper;
|
|
4122
|
-
const matrix = {};
|
|
4395
|
+
const { copy: copy$5, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$1, divideParent, getLayout } = MatrixHelper;
|
|
4396
|
+
const matrix$1 = {};
|
|
4123
4397
|
const LeafHelper = {
|
|
4124
|
-
|
|
4125
|
-
leaf.
|
|
4398
|
+
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
4399
|
+
if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
|
|
4400
|
+
waitAutoLayout = true;
|
|
4401
|
+
updateMatrix$2(leaf, checkAutoLayout, waitAutoLayout);
|
|
4126
4402
|
if (leaf.isBranch) {
|
|
4127
4403
|
const { children } = leaf;
|
|
4128
4404
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
4129
|
-
|
|
4405
|
+
updateAllMatrix$3(children[i], checkAutoLayout, waitAutoLayout);
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
},
|
|
4409
|
+
updateMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
4410
|
+
const layout = leaf.__layout;
|
|
4411
|
+
if (checkAutoLayout) {
|
|
4412
|
+
if (waitAutoLayout) {
|
|
4413
|
+
layout.waitAutoLayout = true;
|
|
4414
|
+
if (leaf.__hasAutoLayout)
|
|
4415
|
+
layout.matrixChanged = false;
|
|
4130
4416
|
}
|
|
4131
4417
|
}
|
|
4418
|
+
else if (layout.waitAutoLayout) {
|
|
4419
|
+
layout.waitAutoLayout = false;
|
|
4420
|
+
}
|
|
4421
|
+
if (layout.matrixChanged)
|
|
4422
|
+
leaf.__updateLocalMatrix();
|
|
4423
|
+
if (!layout.waitAutoLayout)
|
|
4424
|
+
leaf.__updateWorldMatrix();
|
|
4425
|
+
},
|
|
4426
|
+
updateBounds(leaf) {
|
|
4427
|
+
const layout = leaf.__layout;
|
|
4428
|
+
if (layout.boundsChanged)
|
|
4429
|
+
leaf.__updateLocalBounds();
|
|
4430
|
+
if (!layout.waitAutoLayout)
|
|
4431
|
+
leaf.__updateWorldBounds();
|
|
4132
4432
|
},
|
|
4133
4433
|
updateAllWorldOpacity(leaf) {
|
|
4134
4434
|
leaf.__updateWorldOpacity();
|
|
@@ -4170,62 +4470,78 @@ const LeafHelper = {
|
|
|
4170
4470
|
t.x += x;
|
|
4171
4471
|
t.y += y;
|
|
4172
4472
|
},
|
|
4173
|
-
zoomOfWorld(t, origin, scaleX, scaleY) {
|
|
4174
|
-
this.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY);
|
|
4473
|
+
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4474
|
+
this.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
4175
4475
|
},
|
|
4176
|
-
zoomOfLocal(t, origin, scaleX, scaleY = scaleX) {
|
|
4177
|
-
copy$5(matrix, t.
|
|
4178
|
-
scaleOfOuter$3(matrix, origin, scaleX, scaleY);
|
|
4179
|
-
moveByMatrix(t, matrix);
|
|
4180
|
-
t.scaleX
|
|
4181
|
-
t.scaleY *= scaleY;
|
|
4476
|
+
zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
|
|
4477
|
+
copy$5(matrix$1, t.__localMatrix);
|
|
4478
|
+
scaleOfOuter$3(matrix$1, origin, scaleX, scaleY);
|
|
4479
|
+
moveByMatrix(t, matrix$1);
|
|
4480
|
+
t.scaleResize(scaleX, scaleY, resize !== true);
|
|
4182
4481
|
},
|
|
4183
4482
|
rotateOfWorld(t, origin, angle) {
|
|
4184
4483
|
this.rotateOfLocal(t, getTempLocal(t, origin), angle);
|
|
4185
4484
|
},
|
|
4186
4485
|
rotateOfLocal(t, origin, angle) {
|
|
4187
|
-
copy$5(matrix, t.
|
|
4188
|
-
rotateOfOuter$3(matrix, origin, angle);
|
|
4189
|
-
moveByMatrix(t, matrix);
|
|
4486
|
+
copy$5(matrix$1, t.__localMatrix);
|
|
4487
|
+
rotateOfOuter$3(matrix$1, origin, angle);
|
|
4488
|
+
moveByMatrix(t, matrix$1);
|
|
4190
4489
|
t.rotation = MathHelper.formatRotation(t.rotation + angle);
|
|
4191
4490
|
},
|
|
4192
|
-
skewOfWorld(t, origin, skewX, skewY) {
|
|
4193
|
-
this.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY);
|
|
4491
|
+
skewOfWorld(t, origin, skewX, skewY, resize) {
|
|
4492
|
+
this.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
|
|
4493
|
+
},
|
|
4494
|
+
skewOfLocal(t, origin, skewX, skewY = 0, resize) {
|
|
4495
|
+
copy$5(matrix$1, t.__localMatrix);
|
|
4496
|
+
skewOfOuter(matrix$1, origin, skewX, skewY);
|
|
4497
|
+
L.setTransform(t, matrix$1, resize);
|
|
4498
|
+
},
|
|
4499
|
+
transform(t, transform, resize) {
|
|
4500
|
+
copy$5(matrix$1, t.localTransform);
|
|
4501
|
+
multiplyParent$1(matrix$1, transform);
|
|
4502
|
+
L.setTransform(t, matrix$1, resize);
|
|
4194
4503
|
},
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4504
|
+
setTransform(t, transform, resize) {
|
|
4505
|
+
const layout = getLayout(transform);
|
|
4506
|
+
if (resize) {
|
|
4507
|
+
t.scaleResize(layout.scaleX / t.scaleX, layout.scaleY / t.scaleY, resize !== true);
|
|
4508
|
+
delete layout.scaleX;
|
|
4509
|
+
delete layout.scaleY;
|
|
4510
|
+
}
|
|
4511
|
+
t.set(layout);
|
|
4201
4512
|
},
|
|
4202
|
-
drop(t, parent) {
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
parent.add(t);
|
|
4513
|
+
drop(t, parent, index, resize) {
|
|
4514
|
+
copy$5(matrix$1, t.worldTransform);
|
|
4515
|
+
divideParent(matrix$1, parent.worldTransform);
|
|
4516
|
+
t.setTransform(matrix$1, resize);
|
|
4517
|
+
parent.add(t, index);
|
|
4208
4518
|
},
|
|
4209
|
-
hasParent(
|
|
4519
|
+
hasParent(p, parent) {
|
|
4210
4520
|
if (!parent)
|
|
4211
4521
|
return false;
|
|
4212
|
-
let p = t;
|
|
4213
4522
|
while (p) {
|
|
4214
4523
|
if (parent === p)
|
|
4215
4524
|
return true;
|
|
4216
4525
|
p = p.parent;
|
|
4217
4526
|
}
|
|
4218
|
-
|
|
4527
|
+
},
|
|
4528
|
+
hasParentAutoLayout(p) {
|
|
4529
|
+
while (p.parent) {
|
|
4530
|
+
p = p.parent;
|
|
4531
|
+
if (p.__hasAutoLayout)
|
|
4532
|
+
return true;
|
|
4533
|
+
}
|
|
4219
4534
|
}
|
|
4220
4535
|
};
|
|
4221
4536
|
const L = LeafHelper;
|
|
4222
|
-
const {
|
|
4537
|
+
const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
|
|
4223
4538
|
function moveByMatrix(t, matrix) {
|
|
4224
|
-
|
|
4225
|
-
t.
|
|
4539
|
+
const { e, f } = t.__localMatrix;
|
|
4540
|
+
t.x += matrix.e - e;
|
|
4541
|
+
t.y += matrix.f - f;
|
|
4226
4542
|
}
|
|
4227
4543
|
function getTempLocal(t, world) {
|
|
4228
|
-
t.__layout.
|
|
4544
|
+
t.__layout.update();
|
|
4229
4545
|
return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
|
|
4230
4546
|
}
|
|
4231
4547
|
|
|
@@ -4234,18 +4550,18 @@ const LeafBoundsHelper = {
|
|
|
4234
4550
|
return target.__world;
|
|
4235
4551
|
},
|
|
4236
4552
|
localBoxBounds(target) {
|
|
4237
|
-
return target.__.isEraser ? null : target.__local;
|
|
4553
|
+
return target.__.isEraser ? null : (target.__local || target.__);
|
|
4238
4554
|
},
|
|
4239
|
-
|
|
4555
|
+
localStrokeBounds(target) {
|
|
4240
4556
|
return target.__.isEraser ? null : target.__layout.localStrokeBounds;
|
|
4241
4557
|
},
|
|
4242
4558
|
localRenderBounds(target) {
|
|
4243
4559
|
return target.__.isEraser ? null : target.__layout.localRenderBounds;
|
|
4244
4560
|
},
|
|
4245
4561
|
maskLocalBoxBounds(target) {
|
|
4246
|
-
return target.__.isMask ? target.
|
|
4562
|
+
return target.__.isMask ? target.__localBounds : null;
|
|
4247
4563
|
},
|
|
4248
|
-
|
|
4564
|
+
maskLocalStrokeBounds(target) {
|
|
4249
4565
|
return target.__.isMask ? target.__layout.localStrokeBounds : null;
|
|
4250
4566
|
},
|
|
4251
4567
|
maskLocalRenderBounds(target) {
|
|
@@ -4253,11 +4569,12 @@ const LeafBoundsHelper = {
|
|
|
4253
4569
|
}
|
|
4254
4570
|
};
|
|
4255
4571
|
|
|
4572
|
+
const { updateBounds: updateBounds$2 } = LeafHelper;
|
|
4256
4573
|
const BranchHelper = {
|
|
4257
4574
|
sort(a, b) {
|
|
4258
4575
|
return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
|
|
4259
4576
|
},
|
|
4260
|
-
pushAllChildBranch(branch,
|
|
4577
|
+
pushAllChildBranch(branch, leafList) {
|
|
4261
4578
|
branch.__tempNumber = 1;
|
|
4262
4579
|
if (branch.__.__childBranchNumber) {
|
|
4263
4580
|
const { children } = branch;
|
|
@@ -4265,18 +4582,18 @@ const BranchHelper = {
|
|
|
4265
4582
|
branch = children[i];
|
|
4266
4583
|
if (branch.isBranch) {
|
|
4267
4584
|
branch.__tempNumber = 1;
|
|
4268
|
-
|
|
4269
|
-
pushAllChildBranch$1(branch,
|
|
4585
|
+
leafList.add(branch);
|
|
4586
|
+
pushAllChildBranch$1(branch, leafList);
|
|
4270
4587
|
}
|
|
4271
4588
|
}
|
|
4272
4589
|
}
|
|
4273
4590
|
},
|
|
4274
|
-
pushAllParent(leaf,
|
|
4275
|
-
const { keys } =
|
|
4591
|
+
pushAllParent(leaf, leafList) {
|
|
4592
|
+
const { keys } = leafList;
|
|
4276
4593
|
if (keys) {
|
|
4277
4594
|
while (leaf.parent) {
|
|
4278
4595
|
if (keys[leaf.parent.innerId] === undefined) {
|
|
4279
|
-
|
|
4596
|
+
leafList.add(leaf.parent);
|
|
4280
4597
|
leaf = leaf.parent;
|
|
4281
4598
|
}
|
|
4282
4599
|
else {
|
|
@@ -4286,7 +4603,7 @@ const BranchHelper = {
|
|
|
4286
4603
|
}
|
|
4287
4604
|
else {
|
|
4288
4605
|
while (leaf.parent) {
|
|
4289
|
-
|
|
4606
|
+
leafList.add(leaf.parent);
|
|
4290
4607
|
leaf = leaf.parent;
|
|
4291
4608
|
}
|
|
4292
4609
|
}
|
|
@@ -4300,21 +4617,29 @@ const BranchHelper = {
|
|
|
4300
4617
|
}
|
|
4301
4618
|
}
|
|
4302
4619
|
for (let i = start, len = pushList.length; i < len; i++) {
|
|
4303
|
-
pushAllBranchStack
|
|
4620
|
+
pushAllBranchStack(pushList[i], pushList);
|
|
4304
4621
|
}
|
|
4305
4622
|
},
|
|
4306
|
-
|
|
4307
|
-
|
|
4623
|
+
updateBounds(branch, exclude) {
|
|
4624
|
+
const branchStack = [branch];
|
|
4625
|
+
pushAllBranchStack(branch, branchStack);
|
|
4626
|
+
updateBoundsByBranchStack(branchStack, exclude);
|
|
4627
|
+
},
|
|
4628
|
+
updateBoundsByBranchStack(branchStack, exclude) {
|
|
4629
|
+
let branch, children;
|
|
4308
4630
|
for (let i = branchStack.length - 1; i > -1; i--) {
|
|
4309
4631
|
branch = branchStack[i];
|
|
4310
|
-
|
|
4311
|
-
|
|
4632
|
+
children = branch.children;
|
|
4633
|
+
for (let j = 0, len = children.length; j < len; j++) {
|
|
4634
|
+
updateBounds$2(children[j]);
|
|
4312
4635
|
}
|
|
4636
|
+
if (exclude && exclude === branch)
|
|
4637
|
+
continue;
|
|
4638
|
+
updateBounds$2(branch);
|
|
4313
4639
|
}
|
|
4314
|
-
branch.__updateWorldBounds();
|
|
4315
4640
|
}
|
|
4316
4641
|
};
|
|
4317
|
-
const { pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack
|
|
4642
|
+
const { pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack, updateBoundsByBranchStack } = BranchHelper;
|
|
4318
4643
|
|
|
4319
4644
|
const WaitHelper = {
|
|
4320
4645
|
run(wait) {
|
|
@@ -4382,7 +4707,7 @@ const InteractionHelper = {
|
|
|
4382
4707
|
const { list } = path;
|
|
4383
4708
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
4384
4709
|
if (list[i].hasEvent(type))
|
|
4385
|
-
find.
|
|
4710
|
+
find.add(list[i]);
|
|
4386
4711
|
}
|
|
4387
4712
|
return find;
|
|
4388
4713
|
}
|
|
@@ -4399,7 +4724,8 @@ class Dragger {
|
|
|
4399
4724
|
this.dragData = getDragEventData(data, data, data);
|
|
4400
4725
|
}
|
|
4401
4726
|
getList() {
|
|
4402
|
-
|
|
4727
|
+
const { proxy } = this.interaction.selector;
|
|
4728
|
+
return this.dragging && (!proxy || !proxy.list.length) ? (DragEvent.list || this.dragableList || emptyList) : emptyList;
|
|
4403
4729
|
}
|
|
4404
4730
|
checkDrag(data, canDrag) {
|
|
4405
4731
|
const { interaction } = this;
|
|
@@ -4410,8 +4736,7 @@ class Dragger {
|
|
|
4410
4736
|
}
|
|
4411
4737
|
const { dragData } = this;
|
|
4412
4738
|
if (!this.moving) {
|
|
4413
|
-
|
|
4414
|
-
this.moving = (PointerButton.middle(data) || interaction.moveMode || moveOnDragEmpty) && canDrag;
|
|
4739
|
+
this.moving = (PointerButton.middle(data) || interaction.moveMode) && canDrag;
|
|
4415
4740
|
if (this.moving)
|
|
4416
4741
|
interaction.emit(MoveEvent.START, dragData);
|
|
4417
4742
|
}
|
|
@@ -4446,7 +4771,7 @@ class Dragger {
|
|
|
4446
4771
|
let leaf;
|
|
4447
4772
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
4448
4773
|
leaf = path.list[i];
|
|
4449
|
-
if (leaf.__.draggable && leaf.__.hitSelf) {
|
|
4774
|
+
if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf) {
|
|
4450
4775
|
this.dragableList = new LeafList(leaf);
|
|
4451
4776
|
break;
|
|
4452
4777
|
}
|
|
@@ -4457,9 +4782,7 @@ class Dragger {
|
|
|
4457
4782
|
const list = this.getList();
|
|
4458
4783
|
if (list.length && running) {
|
|
4459
4784
|
const { moveX, moveY } = this.dragData;
|
|
4460
|
-
list.forEach(leaf =>
|
|
4461
|
-
LeafHelper.moveWorld(leaf, moveX, moveY);
|
|
4462
|
-
});
|
|
4785
|
+
list.forEach(leaf => LeafHelper.moveWorld(leaf, moveX, moveY));
|
|
4463
4786
|
}
|
|
4464
4787
|
}
|
|
4465
4788
|
dragOverOrOut(data) {
|
|
@@ -4537,8 +4860,8 @@ class Dragger {
|
|
|
4537
4860
|
return;
|
|
4538
4861
|
const bounds = interaction.shrinkCanvasBounds;
|
|
4539
4862
|
const { x, y } = bounds;
|
|
4540
|
-
const right = BoundsHelper.
|
|
4541
|
-
const bottom = BoundsHelper.
|
|
4863
|
+
const right = BoundsHelper.maxX(bounds);
|
|
4864
|
+
const bottom = BoundsHelper.maxY(bounds);
|
|
4542
4865
|
const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
|
|
4543
4866
|
const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
|
|
4544
4867
|
let totalX = 0, totalY = 0;
|
|
@@ -4562,6 +4885,7 @@ class Dragger {
|
|
|
4562
4885
|
}
|
|
4563
4886
|
}
|
|
4564
4887
|
|
|
4888
|
+
const debug$7 = Debug.get('emit');
|
|
4565
4889
|
function emit$1(type, data, path, excludePath) {
|
|
4566
4890
|
if (!path && !data.path)
|
|
4567
4891
|
return;
|
|
@@ -4574,24 +4898,29 @@ function emit$1(type, data, path, excludePath) {
|
|
|
4574
4898
|
path = data.path;
|
|
4575
4899
|
}
|
|
4576
4900
|
data.target = path.indexAt(0);
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
}
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4901
|
+
try {
|
|
4902
|
+
for (let i = path.length - 1; i > -1; i--) {
|
|
4903
|
+
leaf = path.list[i];
|
|
4904
|
+
if (emitEvent(leaf, type, data, true, excludePath))
|
|
4905
|
+
return;
|
|
4906
|
+
if (leaf.isApp)
|
|
4907
|
+
emitAppChildren(leaf, type, data, true, excludePath);
|
|
4908
|
+
}
|
|
4909
|
+
for (let i = 0, len = path.length; i < len; i++) {
|
|
4910
|
+
leaf = path.list[i];
|
|
4911
|
+
if (leaf.isApp)
|
|
4912
|
+
emitAppChildren(leaf, type, data, false, excludePath);
|
|
4913
|
+
if (emitEvent(leaf, type, data, false, excludePath))
|
|
4914
|
+
return;
|
|
4915
|
+
}
|
|
4916
|
+
}
|
|
4917
|
+
catch (e) {
|
|
4918
|
+
debug$7.error(e);
|
|
4919
|
+
}
|
|
4920
|
+
}
|
|
4921
|
+
const allowTypes = ['move', 'zoom', 'rotate', 'key'];
|
|
4922
|
+
function emitAppChildren(leaf, type, data, capture, excludePath) {
|
|
4923
|
+
if (allowTypes.some(name => type.startsWith(name)) && leaf.__.hitChildren && !exclude(leaf, excludePath)) {
|
|
4595
4924
|
let child;
|
|
4596
4925
|
for (let i = 0, len = leaf.children.length; i < len; i++) {
|
|
4597
4926
|
child = leaf.children[i];
|
|
@@ -4626,39 +4955,42 @@ const MultiTouchHelper = {
|
|
|
4626
4955
|
const lastDistance = PointHelper.getDistance(a.from, b.from);
|
|
4627
4956
|
const distance = PointHelper.getDistance(a.to, b.to);
|
|
4628
4957
|
const scale = distance / lastDistance;
|
|
4629
|
-
const angle = PointHelper.
|
|
4958
|
+
const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
|
|
4630
4959
|
return { move, scale, angle, center };
|
|
4631
4960
|
}
|
|
4632
4961
|
};
|
|
4633
4962
|
|
|
4963
|
+
const config = {
|
|
4964
|
+
wheel: {
|
|
4965
|
+
zoomMode: false,
|
|
4966
|
+
zoomSpeed: 0.5,
|
|
4967
|
+
moveSpeed: 0.5,
|
|
4968
|
+
rotateSpeed: 0.5,
|
|
4969
|
+
delta: Platform.os === 'Windows' ? { x: 150 / 4, y: 150 / 4 } : { x: 80 / 4, y: 8.0 },
|
|
4970
|
+
preventDefault: true
|
|
4971
|
+
},
|
|
4972
|
+
pointer: {
|
|
4973
|
+
hitRadius: 5,
|
|
4974
|
+
through: false,
|
|
4975
|
+
tapTime: 120,
|
|
4976
|
+
longPressTime: 800,
|
|
4977
|
+
transformTime: 500,
|
|
4978
|
+
dragHover: true,
|
|
4979
|
+
dragDistance: 2,
|
|
4980
|
+
swipeDistance: 20,
|
|
4981
|
+
ignoreMove: false
|
|
4982
|
+
},
|
|
4983
|
+
cursor: {}
|
|
4984
|
+
};
|
|
4985
|
+
|
|
4634
4986
|
const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1 } = InteractionHelper;
|
|
4635
4987
|
class InteractionBase {
|
|
4636
4988
|
get dragging() { return this.dragger.dragging; }
|
|
4637
|
-
get
|
|
4989
|
+
get isDragEmpty() { return this.config.move.dragEmpty && (this.hoverData && this.hoverData.path.list[0].isLeafer) && (!this.downData || this.downData.path.list[0].isLeafer); }
|
|
4990
|
+
get moveMode() { return this.config.move.drag || (this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey()) || (this.downData && PointerButton.middle(this.downData)) || this.isDragEmpty; }
|
|
4638
4991
|
get hitRadius() { return this.config.pointer.hitRadius; }
|
|
4639
4992
|
constructor(target, canvas, selector, userConfig) {
|
|
4640
|
-
this.config =
|
|
4641
|
-
wheel: {
|
|
4642
|
-
zoomMode: false,
|
|
4643
|
-
zoomSpeed: 0.5,
|
|
4644
|
-
moveSpeed: 0.5,
|
|
4645
|
-
rotateSpeed: 0.5,
|
|
4646
|
-
delta: Platform.os === 'Windows' ? { x: 150 / 4, y: 150 / 4 } : { x: 80 / 4, y: 8.0 },
|
|
4647
|
-
preventDefault: true
|
|
4648
|
-
},
|
|
4649
|
-
pointer: {
|
|
4650
|
-
hitRadius: 5,
|
|
4651
|
-
through: false,
|
|
4652
|
-
tapTime: 120,
|
|
4653
|
-
longPressTime: 800,
|
|
4654
|
-
transformTime: 500,
|
|
4655
|
-
dragHover: true,
|
|
4656
|
-
dragDistance: 2,
|
|
4657
|
-
swipeDistance: 20,
|
|
4658
|
-
ignoreMove: false
|
|
4659
|
-
},
|
|
4660
|
-
cursor: {}
|
|
4661
|
-
};
|
|
4993
|
+
this.config = config;
|
|
4662
4994
|
this.tapCount = 0;
|
|
4663
4995
|
this.downKeyMap = {};
|
|
4664
4996
|
this.target = target;
|
|
@@ -4684,10 +5016,10 @@ class InteractionBase {
|
|
|
4684
5016
|
if (!data)
|
|
4685
5017
|
return;
|
|
4686
5018
|
PointerButton.defaultLeft(data);
|
|
4687
|
-
this.emit(PointerEvent.BEFORE_DOWN, data, this.defaultPath);
|
|
4688
5019
|
this.updateDownData(data);
|
|
4689
5020
|
if (useDefaultPath)
|
|
4690
5021
|
data.path = this.defaultPath;
|
|
5022
|
+
this.emit(PointerEvent.BEFORE_DOWN, data);
|
|
4691
5023
|
this.emit(PointerEvent.DOWN, data);
|
|
4692
5024
|
this.downTime = Date.now();
|
|
4693
5025
|
this.dragger.setDragData(data);
|
|
@@ -4718,7 +5050,8 @@ class InteractionBase {
|
|
|
4718
5050
|
const canDrag = PointHelper.getDistance(this.downData, data) > this.config.pointer.dragDistance;
|
|
4719
5051
|
if (this.waitTap && canDrag)
|
|
4720
5052
|
this.pointerWaitCancel();
|
|
4721
|
-
this.
|
|
5053
|
+
if (!PointerButton.right(this.downData))
|
|
5054
|
+
this.dragger.checkDrag(data, canDrag);
|
|
4722
5055
|
}
|
|
4723
5056
|
if (this.dragger.moving || this.config.pointer.ignoreMove)
|
|
4724
5057
|
return;
|
|
@@ -4738,8 +5071,8 @@ class InteractionBase {
|
|
|
4738
5071
|
if (!this.downData)
|
|
4739
5072
|
return;
|
|
4740
5073
|
PointerButton.defaultLeft(data);
|
|
4741
|
-
this.emit(PointerEvent.BEFORE_UP, data, this.defaultPath);
|
|
4742
5074
|
this.findPath(data);
|
|
5075
|
+
this.emit(PointerEvent.BEFORE_UP, data);
|
|
4743
5076
|
this.emit(PointerEvent.UP, data);
|
|
4744
5077
|
this.emit(PointerEvent.UP, this.downData, undefined, data.path);
|
|
4745
5078
|
this.touchLeave(data);
|
|
@@ -4999,20 +5332,27 @@ class Cursor {
|
|
|
4999
5332
|
}
|
|
5000
5333
|
Cursor.custom = {};
|
|
5001
5334
|
|
|
5002
|
-
const { toOuterOf: toOuterOf$1 } = BoundsHelper;
|
|
5335
|
+
const { toOuterOf: toOuterOf$1, getPoints } = BoundsHelper;
|
|
5003
5336
|
class LeafLayout {
|
|
5337
|
+
get a() { return 1; }
|
|
5338
|
+
get b() { return 0; }
|
|
5339
|
+
get c() { return 0; }
|
|
5340
|
+
get d() { return 1; }
|
|
5341
|
+
get e() { return this.leaf.__.x; }
|
|
5342
|
+
get f() { return this.leaf.__.y; }
|
|
5004
5343
|
constructor(leaf) {
|
|
5005
5344
|
this.leaf = leaf;
|
|
5006
5345
|
this.renderBounds = this.strokeBounds = this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
|
|
5007
|
-
|
|
5346
|
+
if (leaf.__local)
|
|
5347
|
+
this.localRenderBounds = this.localStrokeBounds = leaf.__local;
|
|
5008
5348
|
this.boxChange();
|
|
5009
5349
|
this.matrixChange();
|
|
5010
5350
|
}
|
|
5011
|
-
|
|
5351
|
+
update() {
|
|
5012
5352
|
const { leafer } = this.leaf;
|
|
5013
5353
|
if (leafer) {
|
|
5014
5354
|
if (leafer.ready) {
|
|
5015
|
-
if (
|
|
5355
|
+
if (leafer.watcher.changed)
|
|
5016
5356
|
leafer.layouter.layout();
|
|
5017
5357
|
}
|
|
5018
5358
|
else {
|
|
@@ -5021,59 +5361,141 @@ class LeafLayout {
|
|
|
5021
5361
|
}
|
|
5022
5362
|
else {
|
|
5023
5363
|
let root = this.leaf;
|
|
5024
|
-
while (root.parent) {
|
|
5364
|
+
while (root.parent && !root.parent.leafer) {
|
|
5025
5365
|
root = root.parent;
|
|
5026
5366
|
}
|
|
5027
5367
|
Platform.layout(root);
|
|
5028
5368
|
}
|
|
5029
5369
|
}
|
|
5030
|
-
getTransform(
|
|
5031
|
-
this.
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
return this.
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5370
|
+
getTransform(relative = 'world') {
|
|
5371
|
+
this.update();
|
|
5372
|
+
switch (relative) {
|
|
5373
|
+
case 'world':
|
|
5374
|
+
return this.leaf.__world;
|
|
5375
|
+
case 'local':
|
|
5376
|
+
return this.leaf.__localMatrix;
|
|
5377
|
+
case 'inner':
|
|
5378
|
+
return MatrixHelper.defaultMatrix;
|
|
5379
|
+
default:
|
|
5380
|
+
return new Matrix(this.leaf.__world).divideParent(relative.__world);
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
getBounds(type, relative = 'world') {
|
|
5384
|
+
this.update();
|
|
5385
|
+
switch (relative) {
|
|
5386
|
+
case 'world':
|
|
5387
|
+
return this.getWorldBounds(type);
|
|
5388
|
+
case 'local':
|
|
5389
|
+
return this.getLocalBounds(type);
|
|
5390
|
+
case 'inner':
|
|
5391
|
+
return this.getInnerBounds(type);
|
|
5392
|
+
default:
|
|
5393
|
+
return new Bounds(this.getInnerBounds(type)).toOuterOf(this.getTransform(relative));
|
|
5394
|
+
}
|
|
5395
|
+
}
|
|
5396
|
+
getInnerBounds(type = 'box') {
|
|
5397
|
+
switch (type) {
|
|
5398
|
+
case 'render':
|
|
5399
|
+
return this.renderBounds;
|
|
5400
|
+
case 'content':
|
|
5401
|
+
if (this.contentBounds)
|
|
5402
|
+
return this.contentBounds;
|
|
5403
|
+
case 'margin':
|
|
5404
|
+
case 'box':
|
|
5405
|
+
return this.boxBounds;
|
|
5406
|
+
case 'stroke':
|
|
5407
|
+
return this.strokeBounds;
|
|
5408
|
+
}
|
|
5409
|
+
}
|
|
5410
|
+
getLocalBounds(type = 'box') {
|
|
5411
|
+
switch (type) {
|
|
5412
|
+
case 'render':
|
|
5413
|
+
if (this.localRenderBounds)
|
|
5068
5414
|
return this.localRenderBounds;
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
case 'box':
|
|
5072
|
-
return this.leaf.__local;
|
|
5073
|
-
case 'stroke':
|
|
5415
|
+
case 'stroke':
|
|
5416
|
+
if (this.localStrokeBounds)
|
|
5074
5417
|
return this.localStrokeBounds;
|
|
5075
|
-
|
|
5418
|
+
case 'margin':
|
|
5419
|
+
case 'content':
|
|
5420
|
+
case 'box':
|
|
5421
|
+
return this.leaf.__localBounds;
|
|
5422
|
+
}
|
|
5423
|
+
}
|
|
5424
|
+
getWorldBounds(type = 'box') {
|
|
5425
|
+
switch (type) {
|
|
5426
|
+
case 'render':
|
|
5427
|
+
return this.leaf.__world;
|
|
5428
|
+
case 'content':
|
|
5429
|
+
if (this.contentBounds)
|
|
5430
|
+
return this.getWorldContentBounds();
|
|
5431
|
+
case 'margin':
|
|
5432
|
+
case 'box':
|
|
5433
|
+
return this.getWorldBoxBounds();
|
|
5434
|
+
case 'margin':
|
|
5435
|
+
case 'stroke':
|
|
5436
|
+
return this.getWorldStrokeBounds();
|
|
5437
|
+
}
|
|
5438
|
+
}
|
|
5439
|
+
getLayoutBounds(type, relative = 'world', unscale) {
|
|
5440
|
+
const { leaf } = this;
|
|
5441
|
+
let point, layout;
|
|
5442
|
+
let bounds = this.getInnerBounds(type);
|
|
5443
|
+
switch (relative) {
|
|
5444
|
+
case 'world':
|
|
5445
|
+
point = leaf.getWorldPoint(bounds);
|
|
5446
|
+
layout = leaf.__world;
|
|
5447
|
+
break;
|
|
5448
|
+
case 'local':
|
|
5449
|
+
point = leaf.getLocalPointByInner(bounds);
|
|
5450
|
+
layout = leaf.__;
|
|
5451
|
+
break;
|
|
5452
|
+
case 'inner':
|
|
5453
|
+
point = bounds;
|
|
5454
|
+
layout = MatrixHelper.defaultWorld;
|
|
5455
|
+
break;
|
|
5456
|
+
default:
|
|
5457
|
+
point = leaf.getWorldPoint(bounds, relative);
|
|
5458
|
+
layout = leaf.__world;
|
|
5459
|
+
}
|
|
5460
|
+
let { scaleX, scaleY, rotation, skewX, skewY } = layout;
|
|
5461
|
+
let { width, height } = bounds;
|
|
5462
|
+
if (typeof relative === 'object') {
|
|
5463
|
+
const r = relative.__world;
|
|
5464
|
+
scaleX /= r.scaleX;
|
|
5465
|
+
scaleY /= r.scaleY;
|
|
5466
|
+
rotation -= r.rotation;
|
|
5467
|
+
skewX -= r.skewX;
|
|
5468
|
+
skewY -= r.skewY;
|
|
5469
|
+
}
|
|
5470
|
+
if (unscale) {
|
|
5471
|
+
const uScaleX = scaleX < 0 ? -scaleX : scaleX;
|
|
5472
|
+
const uScaleY = scaleY < 0 ? -scaleY : scaleY;
|
|
5473
|
+
scaleX /= uScaleX;
|
|
5474
|
+
scaleY /= uScaleY;
|
|
5475
|
+
width *= uScaleX;
|
|
5476
|
+
height *= uScaleY;
|
|
5477
|
+
}
|
|
5478
|
+
return { x: point.x, y: point.y, scaleX, scaleY, rotation, skewX, skewY, width, height };
|
|
5479
|
+
}
|
|
5480
|
+
getLayoutPoints(type, relative = 'world') {
|
|
5481
|
+
const { leaf } = this;
|
|
5482
|
+
const points = getPoints(this.getInnerBounds(type));
|
|
5483
|
+
let relativeLeaf;
|
|
5484
|
+
switch (relative) {
|
|
5485
|
+
case 'world':
|
|
5486
|
+
relativeLeaf = null;
|
|
5487
|
+
break;
|
|
5488
|
+
case 'local':
|
|
5489
|
+
relativeLeaf = leaf.parent;
|
|
5490
|
+
break;
|
|
5491
|
+
case 'inner':
|
|
5492
|
+
break;
|
|
5493
|
+
default:
|
|
5494
|
+
relativeLeaf = relative;
|
|
5076
5495
|
}
|
|
5496
|
+
if (relativeLeaf !== undefined)
|
|
5497
|
+
points.forEach(point => leaf.innerToWorld(point, null, false, relativeLeaf));
|
|
5498
|
+
return points;
|
|
5077
5499
|
}
|
|
5078
5500
|
getWorldContentBounds() {
|
|
5079
5501
|
this._worldContentBounds || (this._worldContentBounds = {});
|
|
@@ -5093,7 +5515,7 @@ class LeafLayout {
|
|
|
5093
5515
|
spreadStrokeCancel() {
|
|
5094
5516
|
const same = this.renderBounds === this.strokeBounds;
|
|
5095
5517
|
this.strokeBounds = this.boxBounds;
|
|
5096
|
-
this.localStrokeBounds = this.leaf.
|
|
5518
|
+
this.localStrokeBounds = this.leaf.__localBounds;
|
|
5097
5519
|
if (same)
|
|
5098
5520
|
this.spreadRenderCancel();
|
|
5099
5521
|
}
|
|
@@ -5220,13 +5642,13 @@ const LeafEventer = {
|
|
|
5220
5642
|
if (bind)
|
|
5221
5643
|
listener = listener.bind(bind);
|
|
5222
5644
|
this.on(type, listener, options);
|
|
5223
|
-
return { type, listener, options };
|
|
5645
|
+
return { type, current: this, listener, options };
|
|
5224
5646
|
},
|
|
5225
5647
|
off_(id) {
|
|
5226
5648
|
if (!id)
|
|
5227
5649
|
return;
|
|
5228
5650
|
const list = id instanceof Array ? id : [id];
|
|
5229
|
-
list.forEach(item =>
|
|
5651
|
+
list.forEach(item => item.current.off(item.type, item.listener, item.options));
|
|
5230
5652
|
list.length = 0;
|
|
5231
5653
|
},
|
|
5232
5654
|
once(type, listener, capture) {
|
|
@@ -5292,7 +5714,7 @@ const LeafDataProxy = {
|
|
|
5292
5714
|
const oldValue = this.__.__getInput(name);
|
|
5293
5715
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
5294
5716
|
this.__[name] = newValue;
|
|
5295
|
-
if (this.
|
|
5717
|
+
if (this.__proxyData)
|
|
5296
5718
|
this.setProxyAttr(name, newValue);
|
|
5297
5719
|
const { CHANGE } = PropertyEvent;
|
|
5298
5720
|
const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
|
|
@@ -5303,191 +5725,121 @@ const LeafDataProxy = {
|
|
|
5303
5725
|
}
|
|
5304
5726
|
else {
|
|
5305
5727
|
this.__[name] = newValue;
|
|
5306
|
-
if (this.
|
|
5728
|
+
if (this.__proxyData)
|
|
5307
5729
|
this.setProxyAttr(name, newValue);
|
|
5308
5730
|
}
|
|
5309
5731
|
},
|
|
5310
5732
|
__getAttr(name) {
|
|
5311
|
-
if (this.
|
|
5733
|
+
if (this.__proxyData)
|
|
5312
5734
|
return this.getProxyAttr(name);
|
|
5313
5735
|
return this.__.__get(name);
|
|
5314
|
-
},
|
|
5315
|
-
setProxyAttr(name, newValue) {
|
|
5316
|
-
if (this.proxyData[name] !== newValue)
|
|
5317
|
-
this.proxyData[name] = newValue;
|
|
5318
|
-
},
|
|
5319
|
-
getProxyAttr(name) {
|
|
5320
|
-
return this.proxyData[name];
|
|
5321
5736
|
}
|
|
5322
5737
|
};
|
|
5323
5738
|
|
|
5324
|
-
const {
|
|
5325
|
-
const
|
|
5326
|
-
const defaultCenter = { x: 0.5, y: 0.5 };
|
|
5739
|
+
const { setLayout, multiplyParent, translateInner, defaultWorld } = MatrixHelper;
|
|
5740
|
+
const { toPoint, tempPoint } = AroundHelper;
|
|
5327
5741
|
const LeafMatrix = {
|
|
5328
5742
|
__updateWorldMatrix() {
|
|
5329
|
-
|
|
5330
|
-
const r = this.__local;
|
|
5331
|
-
const w = this.__world;
|
|
5332
|
-
if (this.__layout.matrixChanged)
|
|
5333
|
-
this.__updateLocalMatrix();
|
|
5334
|
-
if (this.__layout.affectScaleOrRotation) {
|
|
5335
|
-
w.a = r.a * pw.a + r.b * pw.c;
|
|
5336
|
-
w.b = r.a * pw.b + r.b * pw.d;
|
|
5337
|
-
w.c = r.c * pw.a + r.d * pw.c;
|
|
5338
|
-
w.d = r.c * pw.b + r.d * pw.d;
|
|
5339
|
-
w.e = r.e * pw.a + r.f * pw.c + pw.e;
|
|
5340
|
-
w.f = r.e * pw.b + r.f * pw.d + pw.f;
|
|
5341
|
-
const data = this.__;
|
|
5342
|
-
w.scaleX = pw.scaleX * data.scaleX;
|
|
5343
|
-
w.scaleY = pw.scaleY * data.scaleY;
|
|
5344
|
-
w.rotation = pw.rotation + data.rotation;
|
|
5345
|
-
w.skewX = pw.skewX + data.skewX;
|
|
5346
|
-
w.skewY = pw.skewY + data.skewY;
|
|
5347
|
-
}
|
|
5348
|
-
else {
|
|
5349
|
-
w.a = pw.a;
|
|
5350
|
-
w.b = pw.b;
|
|
5351
|
-
w.c = pw.c;
|
|
5352
|
-
w.d = pw.d;
|
|
5353
|
-
w.e = r.e * pw.a + r.f * pw.c + pw.e;
|
|
5354
|
-
w.f = r.e * pw.b + r.f * pw.d + pw.f;
|
|
5355
|
-
w.scaleX = pw.scaleX;
|
|
5356
|
-
w.scaleY = pw.scaleY;
|
|
5357
|
-
w.rotation = pw.rotation;
|
|
5358
|
-
w.skewX = pw.skewX;
|
|
5359
|
-
w.skewY = pw.skewY;
|
|
5360
|
-
}
|
|
5743
|
+
multiplyParent(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
|
|
5361
5744
|
},
|
|
5362
5745
|
__updateLocalMatrix() {
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
const { scaleX, scaleY } = this.__;
|
|
5367
|
-
if (layout.affectRotation) {
|
|
5746
|
+
if (this.__local) {
|
|
5747
|
+
const layout = this.__layout, local = this.__local, data = this.__;
|
|
5748
|
+
if (layout.affectScaleOrRotation) {
|
|
5368
5749
|
if (layout.scaleChanged || layout.rotationChanged) {
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
rotation *= OneRadian;
|
|
5372
|
-
if (skewX)
|
|
5373
|
-
skewX *= OneRadian;
|
|
5374
|
-
if (skewY)
|
|
5375
|
-
skewY *= OneRadian;
|
|
5376
|
-
r.a = scaleX * cos$2(rotation + skewY);
|
|
5377
|
-
r.b = scaleX * sin$2(rotation + skewY);
|
|
5378
|
-
r.c = scaleY * -sin$2(rotation - skewX);
|
|
5379
|
-
r.d = scaleY * cos$2(rotation - skewX);
|
|
5380
|
-
}
|
|
5381
|
-
else {
|
|
5382
|
-
r.a = scaleX;
|
|
5383
|
-
r.b = 0;
|
|
5384
|
-
r.c = 0;
|
|
5385
|
-
r.d = scaleY;
|
|
5386
|
-
layout.affectRotation = false;
|
|
5387
|
-
}
|
|
5388
|
-
layout.scaleChanged = false;
|
|
5389
|
-
layout.rotationChanged = false;
|
|
5390
|
-
}
|
|
5391
|
-
}
|
|
5392
|
-
else {
|
|
5393
|
-
if (layout.scaleChanged) {
|
|
5394
|
-
r.a = scaleX;
|
|
5395
|
-
r.d = scaleY;
|
|
5396
|
-
layout.scaleChanged = false;
|
|
5750
|
+
setLayout(local, data, null, layout.affectRotation);
|
|
5751
|
+
layout.scaleChanged = layout.rotationChanged = false;
|
|
5397
5752
|
}
|
|
5398
5753
|
}
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
const { width, height } = this.__;
|
|
5405
|
-
if (width && height) {
|
|
5406
|
-
const origin = (around === 'center') ? defaultCenter : around;
|
|
5407
|
-
const offsetX = width * origin.x, offsetY = height * origin.y;
|
|
5408
|
-
r.e -= offsetX * r.a + offsetY * r.c;
|
|
5409
|
-
r.f -= offsetX * r.b + offsetY * r.d;
|
|
5754
|
+
local.e = data.x;
|
|
5755
|
+
local.f = data.y;
|
|
5756
|
+
if (data.around) {
|
|
5757
|
+
toPoint(data.around, layout.boxBounds, tempPoint);
|
|
5758
|
+
translateInner(local, -tempPoint.x, -tempPoint.y);
|
|
5410
5759
|
}
|
|
5411
5760
|
}
|
|
5412
5761
|
this.__layout.matrixChanged = false;
|
|
5413
5762
|
}
|
|
5414
5763
|
};
|
|
5415
5764
|
|
|
5765
|
+
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2, hasParentAutoLayout } = LeafHelper;
|
|
5766
|
+
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5416
5767
|
const { toOuterOf, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
5417
5768
|
const LeafBounds = {
|
|
5418
5769
|
__updateWorldBounds() {
|
|
5419
|
-
|
|
5420
|
-
if (this.__layout.
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5770
|
+
toOuterOf(this.__layout.renderBounds, this.__world, this.__world);
|
|
5771
|
+
if (this.__layout.resized) {
|
|
5772
|
+
this.__onUpdateSize();
|
|
5773
|
+
this.__layout.resized = false;
|
|
5774
|
+
}
|
|
5775
|
+
},
|
|
5776
|
+
__updateLocalBounds() {
|
|
5777
|
+
const layout = this.__layout;
|
|
5778
|
+
if (layout.boxChanged) {
|
|
5779
|
+
this.__updatePath();
|
|
5780
|
+
this.__updateRenderPath();
|
|
5781
|
+
this.__updateBoxBounds();
|
|
5782
|
+
layout.boxChanged = false;
|
|
5783
|
+
layout.resized = true;
|
|
5784
|
+
}
|
|
5785
|
+
if (layout.localBoxChanged) {
|
|
5786
|
+
if (this.__local)
|
|
5431
5787
|
this.__updateLocalBoxBounds();
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
this.__updateStrokeBounds();
|
|
5446
|
-
this.__updateLocalStrokeBounds();
|
|
5447
|
-
}
|
|
5448
|
-
else {
|
|
5449
|
-
layout.spreadStrokeCancel();
|
|
5450
|
-
}
|
|
5451
|
-
layout.strokeChanged = false;
|
|
5452
|
-
if (layout.renderSpread)
|
|
5453
|
-
layout.renderChanged = true;
|
|
5454
|
-
if (this.parent)
|
|
5455
|
-
this.parent.__layout.strokeChange();
|
|
5456
|
-
resize || (resize = true);
|
|
5457
|
-
}
|
|
5458
|
-
if (layout.renderChanged) {
|
|
5459
|
-
layout.renderSpread = this.__updateRenderSpread();
|
|
5460
|
-
if (layout.renderSpread) {
|
|
5461
|
-
if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
|
|
5462
|
-
layout.spreadRender();
|
|
5463
|
-
}
|
|
5464
|
-
this.__updateRenderBounds();
|
|
5465
|
-
this.__updateLocalRenderBounds();
|
|
5788
|
+
layout.localBoxChanged = false;
|
|
5789
|
+
if (layout.strokeSpread)
|
|
5790
|
+
layout.strokeChanged = true;
|
|
5791
|
+
if (layout.renderSpread)
|
|
5792
|
+
layout.renderChanged = true;
|
|
5793
|
+
if (this.parent)
|
|
5794
|
+
this.parent.__layout.boxChange();
|
|
5795
|
+
}
|
|
5796
|
+
if (layout.strokeChanged) {
|
|
5797
|
+
layout.strokeSpread = this.__updateStrokeSpread();
|
|
5798
|
+
if (layout.strokeSpread) {
|
|
5799
|
+
if (layout.strokeBounds === layout.boxBounds) {
|
|
5800
|
+
layout.spreadStroke();
|
|
5466
5801
|
}
|
|
5467
|
-
|
|
5468
|
-
|
|
5802
|
+
this.__updateStrokeBounds();
|
|
5803
|
+
this.__updateLocalStrokeBounds();
|
|
5804
|
+
}
|
|
5805
|
+
else {
|
|
5806
|
+
layout.spreadStrokeCancel();
|
|
5807
|
+
}
|
|
5808
|
+
layout.strokeChanged = false;
|
|
5809
|
+
if (layout.renderSpread)
|
|
5810
|
+
layout.renderChanged = true;
|
|
5811
|
+
if (this.parent)
|
|
5812
|
+
this.parent.__layout.strokeChange();
|
|
5813
|
+
layout.resized = true;
|
|
5814
|
+
}
|
|
5815
|
+
if (layout.renderChanged) {
|
|
5816
|
+
layout.renderSpread = this.__updateRenderSpread();
|
|
5817
|
+
if (layout.renderSpread) {
|
|
5818
|
+
if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
|
|
5819
|
+
layout.spreadRender();
|
|
5469
5820
|
}
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
this.parent.__layout.renderChange();
|
|
5821
|
+
this.__updateRenderBounds();
|
|
5822
|
+
this.__updateLocalRenderBounds();
|
|
5473
5823
|
}
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
toOuterOf(this.__layout.renderBounds, this.__world, this.__world);
|
|
5824
|
+
else {
|
|
5825
|
+
layout.spreadRenderCancel();
|
|
5826
|
+
}
|
|
5827
|
+
layout.renderChanged = false;
|
|
5828
|
+
if (this.parent)
|
|
5829
|
+
this.parent.__layout.renderChange();
|
|
5481
5830
|
}
|
|
5831
|
+
layout.boundsChanged = false;
|
|
5482
5832
|
},
|
|
5483
5833
|
__updateLocalBoxBounds() {
|
|
5834
|
+
if (this.__hasAutoLayout)
|
|
5835
|
+
this.__updateAutoLayout();
|
|
5484
5836
|
toOuterOf(this.__layout.boxBounds, this.__local, this.__local);
|
|
5485
5837
|
},
|
|
5486
5838
|
__updateLocalStrokeBounds() {
|
|
5487
|
-
toOuterOf(this.__layout.strokeBounds, this.
|
|
5839
|
+
toOuterOf(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
|
|
5488
5840
|
},
|
|
5489
5841
|
__updateLocalRenderBounds() {
|
|
5490
|
-
toOuterOf(this.__layout.renderBounds, this.
|
|
5842
|
+
toOuterOf(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
|
|
5491
5843
|
},
|
|
5492
5844
|
__updateBoxBounds() {
|
|
5493
5845
|
const b = this.__layout.boxBounds;
|
|
@@ -5497,14 +5849,27 @@ const LeafBounds = {
|
|
|
5497
5849
|
b.width = width;
|
|
5498
5850
|
b.height = height;
|
|
5499
5851
|
},
|
|
5852
|
+
__updateAutoLayout() {
|
|
5853
|
+
this.__layout.matrixChanged = true;
|
|
5854
|
+
if (this.isBranch) {
|
|
5855
|
+
if (this.leafer)
|
|
5856
|
+
this.leafer.layouter.addExtra(this);
|
|
5857
|
+
if (hasParentAutoLayout(this)) {
|
|
5858
|
+
updateMatrix$1(this);
|
|
5859
|
+
}
|
|
5860
|
+
else {
|
|
5861
|
+
updateAllMatrix$2(this);
|
|
5862
|
+
updateBounds$1(this, this);
|
|
5863
|
+
}
|
|
5864
|
+
}
|
|
5865
|
+
else {
|
|
5866
|
+
updateMatrix$1(this);
|
|
5867
|
+
}
|
|
5868
|
+
},
|
|
5500
5869
|
__updateNaturalSize() {
|
|
5501
5870
|
const { __: data, __layout: layout } = this;
|
|
5502
5871
|
data.__naturalWidth = layout.boxBounds.width;
|
|
5503
5872
|
data.__naturalHeight = layout.boxBounds.height;
|
|
5504
|
-
if (this.around) {
|
|
5505
|
-
layout.matrixChanged = true;
|
|
5506
|
-
this.__updateWorldMatrix();
|
|
5507
|
-
}
|
|
5508
5873
|
},
|
|
5509
5874
|
__updateStrokeBounds() {
|
|
5510
5875
|
copyAndSpread$1(this.__layout.strokeBounds, this.__layout.boxBounds, this.__layout.strokeSpread);
|
|
@@ -5547,7 +5912,7 @@ const LeafRender = {
|
|
|
5547
5912
|
const tempCanvas = canvas.getSameCanvas(true);
|
|
5548
5913
|
this.__draw(tempCanvas, options);
|
|
5549
5914
|
const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
|
|
5550
|
-
if (this.
|
|
5915
|
+
if (this.__worldFlipped || options.matrix) {
|
|
5551
5916
|
canvas.copyWorldByReset(tempCanvas, null, null, blendMode);
|
|
5552
5917
|
}
|
|
5553
5918
|
else {
|
|
@@ -5625,7 +5990,7 @@ const BranchRender = {
|
|
|
5625
5990
|
this.__renderBranch(tempCanvas, options);
|
|
5626
5991
|
canvas.opacity = this.__worldOpacity;
|
|
5627
5992
|
const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
|
|
5628
|
-
if (this.
|
|
5993
|
+
if (this.__worldFlipped || options.matrix) {
|
|
5629
5994
|
canvas.copyWorld(tempCanvas, null, null, blendMode);
|
|
5630
5995
|
}
|
|
5631
5996
|
else {
|
|
@@ -5643,8 +6008,8 @@ const BranchRender = {
|
|
|
5643
6008
|
const { children } = this;
|
|
5644
6009
|
if (this.__hasMask && children.length > 1) {
|
|
5645
6010
|
let mask;
|
|
5646
|
-
const maskCanvas = canvas.getSameCanvas();
|
|
5647
|
-
const contentCanvas = canvas.getSameCanvas();
|
|
6011
|
+
const maskCanvas = canvas.getSameCanvas(false, true);
|
|
6012
|
+
const contentCanvas = canvas.getSameCanvas(false, true);
|
|
5648
6013
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
5649
6014
|
child = children[i];
|
|
5650
6015
|
if (child.isMask) {
|
|
@@ -5678,7 +6043,7 @@ const BranchRender = {
|
|
|
5678
6043
|
const { LEAF, create } = IncrementId;
|
|
5679
6044
|
const { toInnerPoint, toOuterPoint } = MatrixHelper;
|
|
5680
6045
|
const { tempToOuterOf, copy: copy$3 } = PointHelper;
|
|
5681
|
-
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal } = LeafHelper;
|
|
6046
|
+
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, transform, setTransform, drop } = LeafHelper;
|
|
5682
6047
|
let Leaf = class Leaf {
|
|
5683
6048
|
get tag() { return this.__tag; }
|
|
5684
6049
|
set tag(_value) { }
|
|
@@ -5686,15 +6051,16 @@ let Leaf = class Leaf {
|
|
|
5686
6051
|
get innerName() { return this.__.name || this.tag + this.innerId; }
|
|
5687
6052
|
get __DataProcessor() { return LeafData; }
|
|
5688
6053
|
get __LayoutProcessor() { return LeafLayout; }
|
|
6054
|
+
get __localMatrix() { return this.__local || this.__layout; }
|
|
6055
|
+
get __localBounds() { return this.__local || this.__; }
|
|
5689
6056
|
get worldTransform() { return this.__layout.getTransform('world'); }
|
|
5690
6057
|
get localTransform() { return this.__layout.getTransform('local'); }
|
|
5691
6058
|
get boxBounds() { return this.getBounds('box', 'inner'); }
|
|
5692
6059
|
get worldBoxBounds() { return this.getBounds('box'); }
|
|
5693
6060
|
get worldStrokeBounds() { return this.getBounds('stroke'); }
|
|
5694
6061
|
get worldRenderBounds() { return this.getBounds('render'); }
|
|
5695
|
-
get worldOpacity() { this.__layout.
|
|
5696
|
-
get
|
|
5697
|
-
get __hasMirror() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
|
|
6062
|
+
get worldOpacity() { this.__layout.update(); return this.__worldOpacity; }
|
|
6063
|
+
get __worldFlipped() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
|
|
5698
6064
|
get __onlyHitMask() { return this.__hasMask && !this.__.hitChildren; }
|
|
5699
6065
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5700
6066
|
constructor(data) {
|
|
@@ -5703,20 +6069,15 @@ let Leaf = class Leaf {
|
|
|
5703
6069
|
}
|
|
5704
6070
|
reset(data) {
|
|
5705
6071
|
this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 };
|
|
5706
|
-
|
|
6072
|
+
if (data !== null)
|
|
6073
|
+
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
5707
6074
|
this.__worldOpacity = 1;
|
|
5708
6075
|
this.__ = new this.__DataProcessor(this);
|
|
5709
6076
|
this.__layout = new this.__LayoutProcessor(this);
|
|
5710
6077
|
if (this.__level)
|
|
5711
6078
|
this.resetCustom();
|
|
5712
|
-
if (data)
|
|
5713
|
-
|
|
5714
|
-
this.set(data);
|
|
5715
|
-
}
|
|
5716
|
-
else {
|
|
5717
|
-
Object.assign(this, data);
|
|
5718
|
-
}
|
|
5719
|
-
}
|
|
6079
|
+
if (data)
|
|
6080
|
+
data.children ? this.set(data) : Object.assign(this, data);
|
|
5720
6081
|
}
|
|
5721
6082
|
resetCustom() {
|
|
5722
6083
|
this.__hasMask = this.__hasEraser = null;
|
|
@@ -5753,7 +6114,7 @@ let Leaf = class Leaf {
|
|
|
5753
6114
|
}
|
|
5754
6115
|
}
|
|
5755
6116
|
set(_data) { }
|
|
5756
|
-
get(
|
|
6117
|
+
get() { return undefined; }
|
|
5757
6118
|
toJSON() {
|
|
5758
6119
|
return this.__.__getInputData();
|
|
5759
6120
|
}
|
|
@@ -5764,8 +6125,8 @@ let Leaf = class Leaf {
|
|
|
5764
6125
|
__getAttr(_attrName) { return undefined; }
|
|
5765
6126
|
setProxyAttr(_attrName, _newValue) { }
|
|
5766
6127
|
getProxyAttr(_attrName) { return undefined; }
|
|
5767
|
-
find(_condition) { return undefined; }
|
|
5768
|
-
findOne(_condition) { return undefined; }
|
|
6128
|
+
find(_condition, _options) { return undefined; }
|
|
6129
|
+
findOne(_condition, _options) { return undefined; }
|
|
5769
6130
|
forceUpdate(attrName) {
|
|
5770
6131
|
if (attrName === undefined)
|
|
5771
6132
|
attrName = 'width';
|
|
@@ -5775,15 +6136,20 @@ let Leaf = class Leaf {
|
|
|
5775
6136
|
this.__[attrName] = value === undefined ? null : undefined;
|
|
5776
6137
|
this[attrName] = value;
|
|
5777
6138
|
}
|
|
6139
|
+
updateLayout() {
|
|
6140
|
+
this.__layout.update();
|
|
6141
|
+
}
|
|
5778
6142
|
__updateWorldMatrix() { }
|
|
5779
6143
|
__updateLocalMatrix() { }
|
|
5780
6144
|
__updateWorldBounds() { }
|
|
6145
|
+
__updateLocalBounds() { }
|
|
5781
6146
|
__updateLocalBoxBounds() { }
|
|
5782
6147
|
__updateLocalStrokeBounds() { }
|
|
5783
6148
|
__updateLocalRenderBounds() { }
|
|
5784
6149
|
__updateBoxBounds() { }
|
|
5785
6150
|
__updateStrokeBounds() { }
|
|
5786
6151
|
__updateRenderBounds() { }
|
|
6152
|
+
__updateAutoLayout() { }
|
|
5787
6153
|
__updateNaturalSize() { }
|
|
5788
6154
|
__updateStrokeSpread() { return 0; }
|
|
5789
6155
|
__updateRenderSpread() { return 0; }
|
|
@@ -5793,15 +6159,21 @@ let Leaf = class Leaf {
|
|
|
5793
6159
|
__renderMask(_canvas, _content, _mask, _recycle) { }
|
|
5794
6160
|
__removeMask(_child) { }
|
|
5795
6161
|
getWorld(attrName) {
|
|
5796
|
-
this.__layout.
|
|
6162
|
+
this.__layout.update();
|
|
5797
6163
|
if (attrName === 'x')
|
|
5798
6164
|
return this.__world.e;
|
|
5799
6165
|
if (attrName === 'y')
|
|
5800
6166
|
return this.__world.f;
|
|
5801
6167
|
return this.__world[attrName];
|
|
5802
6168
|
}
|
|
5803
|
-
getBounds(type,
|
|
5804
|
-
return this.__layout.getBounds(type,
|
|
6169
|
+
getBounds(type, relative) {
|
|
6170
|
+
return this.__layout.getBounds(type, relative);
|
|
6171
|
+
}
|
|
6172
|
+
getLayoutBounds(type, relative, unscale) {
|
|
6173
|
+
return this.__layout.getLayoutBounds(type, relative, unscale);
|
|
6174
|
+
}
|
|
6175
|
+
getLayoutPoints(type, relative) {
|
|
6176
|
+
return this.__layout.getLayoutPoints(type, relative);
|
|
5805
6177
|
}
|
|
5806
6178
|
worldToLocal(world, to, distance, relative) {
|
|
5807
6179
|
if (this.parent) {
|
|
@@ -5859,17 +6231,43 @@ let Leaf = class Leaf {
|
|
|
5859
6231
|
this.localToWorld(local, point, distance, relative);
|
|
5860
6232
|
return point;
|
|
5861
6233
|
}
|
|
6234
|
+
setTransform(matrix, resize) {
|
|
6235
|
+
setTransform(this, matrix, resize);
|
|
6236
|
+
}
|
|
6237
|
+
transform(matrix, resize) {
|
|
6238
|
+
transform(this, matrix, resize);
|
|
6239
|
+
}
|
|
5862
6240
|
move(x, y) {
|
|
5863
6241
|
moveLocal(this, x, y);
|
|
5864
6242
|
}
|
|
5865
|
-
scaleOf(origin,
|
|
5866
|
-
zoomOfLocal(this, tempToOuterOf(origin, this.localTransform),
|
|
6243
|
+
scaleOf(origin, scaleX, scaleY, resize) {
|
|
6244
|
+
zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), scaleX, scaleY, resize);
|
|
5867
6245
|
}
|
|
5868
|
-
rotateOf(origin,
|
|
5869
|
-
rotateOfLocal(this, tempToOuterOf(origin, this.localTransform),
|
|
6246
|
+
rotateOf(origin, rotation) {
|
|
6247
|
+
rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), rotation);
|
|
6248
|
+
}
|
|
6249
|
+
skewOf(origin, skewX, skewY, resize) {
|
|
6250
|
+
skewOfLocal(this, tempToOuterOf(origin, this.localTransform), skewX, skewY, resize);
|
|
6251
|
+
}
|
|
6252
|
+
scaleResize(scaleX, scaleY = scaleX, noResize) {
|
|
6253
|
+
const data = this;
|
|
6254
|
+
if (noResize) {
|
|
6255
|
+
data.scaleX *= scaleX;
|
|
6256
|
+
data.scaleY *= scaleY;
|
|
6257
|
+
}
|
|
6258
|
+
else {
|
|
6259
|
+
if (scaleX < 0)
|
|
6260
|
+
data.scaleX *= -1, scaleX = -scaleX;
|
|
6261
|
+
if (scaleY < 0)
|
|
6262
|
+
data.scaleY *= -1, scaleY = -scaleY;
|
|
6263
|
+
this.__scaleResize(scaleX, scaleY);
|
|
6264
|
+
}
|
|
5870
6265
|
}
|
|
5871
|
-
|
|
5872
|
-
|
|
6266
|
+
__scaleResize(scaleX, scaleY) {
|
|
6267
|
+
if (scaleX !== 1)
|
|
6268
|
+
this.width *= scaleX;
|
|
6269
|
+
if (scaleY !== 1)
|
|
6270
|
+
this.height *= scaleY;
|
|
5873
6271
|
}
|
|
5874
6272
|
__hitWorld(_point) { return true; }
|
|
5875
6273
|
__hit(_local) { return true; }
|
|
@@ -5891,6 +6289,9 @@ let Leaf = class Leaf {
|
|
|
5891
6289
|
if (this.parent)
|
|
5892
6290
|
this.parent.remove(this, destroy);
|
|
5893
6291
|
}
|
|
6292
|
+
dropTo(parent, index, resize) {
|
|
6293
|
+
drop(this, parent, index, resize);
|
|
6294
|
+
}
|
|
5894
6295
|
on(_type, _listener, _options) { }
|
|
5895
6296
|
off(_type, _listener, _options) { }
|
|
5896
6297
|
on_(_type, _listener, _bind, _options) { return undefined; }
|
|
@@ -5899,6 +6300,14 @@ let Leaf = class Leaf {
|
|
|
5899
6300
|
emit(_type, _event, _capture) { }
|
|
5900
6301
|
emitEvent(_event, _capture) { }
|
|
5901
6302
|
hasEvent(_type, _capture) { return false; }
|
|
6303
|
+
static changeAttr(attrName, defaultValue) {
|
|
6304
|
+
defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
6305
|
+
}
|
|
6306
|
+
static addAttr(attrName, defaultValue, fn) {
|
|
6307
|
+
if (!fn)
|
|
6308
|
+
fn = boundsType;
|
|
6309
|
+
fn(defaultValue)(this.prototype, attrName);
|
|
6310
|
+
}
|
|
5902
6311
|
destroy() {
|
|
5903
6312
|
if (!this.destroyed) {
|
|
5904
6313
|
if (this.parent)
|
|
@@ -5921,9 +6330,9 @@ Leaf = __decorate([
|
|
|
5921
6330
|
useModule(LeafRender)
|
|
5922
6331
|
], Leaf);
|
|
5923
6332
|
|
|
5924
|
-
const {
|
|
6333
|
+
const { setListWithFn } = BoundsHelper;
|
|
5925
6334
|
const { sort } = BranchHelper;
|
|
5926
|
-
const { localBoxBounds,
|
|
6335
|
+
const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
|
|
5927
6336
|
let Branch = class Branch extends Leaf {
|
|
5928
6337
|
constructor() {
|
|
5929
6338
|
super();
|
|
@@ -5947,13 +6356,13 @@ let Branch = class Branch extends Leaf {
|
|
|
5947
6356
|
return 0;
|
|
5948
6357
|
}
|
|
5949
6358
|
__updateBoxBounds() {
|
|
5950
|
-
|
|
6359
|
+
setListWithFn(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds);
|
|
5951
6360
|
}
|
|
5952
6361
|
__updateStrokeBounds() {
|
|
5953
|
-
|
|
6362
|
+
setListWithFn(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalStrokeBounds : localStrokeBounds);
|
|
5954
6363
|
}
|
|
5955
6364
|
__updateRenderBounds() {
|
|
5956
|
-
|
|
6365
|
+
setListWithFn(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds);
|
|
5957
6366
|
}
|
|
5958
6367
|
__updateSortChildren() {
|
|
5959
6368
|
let affectSort;
|
|
@@ -6099,7 +6508,7 @@ class Watcher {
|
|
|
6099
6508
|
if (this.hasRemove) {
|
|
6100
6509
|
const updatedList = new LeafList();
|
|
6101
6510
|
this.__updatedList.list.forEach(item => { if (item.leafer)
|
|
6102
|
-
updatedList.
|
|
6511
|
+
updatedList.add(item); });
|
|
6103
6512
|
return updatedList;
|
|
6104
6513
|
}
|
|
6105
6514
|
else {
|
|
@@ -6134,7 +6543,7 @@ class Watcher {
|
|
|
6134
6543
|
this.target.emit(RenderEvent.REQUEST);
|
|
6135
6544
|
}
|
|
6136
6545
|
__onAttrChange(event) {
|
|
6137
|
-
this.__updatedList.
|
|
6546
|
+
this.__updatedList.add(event.target);
|
|
6138
6547
|
this.update();
|
|
6139
6548
|
}
|
|
6140
6549
|
__onChildEvent(event) {
|
|
@@ -6144,12 +6553,12 @@ class Watcher {
|
|
|
6144
6553
|
}
|
|
6145
6554
|
else {
|
|
6146
6555
|
this.hasRemove = true;
|
|
6147
|
-
this.__updatedList.
|
|
6556
|
+
this.__updatedList.add(event.parent);
|
|
6148
6557
|
}
|
|
6149
6558
|
this.update();
|
|
6150
6559
|
}
|
|
6151
6560
|
__pushChild(child) {
|
|
6152
|
-
this.__updatedList.
|
|
6561
|
+
this.__updatedList.add(child);
|
|
6153
6562
|
if (child.isBranch)
|
|
6154
6563
|
this.__loopChildren(child);
|
|
6155
6564
|
}
|
|
@@ -6188,7 +6597,7 @@ class Watcher {
|
|
|
6188
6597
|
}
|
|
6189
6598
|
}
|
|
6190
6599
|
|
|
6191
|
-
const {
|
|
6600
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
|
|
6192
6601
|
const { pushAllChildBranch, pushAllParent } = BranchHelper;
|
|
6193
6602
|
function updateMatrix(updateList, levelList) {
|
|
6194
6603
|
let layout;
|
|
@@ -6196,14 +6605,14 @@ function updateMatrix(updateList, levelList) {
|
|
|
6196
6605
|
layout = leaf.__layout;
|
|
6197
6606
|
if (levelList.without(leaf) && !layout.proxyZoom) {
|
|
6198
6607
|
if (layout.matrixChanged) {
|
|
6199
|
-
|
|
6200
|
-
levelList.
|
|
6608
|
+
updateAllMatrix$1(leaf, true);
|
|
6609
|
+
levelList.add(leaf);
|
|
6201
6610
|
if (leaf.isBranch)
|
|
6202
6611
|
pushAllChildBranch(leaf, levelList);
|
|
6203
6612
|
pushAllParent(leaf, levelList);
|
|
6204
6613
|
}
|
|
6205
6614
|
else if (layout.boundsChanged) {
|
|
6206
|
-
levelList.
|
|
6615
|
+
levelList.add(leaf);
|
|
6207
6616
|
if (leaf.isBranch)
|
|
6208
6617
|
leaf.__tempNumber = 0;
|
|
6209
6618
|
pushAllParent(leaf, levelList);
|
|
@@ -6212,20 +6621,21 @@ function updateMatrix(updateList, levelList) {
|
|
|
6212
6621
|
});
|
|
6213
6622
|
}
|
|
6214
6623
|
function updateBounds(boundsList) {
|
|
6215
|
-
let
|
|
6624
|
+
let list, branch, children;
|
|
6216
6625
|
boundsList.sort(true);
|
|
6217
6626
|
boundsList.levels.forEach(level => {
|
|
6218
|
-
|
|
6219
|
-
for (let i = 0, len =
|
|
6220
|
-
branch =
|
|
6627
|
+
list = boundsList.levelMap[level];
|
|
6628
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
6629
|
+
branch = list[i];
|
|
6221
6630
|
if (branch.isBranch && branch.__tempNumber) {
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6631
|
+
children = branch.children;
|
|
6632
|
+
for (let j = 0, jLen = children.length; j < jLen; j++) {
|
|
6633
|
+
if (!children[j].isBranch) {
|
|
6634
|
+
updateOneBounds(children[j]);
|
|
6225
6635
|
}
|
|
6226
6636
|
}
|
|
6227
6637
|
}
|
|
6228
|
-
branch
|
|
6638
|
+
updateOneBounds(branch);
|
|
6229
6639
|
}
|
|
6230
6640
|
});
|
|
6231
6641
|
}
|
|
@@ -6238,7 +6648,7 @@ function updateChange(updateList) {
|
|
|
6238
6648
|
}
|
|
6239
6649
|
|
|
6240
6650
|
const { worldBounds } = LeafBoundsHelper;
|
|
6241
|
-
const {
|
|
6651
|
+
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
6242
6652
|
class LayoutBlockData {
|
|
6243
6653
|
constructor(list) {
|
|
6244
6654
|
this.updatedBounds = new Bounds();
|
|
@@ -6249,14 +6659,20 @@ class LayoutBlockData {
|
|
|
6249
6659
|
this.updatedList = list;
|
|
6250
6660
|
}
|
|
6251
6661
|
setBefore() {
|
|
6252
|
-
|
|
6662
|
+
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
6253
6663
|
}
|
|
6254
6664
|
setAfter() {
|
|
6255
|
-
|
|
6256
|
-
|
|
6665
|
+
const { list } = this.updatedList;
|
|
6666
|
+
if (list.some(leaf => leaf.noBounds)) {
|
|
6667
|
+
this.afterBounds.set(bigBounds);
|
|
6668
|
+
}
|
|
6669
|
+
else {
|
|
6670
|
+
this.afterBounds.setListWithFn(list, worldBounds);
|
|
6671
|
+
}
|
|
6672
|
+
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
6257
6673
|
}
|
|
6258
6674
|
merge(data) {
|
|
6259
|
-
this.updatedList.
|
|
6675
|
+
this.updatedList.addList(data.updatedList.list);
|
|
6260
6676
|
this.beforeBounds.add(data.beforeBounds);
|
|
6261
6677
|
this.afterBounds.add(data.afterBounds);
|
|
6262
6678
|
this.updatedBounds.add(data.updatedBounds);
|
|
@@ -6266,8 +6682,7 @@ class LayoutBlockData {
|
|
|
6266
6682
|
}
|
|
6267
6683
|
}
|
|
6268
6684
|
|
|
6269
|
-
const {
|
|
6270
|
-
const { pushAllBranchStack, updateWorldBoundsByBranchStack } = BranchHelper;
|
|
6685
|
+
const { updateAllMatrix, updateAllChange } = LeafHelper;
|
|
6271
6686
|
const debug$5 = Debug.get('Layouter');
|
|
6272
6687
|
class Layouter {
|
|
6273
6688
|
constructor(target, userConfig) {
|
|
@@ -6344,12 +6759,15 @@ class Layouter {
|
|
|
6344
6759
|
const { target, __updatedList: updateList } = this;
|
|
6345
6760
|
const { BEFORE, LAYOUT, AFTER } = LayoutEvent;
|
|
6346
6761
|
const blocks = this.getBlocks(updateList);
|
|
6347
|
-
blocks.forEach(item =>
|
|
6762
|
+
blocks.forEach(item => item.setBefore());
|
|
6348
6763
|
target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
|
|
6764
|
+
this.extraBlock = null;
|
|
6349
6765
|
updateList.sort();
|
|
6350
6766
|
updateMatrix(updateList, this.__levelList);
|
|
6351
6767
|
updateBounds(this.__levelList);
|
|
6352
6768
|
updateChange(updateList);
|
|
6769
|
+
if (this.extraBlock)
|
|
6770
|
+
blocks.push(this.extraBlock);
|
|
6353
6771
|
blocks.forEach(item => item.setAfter());
|
|
6354
6772
|
target.emitEvent(new LayoutEvent(LAYOUT, blocks, this.times));
|
|
6355
6773
|
target.emitEvent(new LayoutEvent(AFTER, blocks, this.times));
|
|
@@ -6372,17 +6790,20 @@ class Layouter {
|
|
|
6372
6790
|
Run.end(t);
|
|
6373
6791
|
}
|
|
6374
6792
|
static fullLayout(target) {
|
|
6375
|
-
|
|
6793
|
+
updateAllMatrix(target, true);
|
|
6376
6794
|
if (target.isBranch) {
|
|
6377
|
-
|
|
6378
|
-
pushAllBranchStack(target, branchStack);
|
|
6379
|
-
updateWorldBoundsByBranchStack(branchStack);
|
|
6795
|
+
BranchHelper.updateBounds(target);
|
|
6380
6796
|
}
|
|
6381
6797
|
else {
|
|
6382
|
-
|
|
6798
|
+
LeafHelper.updateBounds(target);
|
|
6383
6799
|
}
|
|
6384
6800
|
updateAllChange(target);
|
|
6385
6801
|
}
|
|
6802
|
+
addExtra(leaf) {
|
|
6803
|
+
const block = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
|
|
6804
|
+
block.updatedList.add(leaf);
|
|
6805
|
+
block.beforeBounds.add(leaf.__world);
|
|
6806
|
+
}
|
|
6386
6807
|
createBlock(data) {
|
|
6387
6808
|
return new LayoutBlockData(data);
|
|
6388
6809
|
}
|
|
@@ -6410,8 +6831,7 @@ class Layouter {
|
|
|
6410
6831
|
if (this.target) {
|
|
6411
6832
|
this.stop();
|
|
6412
6833
|
this.__removeListenEvents();
|
|
6413
|
-
this.target = null;
|
|
6414
|
-
this.config = null;
|
|
6834
|
+
this.target = this.config = null;
|
|
6415
6835
|
}
|
|
6416
6836
|
}
|
|
6417
6837
|
}
|
|
@@ -6522,7 +6942,7 @@ class Renderer {
|
|
|
6522
6942
|
const { canvas } = this;
|
|
6523
6943
|
const bounds = block.getIntersect(canvas.bounds);
|
|
6524
6944
|
const includes = block.includes(this.target.__world);
|
|
6525
|
-
const realBounds = new Bounds(
|
|
6945
|
+
const realBounds = new Bounds(bounds);
|
|
6526
6946
|
canvas.save();
|
|
6527
6947
|
if (includes && !Debug.showRepaint) {
|
|
6528
6948
|
canvas.clear();
|
|
@@ -6572,7 +6992,7 @@ class Renderer {
|
|
|
6572
6992
|
const { updateBlocks: list } = this;
|
|
6573
6993
|
if (list) {
|
|
6574
6994
|
const bounds = new Bounds();
|
|
6575
|
-
bounds.
|
|
6995
|
+
bounds.setList(list);
|
|
6576
6996
|
list.length = 0;
|
|
6577
6997
|
list.push(bounds);
|
|
6578
6998
|
}
|
|
@@ -6612,7 +7032,7 @@ class Renderer {
|
|
|
6612
7032
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
6613
7033
|
if (empty) {
|
|
6614
7034
|
if (!leaf.isLeafer)
|
|
6615
|
-
debug$4.
|
|
7035
|
+
debug$4.tip(leaf.innerName, ': empty');
|
|
6616
7036
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
6617
7037
|
}
|
|
6618
7038
|
return empty;
|
|
@@ -6646,6 +7066,14 @@ class Renderer {
|
|
|
6646
7066
|
}
|
|
6647
7067
|
}
|
|
6648
7068
|
|
|
7069
|
+
var AnswerType;
|
|
7070
|
+
(function (AnswerType) {
|
|
7071
|
+
AnswerType[AnswerType["No"] = 0] = "No";
|
|
7072
|
+
AnswerType[AnswerType["Yes"] = 1] = "Yes";
|
|
7073
|
+
AnswerType[AnswerType["NoAndSkip"] = 2] = "NoAndSkip";
|
|
7074
|
+
AnswerType[AnswerType["YesAndSkip"] = 3] = "YesAndSkip";
|
|
7075
|
+
})(AnswerType || (AnswerType = {}));
|
|
7076
|
+
|
|
6649
7077
|
const { hitRadiusPoint } = BoundsHelper;
|
|
6650
7078
|
class Pather {
|
|
6651
7079
|
constructor(target, selector) {
|
|
@@ -6690,10 +7118,10 @@ class Pather {
|
|
|
6690
7118
|
getPath(leaf) {
|
|
6691
7119
|
const path = new LeafList();
|
|
6692
7120
|
while (leaf) {
|
|
6693
|
-
path.
|
|
7121
|
+
path.add(leaf);
|
|
6694
7122
|
leaf = leaf.parent;
|
|
6695
7123
|
}
|
|
6696
|
-
path.
|
|
7124
|
+
path.add(this.target);
|
|
6697
7125
|
return path;
|
|
6698
7126
|
}
|
|
6699
7127
|
getHitablePath(leaf) {
|
|
@@ -6703,7 +7131,7 @@ class Pather {
|
|
|
6703
7131
|
item = path.list[i];
|
|
6704
7132
|
if (!item.__.hittable)
|
|
6705
7133
|
break;
|
|
6706
|
-
hittablePath.
|
|
7134
|
+
hittablePath.addAt(item, 0);
|
|
6707
7135
|
if (!item.__.hitChildren)
|
|
6708
7136
|
break;
|
|
6709
7137
|
}
|
|
@@ -6722,7 +7150,7 @@ class Pather {
|
|
|
6722
7150
|
leaf = path.list[j];
|
|
6723
7151
|
if (nextPath && nextPath.has(leaf))
|
|
6724
7152
|
break;
|
|
6725
|
-
throughPath.
|
|
7153
|
+
throughPath.add(leaf);
|
|
6726
7154
|
}
|
|
6727
7155
|
}
|
|
6728
7156
|
return throughPath;
|
|
@@ -6764,14 +7192,15 @@ class Pather {
|
|
|
6764
7192
|
}
|
|
6765
7193
|
}
|
|
6766
7194
|
|
|
7195
|
+
const { Yes, NoAndSkip, YesAndSkip } = AnswerType;
|
|
6767
7196
|
class Selector {
|
|
6768
7197
|
constructor(target, userConfig) {
|
|
6769
7198
|
this.config = {};
|
|
6770
7199
|
this.innerIdMap = {};
|
|
6771
7200
|
this.idMap = {};
|
|
6772
7201
|
this.methods = {
|
|
6773
|
-
id: (leaf, name) => leaf.id === name ? this.idMap[name] = leaf : 0,
|
|
6774
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? this.innerIdMap[innerId] = leaf : 0,
|
|
7202
|
+
id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
|
|
7203
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
|
|
6775
7204
|
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
6776
7205
|
tag: (leaf, name) => leaf.__tag === name ? 1 : 0
|
|
6777
7206
|
};
|
|
@@ -6781,11 +7210,6 @@ class Selector {
|
|
|
6781
7210
|
this.pather = new Pather(target, this);
|
|
6782
7211
|
this.__listenEvents();
|
|
6783
7212
|
}
|
|
6784
|
-
getByPoint(hitPoint, hitRadius, options) {
|
|
6785
|
-
if (Platform.name === 'node')
|
|
6786
|
-
this.target.emit(LayoutEvent.CHECK_UPDATE);
|
|
6787
|
-
return this.pather.getByPoint(hitPoint, hitRadius, options);
|
|
6788
|
-
}
|
|
6789
7213
|
getBy(condition, branch, one, options) {
|
|
6790
7214
|
switch (typeof condition) {
|
|
6791
7215
|
case 'number':
|
|
@@ -6805,6 +7229,11 @@ class Selector {
|
|
|
6805
7229
|
return this.getByMethod(condition, branch, one, options);
|
|
6806
7230
|
}
|
|
6807
7231
|
}
|
|
7232
|
+
getByPoint(hitPoint, hitRadius, options) {
|
|
7233
|
+
if (Platform.name === 'node')
|
|
7234
|
+
this.target.emit(LayoutEvent.CHECK_UPDATE);
|
|
7235
|
+
return this.pather.getByPoint(hitPoint, hitRadius, options);
|
|
7236
|
+
}
|
|
6808
7237
|
getByInnerId(innerId, branch) {
|
|
6809
7238
|
const cache = this.innerIdMap[innerId];
|
|
6810
7239
|
if (cache)
|
|
@@ -6831,10 +7260,11 @@ class Selector {
|
|
|
6831
7260
|
return list || this.findLeaf;
|
|
6832
7261
|
}
|
|
6833
7262
|
eachFind(children, method, list, options) {
|
|
6834
|
-
let child;
|
|
7263
|
+
let child, result;
|
|
6835
7264
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
6836
7265
|
child = children[i];
|
|
6837
|
-
|
|
7266
|
+
result = method(child, options);
|
|
7267
|
+
if (result === Yes || result === YesAndSkip) {
|
|
6838
7268
|
if (list) {
|
|
6839
7269
|
list.push(child);
|
|
6840
7270
|
}
|
|
@@ -6843,7 +7273,7 @@ class Selector {
|
|
|
6843
7273
|
return;
|
|
6844
7274
|
}
|
|
6845
7275
|
}
|
|
6846
|
-
if (child.isBranch)
|
|
7276
|
+
if (child.isBranch && result < NoAndSkip)
|
|
6847
7277
|
this.eachFind(child.children, method, list, options);
|
|
6848
7278
|
}
|
|
6849
7279
|
}
|
|
@@ -7414,8 +7844,8 @@ function useCanvas(_canvasType, _power) {
|
|
|
7414
7844
|
img.crossOrigin = 'anonymous';
|
|
7415
7845
|
img.onload = () => { resolve(img); };
|
|
7416
7846
|
img.onerror = (e) => { reject(e); };
|
|
7417
|
-
if (!src.startsWith('data:') && Platform.
|
|
7418
|
-
src += (src.includes("?") ? "&" : "?") + Platform.
|
|
7847
|
+
if (!src.startsWith('data:') && Platform.image.suffix)
|
|
7848
|
+
src += (src.includes("?") ? "&" : "?") + Platform.image.suffix;
|
|
7419
7849
|
img.src = src;
|
|
7420
7850
|
});
|
|
7421
7851
|
}
|
|
@@ -7431,8 +7861,7 @@ function useCanvas(_canvasType, _power) {
|
|
|
7431
7861
|
Platform.name = 'web';
|
|
7432
7862
|
Platform.isMobile = 'ontouchstart' in window;
|
|
7433
7863
|
Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
|
|
7434
|
-
Platform.devicePixelRatio = devicePixelRatio;
|
|
7435
|
-
Platform.realtimeLayout = true;
|
|
7864
|
+
Platform.devicePixelRatio = Math.max(1, devicePixelRatio);
|
|
7436
7865
|
const { userAgent } = navigator;
|
|
7437
7866
|
if (userAgent.indexOf("Firefox") > -1) {
|
|
7438
7867
|
Platform.conicGradientRotate90 = true;
|
|
@@ -7462,7 +7891,7 @@ function design(leafer) {
|
|
|
7462
7891
|
if (leafer.isApp)
|
|
7463
7892
|
return;
|
|
7464
7893
|
leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => { LeafHelper.moveWorld(leafer.zoomLayer, e.moveX, e.moveY); }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
|
|
7465
|
-
const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.config.zoom;
|
|
7894
|
+
const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.app.config.zoom;
|
|
7466
7895
|
let { scale } = e;
|
|
7467
7896
|
if (scale * Math.abs(scaleX) < min)
|
|
7468
7897
|
scale = min / scaleX;
|
|
@@ -7509,6 +7938,9 @@ const Export$1 = {};
|
|
|
7509
7938
|
const emptyPaint = {};
|
|
7510
7939
|
const debug$1 = Debug.get('UIData');
|
|
7511
7940
|
class UIData extends LeafData {
|
|
7941
|
+
get __autoWidth() { return !this._width; }
|
|
7942
|
+
get __autoHeight() { return !this._height; }
|
|
7943
|
+
get __autoBounds() { return !this._width && !this._height; }
|
|
7512
7944
|
setVisible(value) {
|
|
7513
7945
|
if (this.__leaf.leafer)
|
|
7514
7946
|
this.__leaf.leafer.watcher.hasVisible = true;
|
|
@@ -7685,6 +8117,9 @@ class TextData extends UIData {
|
|
|
7685
8117
|
class ImageData extends RectData {
|
|
7686
8118
|
}
|
|
7687
8119
|
|
|
8120
|
+
class CanvasData extends RectData {
|
|
8121
|
+
}
|
|
8122
|
+
|
|
7688
8123
|
function effectType(defaultValue) {
|
|
7689
8124
|
return (target, key) => {
|
|
7690
8125
|
defineLeafAttr(target, key, defaultValue, {
|
|
@@ -7895,6 +8330,7 @@ const RectRender = {
|
|
|
7895
8330
|
|
|
7896
8331
|
var UI_1;
|
|
7897
8332
|
let UI = UI_1 = class UI extends Leaf {
|
|
8333
|
+
get app() { return this.leafer && this.leafer.app; }
|
|
7898
8334
|
set scale(value) {
|
|
7899
8335
|
if (typeof value === 'number') {
|
|
7900
8336
|
this.scaleX = this.scaleY = value;
|
|
@@ -7908,22 +8344,25 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7908
8344
|
const { scaleX, scaleY } = this;
|
|
7909
8345
|
return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
|
|
7910
8346
|
}
|
|
8347
|
+
constructor(data) {
|
|
8348
|
+
super(data);
|
|
8349
|
+
}
|
|
7911
8350
|
reset(_data) { }
|
|
7912
8351
|
set(data) {
|
|
7913
8352
|
Object.assign(this, data);
|
|
7914
8353
|
}
|
|
7915
|
-
get(
|
|
7916
|
-
return this.__.__getInputData(
|
|
8354
|
+
get() {
|
|
8355
|
+
return this.__.__getInputData();
|
|
7917
8356
|
}
|
|
7918
|
-
|
|
7919
|
-
find(condition) {
|
|
7920
|
-
return this.leafer ? this.leafer.selector.getBy(condition, this) : [];
|
|
8357
|
+
createProxyData() { return undefined; }
|
|
8358
|
+
find(condition, options) {
|
|
8359
|
+
return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
|
|
7921
8360
|
}
|
|
7922
|
-
findOne(condition) {
|
|
7923
|
-
return this.leafer ? this.leafer.selector.getBy(condition, this, true) : null;
|
|
8361
|
+
findOne(condition, options) {
|
|
8362
|
+
return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
|
|
7924
8363
|
}
|
|
7925
8364
|
getPath(curve) {
|
|
7926
|
-
const path = this.__
|
|
8365
|
+
const { path } = this.__;
|
|
7927
8366
|
if (!path)
|
|
7928
8367
|
return [];
|
|
7929
8368
|
return curve ? PathConvert.toCanvasData(path, true) : path;
|
|
@@ -7955,6 +8394,15 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7955
8394
|
this.__drawPathByData(canvas, this.__.path);
|
|
7956
8395
|
}
|
|
7957
8396
|
__drawPathByData(_drawer, _data) { }
|
|
8397
|
+
__drawPathByBox(drawer) {
|
|
8398
|
+
const { x, y, width, height } = this.__layout.boxBounds;
|
|
8399
|
+
if (this.__.cornerRadius) {
|
|
8400
|
+
drawer.roundRect(x, y, width, height, this.__.cornerRadius);
|
|
8401
|
+
}
|
|
8402
|
+
else {
|
|
8403
|
+
drawer.rect(x, y, width, height);
|
|
8404
|
+
}
|
|
8405
|
+
}
|
|
7958
8406
|
export(filename, options) {
|
|
7959
8407
|
return Export$1.export(this, filename, options);
|
|
7960
8408
|
}
|
|
@@ -7996,12 +8444,12 @@ __decorate([
|
|
|
7996
8444
|
__decorate([
|
|
7997
8445
|
eraserType(false)
|
|
7998
8446
|
], UI.prototype, "isEraser", void 0);
|
|
8447
|
+
__decorate([
|
|
8448
|
+
dataType(false)
|
|
8449
|
+
], UI.prototype, "locked", void 0);
|
|
7999
8450
|
__decorate([
|
|
8000
8451
|
sortType(0)
|
|
8001
8452
|
], UI.prototype, "zIndex", void 0);
|
|
8002
|
-
__decorate([
|
|
8003
|
-
dataType()
|
|
8004
|
-
], UI.prototype, "locked", void 0);
|
|
8005
8453
|
__decorate([
|
|
8006
8454
|
positionType(0)
|
|
8007
8455
|
], UI.prototype, "x", void 0);
|
|
@@ -8030,11 +8478,17 @@ __decorate([
|
|
|
8030
8478
|
rotationType(0)
|
|
8031
8479
|
], UI.prototype, "skewY", void 0);
|
|
8032
8480
|
__decorate([
|
|
8033
|
-
|
|
8481
|
+
autoLayoutType()
|
|
8034
8482
|
], UI.prototype, "around", void 0);
|
|
8035
8483
|
__decorate([
|
|
8036
8484
|
dataType(false)
|
|
8037
8485
|
], UI.prototype, "draggable", void 0);
|
|
8486
|
+
__decorate([
|
|
8487
|
+
dataType(false)
|
|
8488
|
+
], UI.prototype, "editable", void 0);
|
|
8489
|
+
__decorate([
|
|
8490
|
+
dataType('size')
|
|
8491
|
+
], UI.prototype, "editSize", void 0);
|
|
8038
8492
|
__decorate([
|
|
8039
8493
|
hitType(true)
|
|
8040
8494
|
], UI.prototype, "hittable", void 0);
|
|
@@ -8087,7 +8541,7 @@ __decorate([
|
|
|
8087
8541
|
strokeType(10)
|
|
8088
8542
|
], UI.prototype, "miterLimit", void 0);
|
|
8089
8543
|
__decorate([
|
|
8090
|
-
pathType()
|
|
8544
|
+
pathType(0)
|
|
8091
8545
|
], UI.prototype, "cornerRadius", void 0);
|
|
8092
8546
|
__decorate([
|
|
8093
8547
|
pathType()
|
|
@@ -8120,9 +8574,9 @@ UI = UI_1 = __decorate([
|
|
|
8120
8574
|
rewriteAble()
|
|
8121
8575
|
], UI);
|
|
8122
8576
|
|
|
8577
|
+
const matrix = MatrixHelper.get();
|
|
8123
8578
|
let Group = class Group extends UI {
|
|
8124
8579
|
get __tag() { return 'Group'; }
|
|
8125
|
-
get resizeable() { return false; }
|
|
8126
8580
|
set mask(child) {
|
|
8127
8581
|
if (this.__hasMask)
|
|
8128
8582
|
this.__removeMask();
|
|
@@ -8170,6 +8624,14 @@ let Group = class Group extends UI {
|
|
|
8170
8624
|
data.children = this.children.map(child => child.toJSON());
|
|
8171
8625
|
return data;
|
|
8172
8626
|
}
|
|
8627
|
+
__scaleResize(scaleX, scaleY) {
|
|
8628
|
+
const { children } = this;
|
|
8629
|
+
for (let i = 0; i < children.length; i++) {
|
|
8630
|
+
matrix.a = scaleX;
|
|
8631
|
+
matrix.d = scaleY;
|
|
8632
|
+
children[i].transform(matrix, true);
|
|
8633
|
+
}
|
|
8634
|
+
}
|
|
8173
8635
|
addAt(child, index) {
|
|
8174
8636
|
this.add(child, index);
|
|
8175
8637
|
}
|
|
@@ -8197,21 +8659,17 @@ let Rect = class Rect extends UI {
|
|
|
8197
8659
|
constructor(data) {
|
|
8198
8660
|
super(data);
|
|
8199
8661
|
}
|
|
8200
|
-
__drawPathByData(
|
|
8201
|
-
const { width, height, cornerRadius } = this.__;
|
|
8202
|
-
if (cornerRadius) {
|
|
8203
|
-
drawer.roundRect(0, 0, width, height, cornerRadius);
|
|
8204
|
-
}
|
|
8205
|
-
else {
|
|
8206
|
-
drawer.rect(0, 0, width, height);
|
|
8207
|
-
}
|
|
8208
|
-
}
|
|
8662
|
+
__drawPathByData(_drawer, _data) { }
|
|
8209
8663
|
};
|
|
8210
8664
|
__decorate([
|
|
8211
8665
|
dataProcessor(RectData)
|
|
8212
8666
|
], Rect.prototype, "__", void 0);
|
|
8667
|
+
__decorate([
|
|
8668
|
+
rewrite(UI.prototype.__drawPathByBox)
|
|
8669
|
+
], Rect.prototype, "__drawPathByData", null);
|
|
8213
8670
|
Rect = __decorate([
|
|
8214
8671
|
useModule(RectRender),
|
|
8672
|
+
rewriteAble(),
|
|
8215
8673
|
registerUI()
|
|
8216
8674
|
], Rect);
|
|
8217
8675
|
|
|
@@ -8221,12 +8679,20 @@ const bounds$1 = {};
|
|
|
8221
8679
|
const { copy: copy$2, add } = BoundsHelper;
|
|
8222
8680
|
let Box = class Box extends Group {
|
|
8223
8681
|
get __tag() { return 'Box'; }
|
|
8224
|
-
get resizeable() { return true; }
|
|
8225
8682
|
constructor(data) {
|
|
8226
8683
|
super(data);
|
|
8227
8684
|
this.isBranchLeaf = true;
|
|
8228
8685
|
this.__layout.renderChanged || this.__layout.renderChange();
|
|
8229
8686
|
}
|
|
8687
|
+
__scaleResize(scaleX, scaleY) {
|
|
8688
|
+
if (this.__.__autoBounds && this.children.length) {
|
|
8689
|
+
super.__scaleResize(scaleX, scaleY);
|
|
8690
|
+
}
|
|
8691
|
+
else {
|
|
8692
|
+
this.width *= scaleX;
|
|
8693
|
+
this.height *= scaleY;
|
|
8694
|
+
}
|
|
8695
|
+
}
|
|
8230
8696
|
__updateStrokeSpread() { return 0; }
|
|
8231
8697
|
__updateRectRenderSpread() { return 0; }
|
|
8232
8698
|
__updateRenderSpread() {
|
|
@@ -8236,7 +8702,15 @@ let Box = class Box extends Group {
|
|
|
8236
8702
|
width = this.__.__drawAfterFill ? 0 : 1;
|
|
8237
8703
|
return width;
|
|
8238
8704
|
}
|
|
8239
|
-
|
|
8705
|
+
__updateRectBoxBounds() { }
|
|
8706
|
+
__updateBoxBounds() {
|
|
8707
|
+
if (this.__.__autoBounds && this.children.length) {
|
|
8708
|
+
super.__updateBoxBounds();
|
|
8709
|
+
}
|
|
8710
|
+
else {
|
|
8711
|
+
this.__updateRectBoxBounds();
|
|
8712
|
+
}
|
|
8713
|
+
}
|
|
8240
8714
|
__updateStrokeBounds() { }
|
|
8241
8715
|
__updateRenderBounds() {
|
|
8242
8716
|
this.__updateRectRenderBounds();
|
|
@@ -8288,7 +8762,7 @@ __decorate([
|
|
|
8288
8762
|
], Box.prototype, "__updateRectRenderSpread", null);
|
|
8289
8763
|
__decorate([
|
|
8290
8764
|
rewrite(rect.__updateBoxBounds)
|
|
8291
|
-
], Box.prototype, "
|
|
8765
|
+
], Box.prototype, "__updateRectBoxBounds", null);
|
|
8292
8766
|
__decorate([
|
|
8293
8767
|
rewrite(rect.__updateStrokeBounds)
|
|
8294
8768
|
], Box.prototype, "__updateStrokeBounds", null);
|
|
@@ -8316,6 +8790,7 @@ let Frame = class Frame extends Box {
|
|
|
8316
8790
|
get __tag() { return 'Frame'; }
|
|
8317
8791
|
constructor(data) {
|
|
8318
8792
|
super(data);
|
|
8793
|
+
this.isFrame = true;
|
|
8319
8794
|
if (!this.__.fill)
|
|
8320
8795
|
this.__.fill = '#FFFFFF';
|
|
8321
8796
|
}
|
|
@@ -8356,7 +8831,7 @@ let Ellipse = class Ellipse extends UI {
|
|
|
8356
8831
|
ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
|
|
8357
8832
|
}
|
|
8358
8833
|
if (Platform.ellipseToCurve)
|
|
8359
|
-
this.__.path =
|
|
8834
|
+
this.__.path = this.getPath(true);
|
|
8360
8835
|
}
|
|
8361
8836
|
else {
|
|
8362
8837
|
if (startAngle || endAngle) {
|
|
@@ -8386,47 +8861,118 @@ Ellipse = __decorate([
|
|
|
8386
8861
|
registerUI()
|
|
8387
8862
|
], Ellipse);
|
|
8388
8863
|
|
|
8389
|
-
const {
|
|
8390
|
-
const {
|
|
8391
|
-
const { toBounds: toBounds$
|
|
8392
|
-
let
|
|
8393
|
-
get __tag() { return '
|
|
8394
|
-
get
|
|
8864
|
+
const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
|
|
8865
|
+
const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
|
|
8866
|
+
const { toBounds: toBounds$1 } = PathBounds;
|
|
8867
|
+
let Line = class Line extends UI {
|
|
8868
|
+
get __tag() { return 'Line'; }
|
|
8869
|
+
get toPoint() {
|
|
8870
|
+
const { width, rotation } = this.__;
|
|
8871
|
+
const to = { x: 0, y: 0 };
|
|
8872
|
+
if (width)
|
|
8873
|
+
to.x = width;
|
|
8874
|
+
if (rotation)
|
|
8875
|
+
rotate$1(to, rotation);
|
|
8876
|
+
return to;
|
|
8877
|
+
}
|
|
8878
|
+
set toPoint(value) {
|
|
8879
|
+
this.width = getDistance$2(defaultPoint, value);
|
|
8880
|
+
this.rotation = getAngle$2(defaultPoint, value);
|
|
8881
|
+
if (this.height)
|
|
8882
|
+
this.height = 0;
|
|
8883
|
+
}
|
|
8395
8884
|
constructor(data) {
|
|
8396
8885
|
super(data);
|
|
8397
8886
|
}
|
|
8398
8887
|
__updatePath() {
|
|
8399
8888
|
const path = this.__.path = [];
|
|
8400
8889
|
if (this.__.points) {
|
|
8401
|
-
drawPoints$1(path, this.__.points, false
|
|
8890
|
+
drawPoints$1(path, this.__.points, false);
|
|
8402
8891
|
}
|
|
8403
8892
|
else {
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
moveTo$2(path, rx, 0);
|
|
8407
|
-
for (let i = 1; i < sides; i++) {
|
|
8408
|
-
lineTo$2(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
|
|
8409
|
-
}
|
|
8893
|
+
moveTo$2(path, 0, 0);
|
|
8894
|
+
lineTo$2(path, this.width, 0);
|
|
8410
8895
|
}
|
|
8411
|
-
closePath$1(path);
|
|
8412
8896
|
}
|
|
8413
8897
|
__updateRenderPath() {
|
|
8414
8898
|
if (this.__.points && this.__.curve) {
|
|
8415
|
-
drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve,
|
|
8899
|
+
drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
|
|
8416
8900
|
}
|
|
8417
8901
|
else {
|
|
8418
8902
|
super.__updateRenderPath();
|
|
8419
8903
|
}
|
|
8420
8904
|
}
|
|
8421
8905
|
__updateBoxBounds() {
|
|
8422
|
-
if (this.
|
|
8423
|
-
toBounds$
|
|
8424
|
-
this.__updateNaturalSize();
|
|
8906
|
+
if (this.points) {
|
|
8907
|
+
toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
|
|
8425
8908
|
}
|
|
8426
8909
|
else {
|
|
8427
8910
|
super.__updateBoxBounds();
|
|
8428
8911
|
}
|
|
8429
8912
|
}
|
|
8913
|
+
__scaleResize(scaleX, scaleY) {
|
|
8914
|
+
if (this.points) {
|
|
8915
|
+
PathScaler.scalePoints(this.__.points, scaleX, scaleY);
|
|
8916
|
+
this.points = this.__.points;
|
|
8917
|
+
}
|
|
8918
|
+
else {
|
|
8919
|
+
if (this.__tag === 'Line') {
|
|
8920
|
+
const point = this.toPoint;
|
|
8921
|
+
point.x *= scaleX;
|
|
8922
|
+
point.y *= scaleY;
|
|
8923
|
+
this.toPoint = point;
|
|
8924
|
+
}
|
|
8925
|
+
else {
|
|
8926
|
+
super.__scaleResize(scaleX, scaleY);
|
|
8927
|
+
}
|
|
8928
|
+
}
|
|
8929
|
+
}
|
|
8930
|
+
};
|
|
8931
|
+
__decorate([
|
|
8932
|
+
dataProcessor(LineData)
|
|
8933
|
+
], Line.prototype, "__", void 0);
|
|
8934
|
+
__decorate([
|
|
8935
|
+
affectStrokeBoundsType('center')
|
|
8936
|
+
], Line.prototype, "strokeAlign", void 0);
|
|
8937
|
+
__decorate([
|
|
8938
|
+
boundsType(0)
|
|
8939
|
+
], Line.prototype, "height", void 0);
|
|
8940
|
+
__decorate([
|
|
8941
|
+
pathType()
|
|
8942
|
+
], Line.prototype, "points", void 0);
|
|
8943
|
+
__decorate([
|
|
8944
|
+
pathType(0)
|
|
8945
|
+
], Line.prototype, "curve", void 0);
|
|
8946
|
+
Line = __decorate([
|
|
8947
|
+
registerUI()
|
|
8948
|
+
], Line);
|
|
8949
|
+
|
|
8950
|
+
const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
|
|
8951
|
+
const { moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints } = PathCommandDataHelper;
|
|
8952
|
+
const line = Line.prototype;
|
|
8953
|
+
let Polygon = class Polygon extends UI {
|
|
8954
|
+
get __tag() { return 'Polygon'; }
|
|
8955
|
+
constructor(data) {
|
|
8956
|
+
super(data);
|
|
8957
|
+
}
|
|
8958
|
+
__updatePath() {
|
|
8959
|
+
const path = this.__.path = [];
|
|
8960
|
+
if (this.__.points) {
|
|
8961
|
+
drawPoints(path, this.__.points, false, true);
|
|
8962
|
+
}
|
|
8963
|
+
else {
|
|
8964
|
+
const { width, height, sides } = this.__;
|
|
8965
|
+
const rx = width / 2, ry = height / 2;
|
|
8966
|
+
moveTo$1(path, rx, 0);
|
|
8967
|
+
for (let i = 1; i < sides; i++) {
|
|
8968
|
+
lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
|
|
8969
|
+
}
|
|
8970
|
+
}
|
|
8971
|
+
closePath$1(path);
|
|
8972
|
+
}
|
|
8973
|
+
__updateRenderPath() { }
|
|
8974
|
+
__updateBoxBounds() { }
|
|
8975
|
+
__scaleResize(_scaleX, _scaleY) { }
|
|
8430
8976
|
};
|
|
8431
8977
|
__decorate([
|
|
8432
8978
|
dataProcessor(PolygonData)
|
|
@@ -8440,12 +8986,22 @@ __decorate([
|
|
|
8440
8986
|
__decorate([
|
|
8441
8987
|
pathType(0)
|
|
8442
8988
|
], Polygon.prototype, "curve", void 0);
|
|
8989
|
+
__decorate([
|
|
8990
|
+
rewrite(line.__updateRenderPath)
|
|
8991
|
+
], Polygon.prototype, "__updateRenderPath", null);
|
|
8992
|
+
__decorate([
|
|
8993
|
+
rewrite(line.__updateBoxBounds)
|
|
8994
|
+
], Polygon.prototype, "__updateBoxBounds", null);
|
|
8995
|
+
__decorate([
|
|
8996
|
+
rewrite(line.__scaleResize)
|
|
8997
|
+
], Polygon.prototype, "__scaleResize", null);
|
|
8443
8998
|
Polygon = __decorate([
|
|
8999
|
+
rewriteAble(),
|
|
8444
9000
|
registerUI()
|
|
8445
9001
|
], Polygon);
|
|
8446
9002
|
|
|
8447
9003
|
const { sin, cos, PI } = Math;
|
|
8448
|
-
const { moveTo
|
|
9004
|
+
const { moveTo, lineTo, closePath } = PathCommandDataHelper;
|
|
8449
9005
|
let Star = class Star extends UI {
|
|
8450
9006
|
get __tag() { return 'Star'; }
|
|
8451
9007
|
constructor(data) {
|
|
@@ -8455,9 +9011,9 @@ let Star = class Star extends UI {
|
|
|
8455
9011
|
const { width, height, corners, innerRadius } = this.__;
|
|
8456
9012
|
const rx = width / 2, ry = height / 2;
|
|
8457
9013
|
const path = this.__.path = [];
|
|
8458
|
-
moveTo
|
|
9014
|
+
moveTo(path, rx, 0);
|
|
8459
9015
|
for (let i = 1; i < corners * 2; i++) {
|
|
8460
|
-
lineTo
|
|
9016
|
+
lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin((i * PI) / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos((i * PI) / corners));
|
|
8461
9017
|
}
|
|
8462
9018
|
closePath(path);
|
|
8463
9019
|
}
|
|
@@ -8475,77 +9031,6 @@ Star = __decorate([
|
|
|
8475
9031
|
registerUI()
|
|
8476
9032
|
], Star);
|
|
8477
9033
|
|
|
8478
|
-
const { moveTo, lineTo, drawPoints } = PathCommandDataHelper;
|
|
8479
|
-
const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
|
|
8480
|
-
const { toBounds: toBounds$1 } = PathBounds;
|
|
8481
|
-
let Line = class Line extends UI {
|
|
8482
|
-
get __tag() { return 'Line'; }
|
|
8483
|
-
get resizeable() { return !this.points; }
|
|
8484
|
-
get toPoint() {
|
|
8485
|
-
const { width, rotation } = this.__;
|
|
8486
|
-
const to = { x: 0, y: 0 };
|
|
8487
|
-
if (width)
|
|
8488
|
-
to.x = width;
|
|
8489
|
-
if (rotation)
|
|
8490
|
-
rotate$1(to, rotation);
|
|
8491
|
-
return to;
|
|
8492
|
-
}
|
|
8493
|
-
set toPoint(value) {
|
|
8494
|
-
this.width = getDistance$2(defaultPoint, value);
|
|
8495
|
-
this.rotation = getAngle$2(defaultPoint, value);
|
|
8496
|
-
if (this.height)
|
|
8497
|
-
this.height = 0;
|
|
8498
|
-
}
|
|
8499
|
-
constructor(data) {
|
|
8500
|
-
super(data);
|
|
8501
|
-
}
|
|
8502
|
-
__updatePath() {
|
|
8503
|
-
const path = this.__.path = [];
|
|
8504
|
-
if (this.__.points) {
|
|
8505
|
-
drawPoints(path, this.__.points, false);
|
|
8506
|
-
}
|
|
8507
|
-
else {
|
|
8508
|
-
moveTo(path, 0, 0);
|
|
8509
|
-
lineTo(path, this.width, 0);
|
|
8510
|
-
}
|
|
8511
|
-
}
|
|
8512
|
-
__updateRenderPath() {
|
|
8513
|
-
if (this.__.points && this.__.curve) {
|
|
8514
|
-
drawPoints(this.__.__pathForRender = [], this.__.points, this.__.curve, false);
|
|
8515
|
-
}
|
|
8516
|
-
else {
|
|
8517
|
-
super.__updateRenderPath();
|
|
8518
|
-
}
|
|
8519
|
-
}
|
|
8520
|
-
__updateBoxBounds() {
|
|
8521
|
-
if (this.points) {
|
|
8522
|
-
toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
|
|
8523
|
-
this.__updateNaturalSize();
|
|
8524
|
-
}
|
|
8525
|
-
else {
|
|
8526
|
-
super.__updateBoxBounds();
|
|
8527
|
-
}
|
|
8528
|
-
}
|
|
8529
|
-
};
|
|
8530
|
-
__decorate([
|
|
8531
|
-
dataProcessor(LineData)
|
|
8532
|
-
], Line.prototype, "__", void 0);
|
|
8533
|
-
__decorate([
|
|
8534
|
-
affectStrokeBoundsType('center')
|
|
8535
|
-
], Line.prototype, "strokeAlign", void 0);
|
|
8536
|
-
__decorate([
|
|
8537
|
-
boundsType(0)
|
|
8538
|
-
], Line.prototype, "height", void 0);
|
|
8539
|
-
__decorate([
|
|
8540
|
-
pathType()
|
|
8541
|
-
], Line.prototype, "points", void 0);
|
|
8542
|
-
__decorate([
|
|
8543
|
-
pathType(0)
|
|
8544
|
-
], Line.prototype, "curve", void 0);
|
|
8545
|
-
Line = __decorate([
|
|
8546
|
-
registerUI()
|
|
8547
|
-
], Line);
|
|
8548
|
-
|
|
8549
9034
|
let Image$1 = class Image extends Rect {
|
|
8550
9035
|
get __tag() { return 'Image'; }
|
|
8551
9036
|
get ready() { return this.image ? this.image.ready : false; }
|
|
@@ -8596,7 +9081,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8596
9081
|
this.__.__drawAfterFill = true;
|
|
8597
9082
|
}
|
|
8598
9083
|
draw(ui, offset, scale, rotation) {
|
|
8599
|
-
ui.__layout.
|
|
9084
|
+
ui.__layout.update();
|
|
8600
9085
|
const matrix = new Matrix(ui.__world);
|
|
8601
9086
|
matrix.invert();
|
|
8602
9087
|
const m = new Matrix();
|
|
@@ -8606,7 +9091,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8606
9091
|
typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y);
|
|
8607
9092
|
if (rotation)
|
|
8608
9093
|
m.rotate(rotation);
|
|
8609
|
-
matrix.
|
|
9094
|
+
matrix.multiplyParent(m);
|
|
8610
9095
|
ui.__render(this.canvas, { matrix });
|
|
8611
9096
|
this.paint();
|
|
8612
9097
|
}
|
|
@@ -8666,11 +9151,11 @@ Canvas = __decorate([
|
|
|
8666
9151
|
registerUI()
|
|
8667
9152
|
], Canvas);
|
|
8668
9153
|
|
|
8669
|
-
const { copyAndSpread, includes, spread,
|
|
9154
|
+
const { copyAndSpread, includes, spread, setList } = BoundsHelper;
|
|
8670
9155
|
let Text = class Text extends UI {
|
|
8671
9156
|
get __tag() { return 'Text'; }
|
|
8672
9157
|
get textDrawData() {
|
|
8673
|
-
this.__layout.
|
|
9158
|
+
this.__layout.update();
|
|
8674
9159
|
return this.__.__textDrawData;
|
|
8675
9160
|
}
|
|
8676
9161
|
constructor(data) {
|
|
@@ -8701,33 +9186,45 @@ let Text = class Text extends UI {
|
|
|
8701
9186
|
const data = this.__;
|
|
8702
9187
|
const layout = this.__layout;
|
|
8703
9188
|
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
|
|
8704
|
-
const
|
|
8705
|
-
const
|
|
9189
|
+
const autoWidth = data.__autoWidth;
|
|
9190
|
+
const autoHeight = data.__autoHeight;
|
|
8706
9191
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
8707
9192
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
8708
9193
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
8709
9194
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
8710
|
-
data.__clipText = textOverflow !== 'show' &&
|
|
9195
|
+
data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
|
|
8711
9196
|
this.__updateTextDrawData();
|
|
8712
9197
|
const { bounds } = data.__textDrawData;
|
|
8713
9198
|
const b = layout.boxBounds;
|
|
8714
9199
|
if (data.__lineHeight < fontSize)
|
|
8715
9200
|
spread(bounds, fontSize / 2);
|
|
8716
|
-
if (
|
|
8717
|
-
|
|
9201
|
+
if (autoWidth || autoHeight) {
|
|
9202
|
+
b.x = autoWidth ? bounds.x : 0;
|
|
9203
|
+
b.y = autoHeight ? bounds.y : 0;
|
|
9204
|
+
b.width = autoWidth ? bounds.width : data.width;
|
|
9205
|
+
b.height = autoHeight ? bounds.height : data.height;
|
|
9206
|
+
const { padding } = data;
|
|
9207
|
+
if (padding) {
|
|
9208
|
+
const [top, right, bottom, left] = MathHelper.fourNumber(padding);
|
|
9209
|
+
if (autoWidth) {
|
|
9210
|
+
b.x -= left;
|
|
9211
|
+
b.width += (right + left);
|
|
9212
|
+
}
|
|
9213
|
+
if (autoHeight) {
|
|
9214
|
+
b.y -= top;
|
|
9215
|
+
b.height += (bottom + top);
|
|
9216
|
+
}
|
|
9217
|
+
}
|
|
9218
|
+
this.__updateNaturalSize();
|
|
8718
9219
|
}
|
|
8719
9220
|
else {
|
|
8720
|
-
|
|
8721
|
-
b.y = height ? 0 : bounds.y;
|
|
8722
|
-
b.width = width ? width : bounds.width;
|
|
8723
|
-
b.height = height ? height : bounds.height;
|
|
8724
|
-
this.__updateNaturalSize();
|
|
9221
|
+
super.__updateBoxBounds();
|
|
8725
9222
|
}
|
|
8726
9223
|
const contentBounds = includes(b, bounds) ? b : bounds;
|
|
8727
9224
|
if (contentBounds !== layout.contentBounds) {
|
|
8728
9225
|
layout.contentBounds = contentBounds;
|
|
8729
9226
|
layout.renderChanged = true;
|
|
8730
|
-
|
|
9227
|
+
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
8731
9228
|
}
|
|
8732
9229
|
else {
|
|
8733
9230
|
data.__textBoxBounds = contentBounds;
|
|
@@ -8755,6 +9252,9 @@ __decorate([
|
|
|
8755
9252
|
__decorate([
|
|
8756
9253
|
boundsType(0)
|
|
8757
9254
|
], Text.prototype, "padding", void 0);
|
|
9255
|
+
__decorate([
|
|
9256
|
+
surfaceType('#000000')
|
|
9257
|
+
], Text.prototype, "fill", void 0);
|
|
8758
9258
|
__decorate([
|
|
8759
9259
|
affectStrokeBoundsType('outside')
|
|
8760
9260
|
], Text.prototype, "strokeAlign", void 0);
|
|
@@ -8813,13 +9313,15 @@ Text = __decorate([
|
|
|
8813
9313
|
const { toBounds } = PathBounds;
|
|
8814
9314
|
let Path = class Path extends UI {
|
|
8815
9315
|
get __tag() { return 'Path'; }
|
|
8816
|
-
get resizeable() { return false; }
|
|
8817
9316
|
constructor(data) {
|
|
8818
9317
|
super(data);
|
|
8819
9318
|
}
|
|
9319
|
+
__scaleResize(scaleX, scaleY) {
|
|
9320
|
+
PathScaler.scale(this.__.path, scaleX, scaleY);
|
|
9321
|
+
this.path = this.__.path;
|
|
9322
|
+
}
|
|
8820
9323
|
__updateBoxBounds() {
|
|
8821
9324
|
toBounds(this.__.path, this.__layout.boxBounds);
|
|
8822
|
-
this.__updateNaturalSize();
|
|
8823
9325
|
}
|
|
8824
9326
|
};
|
|
8825
9327
|
__decorate([
|
|
@@ -8888,6 +9390,7 @@ let Leafer = class Leafer extends Group {
|
|
|
8888
9390
|
get __tag() { return 'Leafer'; }
|
|
8889
9391
|
get isApp() { return false; }
|
|
8890
9392
|
get app() { return this.parent || this; }
|
|
9393
|
+
get layoutLocked() { return !this.layouter.running; }
|
|
8891
9394
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
8892
9395
|
constructor(userConfig, data) {
|
|
8893
9396
|
super(data);
|
|
@@ -8980,13 +9483,18 @@ let Leafer = class Leafer extends Group {
|
|
|
8980
9483
|
this.emitLeafer(LeaferEvent.STOP);
|
|
8981
9484
|
}
|
|
8982
9485
|
}
|
|
9486
|
+
unlockLayout() {
|
|
9487
|
+
this.layouter.start();
|
|
9488
|
+
this.updateLayout();
|
|
9489
|
+
}
|
|
9490
|
+
lockLayout() {
|
|
9491
|
+
this.updateLayout();
|
|
9492
|
+
this.layouter.stop();
|
|
9493
|
+
}
|
|
8983
9494
|
resize(size) {
|
|
8984
9495
|
const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
|
|
8985
9496
|
Object.keys(data).forEach(key => this[key] = data[key]);
|
|
8986
9497
|
}
|
|
8987
|
-
forceLayout() {
|
|
8988
|
-
this.__layout.checkUpdate(true);
|
|
8989
|
-
}
|
|
8990
9498
|
forceFullRender() {
|
|
8991
9499
|
this.renderer.addBlock(this.canvas.bounds);
|
|
8992
9500
|
if (this.viewReady)
|
|
@@ -9132,7 +9640,7 @@ let Leafer = class Leafer extends Group {
|
|
|
9132
9640
|
}
|
|
9133
9641
|
}
|
|
9134
9642
|
__checkUpdateLayout() {
|
|
9135
|
-
this.__layout.
|
|
9643
|
+
this.__layout.update();
|
|
9136
9644
|
}
|
|
9137
9645
|
emitLeafer(type) {
|
|
9138
9646
|
this.emitEvent(new LeaferEvent(type, this));
|
|
@@ -9192,6 +9700,22 @@ Leafer = __decorate([
|
|
|
9192
9700
|
let App = class App extends Leafer {
|
|
9193
9701
|
get __tag() { return 'App'; }
|
|
9194
9702
|
get isApp() { return true; }
|
|
9703
|
+
constructor(userConfig, data) {
|
|
9704
|
+
super(userConfig, data);
|
|
9705
|
+
if (userConfig) {
|
|
9706
|
+
const { ground, tree, sky, editor } = userConfig;
|
|
9707
|
+
if (ground)
|
|
9708
|
+
this.ground = this.addLeafer(ground);
|
|
9709
|
+
if (tree || editor)
|
|
9710
|
+
this.tree = this.addLeafer(tree);
|
|
9711
|
+
if (sky || editor)
|
|
9712
|
+
this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
|
|
9713
|
+
if (editor) {
|
|
9714
|
+
this.editor = Creator.editor(editor);
|
|
9715
|
+
this.sky.add(this.editor);
|
|
9716
|
+
}
|
|
9717
|
+
}
|
|
9718
|
+
}
|
|
9195
9719
|
__setApp() {
|
|
9196
9720
|
const { canvas } = this;
|
|
9197
9721
|
const { realCanvas, view } = this.config;
|
|
@@ -9208,12 +9732,20 @@ let App = class App extends Leafer {
|
|
|
9208
9732
|
}
|
|
9209
9733
|
start() {
|
|
9210
9734
|
super.start();
|
|
9211
|
-
this.children.forEach(leafer =>
|
|
9735
|
+
this.children.forEach(leafer => leafer.start());
|
|
9212
9736
|
}
|
|
9213
9737
|
stop() {
|
|
9214
|
-
this.children.forEach(leafer =>
|
|
9738
|
+
this.children.forEach(leafer => leafer.stop());
|
|
9215
9739
|
super.stop();
|
|
9216
9740
|
}
|
|
9741
|
+
unlockLayout() {
|
|
9742
|
+
super.unlockLayout();
|
|
9743
|
+
this.children.forEach(leafer => leafer.unlockLayout());
|
|
9744
|
+
}
|
|
9745
|
+
lockLayout() {
|
|
9746
|
+
super.lockLayout();
|
|
9747
|
+
this.children.forEach(leafer => leafer.lockLayout());
|
|
9748
|
+
}
|
|
9217
9749
|
addLeafer(merge) {
|
|
9218
9750
|
const leafer = new Leafer(merge);
|
|
9219
9751
|
this.add(leafer);
|
|
@@ -9232,7 +9764,7 @@ let App = class App extends Leafer {
|
|
|
9232
9764
|
}
|
|
9233
9765
|
__onPropertyChange() {
|
|
9234
9766
|
if (Debug.showHitView)
|
|
9235
|
-
this.children.forEach(leafer =>
|
|
9767
|
+
this.children.forEach(leafer => leafer.forceUpdate('surface'));
|
|
9236
9768
|
}
|
|
9237
9769
|
__onCreated() {
|
|
9238
9770
|
this.created = this.children.every(child => child.created);
|
|
@@ -9254,14 +9786,14 @@ let App = class App extends Leafer {
|
|
|
9254
9786
|
this.renderer.update();
|
|
9255
9787
|
}
|
|
9256
9788
|
__render(canvas, _options) {
|
|
9257
|
-
this.children.forEach(leafer =>
|
|
9789
|
+
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
9258
9790
|
}
|
|
9259
9791
|
__onResize(event) {
|
|
9260
|
-
this.children.forEach(leafer =>
|
|
9792
|
+
this.children.forEach(leafer => leafer.resize(event));
|
|
9261
9793
|
super.__onResize(event);
|
|
9262
9794
|
}
|
|
9263
9795
|
__checkUpdateLayout() {
|
|
9264
|
-
this.children.forEach(leafer =>
|
|
9796
|
+
this.children.forEach(leafer => leafer.__layout.update());
|
|
9265
9797
|
}
|
|
9266
9798
|
__getChildConfig(userConfig) {
|
|
9267
9799
|
let config = Object.assign({}, this.config);
|
|
@@ -9286,7 +9818,7 @@ App = __decorate([
|
|
|
9286
9818
|
registerUI()
|
|
9287
9819
|
], App);
|
|
9288
9820
|
|
|
9289
|
-
const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper
|
|
9821
|
+
const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
|
|
9290
9822
|
function fillOrFitMode(data, mode, box, width, height, rotation) {
|
|
9291
9823
|
const transform = get$4();
|
|
9292
9824
|
const swap = rotation && rotation !== 180;
|
|
@@ -9296,7 +9828,7 @@ function fillOrFitMode(data, mode, box, width, height, rotation) {
|
|
|
9296
9828
|
const x = box.x + (box.width - width * scale) / 2;
|
|
9297
9829
|
const y = box.y + (box.height - height * scale) / 2;
|
|
9298
9830
|
translate$1(transform, x, y);
|
|
9299
|
-
scaleHelper
|
|
9831
|
+
scaleHelper(transform, scale);
|
|
9300
9832
|
if (rotation)
|
|
9301
9833
|
rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
9302
9834
|
data.scaleX = data.scaleY = scale;
|
|
@@ -9308,7 +9840,7 @@ function clipMode(data, box, offset, scale, rotation) {
|
|
|
9308
9840
|
if (offset)
|
|
9309
9841
|
translate$1(transform, offset.x, offset.y);
|
|
9310
9842
|
if (scale) {
|
|
9311
|
-
typeof scale === 'number' ? scaleHelper
|
|
9843
|
+
typeof scale === 'number' ? scaleHelper(transform, scale) : scaleHelper(transform, scale.x, scale.y);
|
|
9312
9844
|
data.scaleX = transform.a;
|
|
9313
9845
|
data.scaleY = transform.d;
|
|
9314
9846
|
}
|
|
@@ -9421,6 +9953,10 @@ function hasNaturalSize(ui, attrName, image) {
|
|
|
9421
9953
|
d.__naturalWidth = image.width;
|
|
9422
9954
|
d.__naturalHeight = image.height;
|
|
9423
9955
|
if (!d.__getInput('width') || !d.__getInput('height')) {
|
|
9956
|
+
if (ui.__proxyData) {
|
|
9957
|
+
ui.setProxyAttr('width', ui.__.width);
|
|
9958
|
+
ui.setProxyAttr('height', ui.__.height);
|
|
9959
|
+
}
|
|
9424
9960
|
ui.forceUpdate('width');
|
|
9425
9961
|
return false;
|
|
9426
9962
|
}
|
|
@@ -9432,22 +9968,19 @@ function emit(type, data) {
|
|
|
9432
9968
|
data.target.emitEvent(new ImageEvent(type, data));
|
|
9433
9969
|
}
|
|
9434
9970
|
|
|
9435
|
-
const { get: get$2, scale
|
|
9971
|
+
const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
|
|
9436
9972
|
function createPattern(ui, paint, pixelRatio) {
|
|
9437
9973
|
let { scaleX, scaleY } = ui.__world;
|
|
9438
9974
|
const id = scaleX + '-' + scaleY;
|
|
9439
9975
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
9440
|
-
paint.patternId = id;
|
|
9441
9976
|
scaleX = Math.abs(scaleX);
|
|
9442
9977
|
scaleY = Math.abs(scaleY);
|
|
9443
9978
|
const { image, data } = paint;
|
|
9444
|
-
|
|
9445
|
-
const maxHeight = image.isSVG ? 4096 : Math.min(image.height, 4096);
|
|
9446
|
-
let scale, matrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
|
|
9979
|
+
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
|
|
9447
9980
|
if (sx) {
|
|
9448
|
-
|
|
9449
|
-
copy$1(
|
|
9450
|
-
|
|
9981
|
+
imageMatrix = get$2();
|
|
9982
|
+
copy$1(imageMatrix, transform);
|
|
9983
|
+
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
9451
9984
|
scaleX *= sx;
|
|
9452
9985
|
scaleY *= sy;
|
|
9453
9986
|
}
|
|
@@ -9455,38 +9988,49 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
9455
9988
|
scaleY *= pixelRatio;
|
|
9456
9989
|
width *= scaleX;
|
|
9457
9990
|
height *= scaleY;
|
|
9458
|
-
|
|
9459
|
-
|
|
9991
|
+
const size = width * height;
|
|
9992
|
+
if (paint.data.mode !== 'repeat') {
|
|
9993
|
+
if (size > Platform.image.maxCacheSize)
|
|
9994
|
+
return false;
|
|
9995
|
+
}
|
|
9996
|
+
let maxSize = Platform.image.maxPatternSize;
|
|
9997
|
+
if (!image.isSVG) {
|
|
9998
|
+
const imageSize = image.width * image.height;
|
|
9999
|
+
if (maxSize > imageSize)
|
|
10000
|
+
maxSize = imageSize;
|
|
9460
10001
|
}
|
|
9461
|
-
if (
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
10002
|
+
if (size > maxSize)
|
|
10003
|
+
imageScale = Math.sqrt(size / maxSize);
|
|
10004
|
+
if (imageScale) {
|
|
10005
|
+
scaleX /= imageScale;
|
|
10006
|
+
scaleY /= imageScale;
|
|
10007
|
+
width /= imageScale;
|
|
10008
|
+
height /= imageScale;
|
|
9466
10009
|
}
|
|
9467
10010
|
if (sx) {
|
|
9468
10011
|
scaleX /= sx;
|
|
9469
10012
|
scaleY /= sy;
|
|
9470
10013
|
}
|
|
9471
10014
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
9472
|
-
if (!
|
|
9473
|
-
|
|
10015
|
+
if (!imageMatrix) {
|
|
10016
|
+
imageMatrix = get$2();
|
|
9474
10017
|
if (transform)
|
|
9475
|
-
copy$1(
|
|
10018
|
+
copy$1(imageMatrix, transform);
|
|
9476
10019
|
}
|
|
9477
|
-
|
|
10020
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
9478
10021
|
}
|
|
9479
|
-
const
|
|
10022
|
+
const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), mode === 'repeat' ? 'repeat' : (Platform.origin.noRepeat || 'no-repeat'));
|
|
9480
10023
|
try {
|
|
9481
10024
|
if (paint.transform)
|
|
9482
10025
|
paint.transform = null;
|
|
9483
|
-
if (
|
|
9484
|
-
|
|
10026
|
+
if (imageMatrix)
|
|
10027
|
+
pattern.setTransform ? pattern.setTransform(imageMatrix) : paint.transform = imageMatrix;
|
|
9485
10028
|
}
|
|
9486
10029
|
catch (_a) {
|
|
9487
|
-
paint.transform =
|
|
10030
|
+
paint.transform = imageMatrix;
|
|
9488
10031
|
}
|
|
9489
|
-
paint.style =
|
|
10032
|
+
paint.style = pattern;
|
|
10033
|
+
paint.patternId = id;
|
|
9490
10034
|
return true;
|
|
9491
10035
|
}
|
|
9492
10036
|
else {
|
|
@@ -9494,18 +10038,24 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
9494
10038
|
}
|
|
9495
10039
|
}
|
|
9496
10040
|
|
|
10041
|
+
const { abs } = Math;
|
|
9497
10042
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
9498
10043
|
const { scaleX, scaleY } = ui.__world;
|
|
9499
10044
|
if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
|
|
9500
10045
|
return false;
|
|
9501
10046
|
}
|
|
9502
10047
|
else {
|
|
10048
|
+
const { data } = paint;
|
|
9503
10049
|
if (allowPaint) {
|
|
9504
|
-
if (
|
|
9505
|
-
let { width, height } =
|
|
9506
|
-
width *= scaleX * canvas.pixelRatio;
|
|
9507
|
-
height *= scaleY * canvas.pixelRatio;
|
|
9508
|
-
|
|
10050
|
+
if (data.mode !== 'repeat') {
|
|
10051
|
+
let { width, height } = data;
|
|
10052
|
+
width *= abs(scaleX) * canvas.pixelRatio;
|
|
10053
|
+
height *= abs(scaleY) * canvas.pixelRatio;
|
|
10054
|
+
if (data.scaleX) {
|
|
10055
|
+
width *= data.scaleX;
|
|
10056
|
+
height *= data.scaleY;
|
|
10057
|
+
}
|
|
10058
|
+
allowPaint = width * height > Platform.image.maxCacheSize;
|
|
9509
10059
|
}
|
|
9510
10060
|
else {
|
|
9511
10061
|
allowPaint = false;
|
|
@@ -9514,7 +10064,6 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
9514
10064
|
if (allowPaint) {
|
|
9515
10065
|
canvas.save();
|
|
9516
10066
|
canvas.clip();
|
|
9517
|
-
const { data } = paint;
|
|
9518
10067
|
if (paint.blendMode)
|
|
9519
10068
|
canvas.blendMode = paint.blendMode;
|
|
9520
10069
|
if (data.opacity)
|
|
@@ -9526,7 +10075,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
9526
10075
|
return true;
|
|
9527
10076
|
}
|
|
9528
10077
|
else {
|
|
9529
|
-
if (!paint.style) {
|
|
10078
|
+
if (!paint.style || Export$1.running) {
|
|
9530
10079
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
9531
10080
|
}
|
|
9532
10081
|
else {
|
|
@@ -9545,7 +10094,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
9545
10094
|
}
|
|
9546
10095
|
|
|
9547
10096
|
function recycleImage(attrName, data) {
|
|
9548
|
-
const paints =
|
|
10097
|
+
const paints = data['_' + attrName];
|
|
9549
10098
|
if (paints instanceof Array) {
|
|
9550
10099
|
let image, recycleMap, input, url;
|
|
9551
10100
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
@@ -9649,7 +10198,7 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas, renderOptions) {
|
|
|
9649
10198
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
9650
10199
|
fillText(ui, out);
|
|
9651
10200
|
out.blendMode = 'normal';
|
|
9652
|
-
if (ui.
|
|
10201
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
9653
10202
|
canvas.copyWorldByReset(out);
|
|
9654
10203
|
}
|
|
9655
10204
|
else {
|
|
@@ -9722,7 +10271,7 @@ function stroke(stroke, ui, canvas, renderOptions) {
|
|
|
9722
10271
|
out.stroke();
|
|
9723
10272
|
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
9724
10273
|
out.clearWorld(ui.__layout.renderBounds);
|
|
9725
|
-
if (ui.
|
|
10274
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
9726
10275
|
canvas.copyWorldByReset(out);
|
|
9727
10276
|
}
|
|
9728
10277
|
else {
|
|
@@ -9762,7 +10311,7 @@ function strokes(strokes, ui, canvas, renderOptions) {
|
|
|
9762
10311
|
drawStrokesStyle(strokes, false, ui, out);
|
|
9763
10312
|
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
9764
10313
|
out.clearWorld(renderBounds);
|
|
9765
|
-
if (ui.
|
|
10314
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
9766
10315
|
canvas.copyWorldByReset(out);
|
|
9767
10316
|
}
|
|
9768
10317
|
else {
|
|
@@ -9986,7 +10535,7 @@ function shadow(ui, current, shape, renderOptions) {
|
|
|
9986
10535
|
}
|
|
9987
10536
|
worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
9988
10537
|
}
|
|
9989
|
-
if (ui.
|
|
10538
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
9990
10539
|
current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
|
|
9991
10540
|
}
|
|
9992
10541
|
else {
|
|
@@ -10050,7 +10599,7 @@ function innerShadow(ui, current, shape, renderOptions) {
|
|
|
10050
10599
|
copyBounds = bounds;
|
|
10051
10600
|
}
|
|
10052
10601
|
other.fillWorld(copyBounds, item.color, 'source-in');
|
|
10053
|
-
if (ui.
|
|
10602
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
10054
10603
|
current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
|
|
10055
10604
|
}
|
|
10056
10605
|
else {
|
|
@@ -10548,6 +11097,7 @@ const ColorConvert = {
|
|
|
10548
11097
|
|
|
10549
11098
|
const Export = {
|
|
10550
11099
|
export(leaf, filename, options) {
|
|
11100
|
+
Export.running = true;
|
|
10551
11101
|
return addTask((success) => new Promise((resolve) => {
|
|
10552
11102
|
const { leafer } = leaf;
|
|
10553
11103
|
if (leafer) {
|
|
@@ -10585,6 +11135,7 @@ const Export = {
|
|
|
10585
11135
|
}
|
|
10586
11136
|
success({ data });
|
|
10587
11137
|
resolve();
|
|
11138
|
+
Export.running = false;
|
|
10588
11139
|
if (unreal)
|
|
10589
11140
|
canvas.recycle();
|
|
10590
11141
|
}));
|
|
@@ -10592,6 +11143,7 @@ const Export = {
|
|
|
10592
11143
|
else {
|
|
10593
11144
|
success({ data: false });
|
|
10594
11145
|
resolve();
|
|
11146
|
+
Export.running = false;
|
|
10595
11147
|
}
|
|
10596
11148
|
}));
|
|
10597
11149
|
}
|
|
@@ -10613,4 +11165,4 @@ Object.assign(Export$1, Export);
|
|
|
10613
11165
|
|
|
10614
11166
|
useCanvas();
|
|
10615
11167
|
|
|
10616
|
-
export { Animate, AnimateEvent, App, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, Branch, BranchHelper, BranchRender, Canvas, CanvasManager, ChildEvent, ColorConvert$1 as ColorConvert, Creator, Cursor, DataHelper, Debug, DragEvent, DropEvent, Effect, Ellipse, EllipseHelper, Event, EventCreator, Export$1 as Export, FileHelper, Frame, Group, HitCanvasManager, Image$1 as Image, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafHit, LeafLayout, LeafLevelList, LeafList, LeafMask, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, Platform, PluginManager, Point, PointHelper, PointerButton, PointerEvent, Polygon, PropertyEvent, Rect, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert$1 as TextConvert,
|
|
11168
|
+
export { Animate, AnimateEvent, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert$1 as ColorConvert, Creator, Cursor, DataHelper, Debug, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export$1 as Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafHit, LeafLayout, LeafLevelList, LeafList, LeafMask, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Platform, PluginManager, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert$1 as TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIHit, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, effectType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, opacityType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useCanvas, useModule, usePlugin };
|