@leafer/worker 1.9.6 → 1.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.cjs +11 -0
- package/dist/worker.esm.js +2 -0
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +667 -427
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +682 -428
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +23 -22
- package/src/index.ts +2 -0
- package/types/index.d.ts +1 -0
package/dist/worker.js
CHANGED
|
@@ -229,17 +229,32 @@ var LeaferUI = function(exports) {
|
|
|
229
229
|
this.__input = this.__middle = null;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
232
|
+
let tempA, tempB, tempTo;
|
|
233
|
+
const {max: max$5} = Math, tempFour = [ 0, 0, 0, 0 ];
|
|
234
|
+
const FourNumberHelper = {
|
|
235
|
+
zero: [ ...tempFour ],
|
|
236
|
+
tempFour: tempFour,
|
|
237
|
+
set(to, top, right, bottom, left) {
|
|
238
|
+
if (right === undefined) right = bottom = left = top;
|
|
239
|
+
to[0] = top;
|
|
240
|
+
to[1] = right;
|
|
241
|
+
to[2] = bottom;
|
|
242
|
+
to[3] = left;
|
|
243
|
+
return to;
|
|
244
|
+
},
|
|
245
|
+
setTemp(top, right, bottom, left) {
|
|
246
|
+
return set$1(tempFour, top, right, bottom, left);
|
|
247
|
+
},
|
|
248
|
+
toTempAB(a, b, change) {
|
|
249
|
+
tempTo = change ? isNumber(a) ? b : a : [];
|
|
250
|
+
if (isNumber(a)) tempA = setTemp(a), tempB = b; else if (isNumber(b)) tempA = a,
|
|
251
|
+
tempB = setTemp(b); else tempA = a, tempB = b;
|
|
252
|
+
if (tempA.length !== 4) tempA = get$5(tempA);
|
|
253
|
+
if (tempB.length !== 4) tempB = get$5(tempB);
|
|
239
254
|
},
|
|
240
|
-
|
|
255
|
+
get(num, maxValue) {
|
|
241
256
|
let data;
|
|
242
|
-
if (
|
|
257
|
+
if (!isNumber(num)) {
|
|
243
258
|
switch (num.length) {
|
|
244
259
|
case 4:
|
|
245
260
|
data = isUndefined(maxValue) ? num : [ ...num ];
|
|
@@ -262,9 +277,36 @@ var LeaferUI = function(exports) {
|
|
|
262
277
|
}
|
|
263
278
|
}
|
|
264
279
|
if (!data) data = [ num, num, num, num ];
|
|
265
|
-
if (maxValue) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
|
|
280
|
+
if (!isUndefined(maxValue)) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue;
|
|
266
281
|
return data;
|
|
267
282
|
},
|
|
283
|
+
max(t, other, change) {
|
|
284
|
+
if (isNumber(t) && isNumber(other)) return max$5(t, other);
|
|
285
|
+
toTempAB(t, other, change);
|
|
286
|
+
return set$1(tempTo, max$5(tempA[0], tempB[0]), max$5(tempA[1], tempB[1]), max$5(tempA[2], tempB[2]), max$5(tempA[3], tempB[3]));
|
|
287
|
+
},
|
|
288
|
+
add(t, other, change) {
|
|
289
|
+
if (isNumber(t) && isNumber(other)) return t + other;
|
|
290
|
+
toTempAB(t, other, change);
|
|
291
|
+
return set$1(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
|
|
292
|
+
},
|
|
293
|
+
swapAndScale(t, scaleX, scaleY, change) {
|
|
294
|
+
if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [ t * scaleY, t * scaleX ];
|
|
295
|
+
const to = change ? t : [];
|
|
296
|
+
const [top, right, bottom, left] = t.length === 4 ? t : get$5(t);
|
|
297
|
+
return set$1(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
const {set: set$1, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
|
|
301
|
+
const {round: round$6, pow: pow$2, PI: PI$4} = Math;
|
|
302
|
+
const MathHelper = {
|
|
303
|
+
within(value, min, max) {
|
|
304
|
+
if (isObject(min)) max = min.max, min = min.min;
|
|
305
|
+
if (!isUndefined(min) && value < min) value = min;
|
|
306
|
+
if (!isUndefined(max) && value > max) value = max;
|
|
307
|
+
return value;
|
|
308
|
+
},
|
|
309
|
+
fourNumber: FourNumberHelper.get,
|
|
268
310
|
formatRotation(rotation, unsign) {
|
|
269
311
|
rotation %= 360;
|
|
270
312
|
if (unsign) {
|
|
@@ -392,14 +434,23 @@ var LeaferUI = function(exports) {
|
|
|
392
434
|
t.c *= scaleY;
|
|
393
435
|
t.d *= scaleY;
|
|
394
436
|
},
|
|
437
|
+
pixelScale(t, pixelRatio, to) {
|
|
438
|
+
to || (to = t);
|
|
439
|
+
to.a = t.a * pixelRatio;
|
|
440
|
+
to.b = t.b * pixelRatio;
|
|
441
|
+
to.c = t.c * pixelRatio;
|
|
442
|
+
to.d = t.d * pixelRatio;
|
|
443
|
+
to.e = t.e * pixelRatio;
|
|
444
|
+
to.f = t.f * pixelRatio;
|
|
445
|
+
},
|
|
395
446
|
scaleOfOuter(t, origin, scaleX, scaleY) {
|
|
396
|
-
M$
|
|
397
|
-
M$
|
|
447
|
+
M$b.toInnerPoint(t, origin, tempPoint$4);
|
|
448
|
+
M$b.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
|
|
398
449
|
},
|
|
399
450
|
scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
|
|
400
|
-
M$
|
|
401
|
-
M$
|
|
402
|
-
M$
|
|
451
|
+
M$b.translateInner(t, origin.x, origin.y);
|
|
452
|
+
M$b.scale(t, scaleX, scaleY);
|
|
453
|
+
M$b.translateInner(t, -origin.x, -origin.y);
|
|
403
454
|
},
|
|
404
455
|
rotate(t, rotation) {
|
|
405
456
|
const {a: a, b: b, c: c, d: d} = t;
|
|
@@ -412,13 +463,13 @@ var LeaferUI = function(exports) {
|
|
|
412
463
|
t.d = c * sinR + d * cosR;
|
|
413
464
|
},
|
|
414
465
|
rotateOfOuter(t, origin, rotation) {
|
|
415
|
-
M$
|
|
416
|
-
M$
|
|
466
|
+
M$b.toInnerPoint(t, origin, tempPoint$4);
|
|
467
|
+
M$b.rotateOfInner(t, tempPoint$4, rotation);
|
|
417
468
|
},
|
|
418
469
|
rotateOfInner(t, origin, rotation) {
|
|
419
|
-
M$
|
|
420
|
-
M$
|
|
421
|
-
M$
|
|
470
|
+
M$b.translateInner(t, origin.x, origin.y);
|
|
471
|
+
M$b.rotate(t, rotation);
|
|
472
|
+
M$b.translateInner(t, -origin.x, -origin.y);
|
|
422
473
|
},
|
|
423
474
|
skew(t, skewX, skewY) {
|
|
424
475
|
const {a: a, b: b, c: c, d: d} = t;
|
|
@@ -434,13 +485,13 @@ var LeaferUI = function(exports) {
|
|
|
434
485
|
}
|
|
435
486
|
},
|
|
436
487
|
skewOfOuter(t, origin, skewX, skewY) {
|
|
437
|
-
M$
|
|
438
|
-
M$
|
|
488
|
+
M$b.toInnerPoint(t, origin, tempPoint$4);
|
|
489
|
+
M$b.skewOfInner(t, tempPoint$4, skewX, skewY);
|
|
439
490
|
},
|
|
440
491
|
skewOfInner(t, origin, skewX, skewY = 0) {
|
|
441
|
-
M$
|
|
442
|
-
M$
|
|
443
|
-
M$
|
|
492
|
+
M$b.translateInner(t, origin.x, origin.y);
|
|
493
|
+
M$b.skew(t, skewX, skewY);
|
|
494
|
+
M$b.translateInner(t, -origin.x, -origin.y);
|
|
444
495
|
},
|
|
445
496
|
multiply(t, child) {
|
|
446
497
|
const {a: a, b: b, c: c, d: d, e: e, f: f} = t;
|
|
@@ -479,15 +530,15 @@ var LeaferUI = function(exports) {
|
|
|
479
530
|
to.f = e * parent.b + f * parent.d + parent.f;
|
|
480
531
|
},
|
|
481
532
|
divide(t, child) {
|
|
482
|
-
M$
|
|
533
|
+
M$b.multiply(t, M$b.tempInvert(child));
|
|
483
534
|
},
|
|
484
535
|
divideParent(t, parent) {
|
|
485
|
-
M$
|
|
536
|
+
M$b.multiplyParent(t, M$b.tempInvert(parent));
|
|
486
537
|
},
|
|
487
538
|
tempInvert(t) {
|
|
488
|
-
const {tempMatrix: tempMatrix} = M$
|
|
489
|
-
M$
|
|
490
|
-
M$
|
|
539
|
+
const {tempMatrix: tempMatrix} = M$b;
|
|
540
|
+
M$b.copy(tempMatrix, t);
|
|
541
|
+
M$b.invert(tempMatrix);
|
|
491
542
|
return tempMatrix;
|
|
492
543
|
},
|
|
493
544
|
invert(t) {
|
|
@@ -565,7 +616,7 @@ var LeaferUI = function(exports) {
|
|
|
565
616
|
}
|
|
566
617
|
t.e = x;
|
|
567
618
|
t.f = y;
|
|
568
|
-
if (origin = origin || around) M$
|
|
619
|
+
if (origin = origin || around) M$b.translateInner(t, -origin.x, -origin.y, !around);
|
|
569
620
|
},
|
|
570
621
|
getLayout(t, origin, around, firstSkewY) {
|
|
571
622
|
const {a: a, b: b, c: c, d: d, e: e, f: f} = t;
|
|
@@ -626,10 +677,10 @@ var LeaferUI = function(exports) {
|
|
|
626
677
|
return world;
|
|
627
678
|
},
|
|
628
679
|
reset(t) {
|
|
629
|
-
M$
|
|
680
|
+
M$b.set(t);
|
|
630
681
|
}
|
|
631
682
|
};
|
|
632
|
-
const M$
|
|
683
|
+
const M$b = MatrixHelper;
|
|
633
684
|
const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
|
|
634
685
|
const {sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5} = Math;
|
|
635
686
|
const PointHelper = {
|
|
@@ -882,6 +933,10 @@ var LeaferUI = function(exports) {
|
|
|
882
933
|
this.scaleY *= y || x;
|
|
883
934
|
return this;
|
|
884
935
|
}
|
|
936
|
+
pixelScale(pixelRatio) {
|
|
937
|
+
MatrixHelper.pixelScale(this, pixelRatio);
|
|
938
|
+
return this;
|
|
939
|
+
}
|
|
885
940
|
scaleOfOuter(origin, x, y) {
|
|
886
941
|
MatrixHelper.scaleOfOuter(this, origin, x, y);
|
|
887
942
|
return this;
|
|
@@ -960,7 +1015,7 @@ var LeaferUI = function(exports) {
|
|
|
960
1015
|
MatrixHelper.reset(this);
|
|
961
1016
|
}
|
|
962
1017
|
}
|
|
963
|
-
const tempMatrix$
|
|
1018
|
+
const tempMatrix$2 = new Matrix;
|
|
964
1019
|
const TwoPointBoundsHelper = {
|
|
965
1020
|
tempPointBounds: {},
|
|
966
1021
|
setPoint(t, minX, minY) {
|
|
@@ -1090,9 +1145,9 @@ var LeaferUI = function(exports) {
|
|
|
1090
1145
|
let right$4, bottom$3, boundsRight, boundsBottom;
|
|
1091
1146
|
const point$2 = {};
|
|
1092
1147
|
const toPoint$5 = {};
|
|
1093
|
-
const tempBounds$
|
|
1148
|
+
const tempBounds$3 = {};
|
|
1094
1149
|
const BoundsHelper = {
|
|
1095
|
-
tempBounds: tempBounds$
|
|
1150
|
+
tempBounds: tempBounds$3,
|
|
1096
1151
|
set(t, x = 0, y = 0, width = 0, height = 0) {
|
|
1097
1152
|
t.x = x;
|
|
1098
1153
|
t.y = y;
|
|
@@ -1143,19 +1198,11 @@ var LeaferUI = function(exports) {
|
|
|
1143
1198
|
B.move(t, x, y);
|
|
1144
1199
|
return t;
|
|
1145
1200
|
},
|
|
1146
|
-
toOffsetOutBounds(t, to,
|
|
1147
|
-
if (!to)
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
}
|
|
1152
|
-
if (parent) {
|
|
1153
|
-
to.offsetX = -(B.maxX(parent) - t.x);
|
|
1154
|
-
to.offsetY = -(B.maxY(parent) - t.y);
|
|
1155
|
-
} else {
|
|
1156
|
-
to.offsetX = t.x + t.width;
|
|
1157
|
-
to.offsetY = t.y + t.height;
|
|
1158
|
-
}
|
|
1201
|
+
toOffsetOutBounds(t, to, offsetBounds) {
|
|
1202
|
+
if (!to) to = t; else copy$c(to, t);
|
|
1203
|
+
if (!offsetBounds) offsetBounds = t;
|
|
1204
|
+
to.offsetX = B.maxX(offsetBounds);
|
|
1205
|
+
to.offsetY = B.maxY(offsetBounds);
|
|
1159
1206
|
B.move(to, -to.offsetX, -to.offsetY);
|
|
1160
1207
|
},
|
|
1161
1208
|
scale(t, scaleX, scaleY = scaleX, onlySize) {
|
|
@@ -1169,9 +1216,9 @@ var LeaferUI = function(exports) {
|
|
|
1169
1216
|
t.height *= scaleY;
|
|
1170
1217
|
},
|
|
1171
1218
|
tempToOuterOf(t, matrix) {
|
|
1172
|
-
B.copy(tempBounds$
|
|
1173
|
-
B.toOuterOf(tempBounds$
|
|
1174
|
-
return tempBounds$
|
|
1219
|
+
B.copy(tempBounds$3, t);
|
|
1220
|
+
B.toOuterOf(tempBounds$3, matrix);
|
|
1221
|
+
return tempBounds$3;
|
|
1175
1222
|
},
|
|
1176
1223
|
getOuterOf(t, matrix) {
|
|
1177
1224
|
t = Object.assign({}, t);
|
|
@@ -1229,9 +1276,9 @@ var LeaferUI = function(exports) {
|
|
|
1229
1276
|
put(t, put, align = "center", putScale = 1, changeSize = true, to) {
|
|
1230
1277
|
to || (to = put);
|
|
1231
1278
|
if (isString(putScale)) putScale = B.getFitScale(t, put, putScale === "cover");
|
|
1232
|
-
tempBounds$
|
|
1233
|
-
tempBounds$
|
|
1234
|
-
AlignHelper.toPoint(align, tempBounds$
|
|
1279
|
+
tempBounds$3.width = changeSize ? put.width *= putScale : put.width * putScale;
|
|
1280
|
+
tempBounds$3.height = changeSize ? put.height *= putScale : put.height * putScale;
|
|
1281
|
+
AlignHelper.toPoint(align, tempBounds$3, t, to, true, true);
|
|
1235
1282
|
},
|
|
1236
1283
|
getSpread(t, spread, side) {
|
|
1237
1284
|
const n = {};
|
|
@@ -1301,7 +1348,7 @@ var LeaferUI = function(exports) {
|
|
|
1301
1348
|
first = false;
|
|
1302
1349
|
if (!addMode) copy$c(t, bounds);
|
|
1303
1350
|
} else {
|
|
1304
|
-
add$
|
|
1351
|
+
add$2(t, bounds);
|
|
1305
1352
|
}
|
|
1306
1353
|
}
|
|
1307
1354
|
}
|
|
@@ -1315,7 +1362,7 @@ var LeaferUI = function(exports) {
|
|
|
1315
1362
|
B.set(t, point.x, point.y);
|
|
1316
1363
|
},
|
|
1317
1364
|
addPoint(t, point) {
|
|
1318
|
-
add$
|
|
1365
|
+
add$2(t, point, true);
|
|
1319
1366
|
},
|
|
1320
1367
|
getPoints(t) {
|
|
1321
1368
|
const {x: x, y: y, width: width, height: height} = t;
|
|
@@ -1384,7 +1431,7 @@ var LeaferUI = function(exports) {
|
|
|
1384
1431
|
}
|
|
1385
1432
|
};
|
|
1386
1433
|
const B = BoundsHelper;
|
|
1387
|
-
const {add: add$
|
|
1434
|
+
const {add: add$2, copy: copy$c} = B;
|
|
1388
1435
|
class Bounds {
|
|
1389
1436
|
get minX() {
|
|
1390
1437
|
return BoundsHelper.minX(this);
|
|
@@ -1527,7 +1574,7 @@ var LeaferUI = function(exports) {
|
|
|
1527
1574
|
BoundsHelper.reset(this);
|
|
1528
1575
|
}
|
|
1529
1576
|
}
|
|
1530
|
-
const tempBounds$
|
|
1577
|
+
const tempBounds$2 = new Bounds;
|
|
1531
1578
|
class AutoBounds {
|
|
1532
1579
|
constructor(top, right, bottom, left, width, height) {
|
|
1533
1580
|
isObject(top) ? this.copy(top) : this.set(top, right, bottom, left, width, height);
|
|
@@ -1991,7 +2038,7 @@ var LeaferUI = function(exports) {
|
|
|
1991
2038
|
__decorate([ contextMethod() ], Canvas.prototype, "fillText", null);
|
|
1992
2039
|
__decorate([ contextMethod() ], Canvas.prototype, "measureText", null);
|
|
1993
2040
|
__decorate([ contextMethod() ], Canvas.prototype, "strokeText", null);
|
|
1994
|
-
const {copy: copy$b, multiplyParent: multiplyParent$4} = MatrixHelper, {round: round$4} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
|
|
2041
|
+
const {copy: copy$b, multiplyParent: multiplyParent$4, pixelScale: pixelScale} = MatrixHelper, {round: round$4} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
|
|
1995
2042
|
const minSize = {
|
|
1996
2043
|
width: 1,
|
|
1997
2044
|
height: 1,
|
|
@@ -2089,13 +2136,8 @@ var LeaferUI = function(exports) {
|
|
|
2089
2136
|
setWorld(matrix, parentMatrix) {
|
|
2090
2137
|
const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
|
|
2091
2138
|
if (parentMatrix) multiplyParent$4(matrix, parentMatrix, w);
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
w.c = matrix.c * pixelRatio;
|
|
2095
|
-
w.d = matrix.d * pixelRatio;
|
|
2096
|
-
w.e = matrix.e * pixelRatio;
|
|
2097
|
-
w.f = matrix.f * pixelRatio;
|
|
2098
|
-
if (pixelSnap) {
|
|
2139
|
+
pixelScale(matrix, pixelRatio, w);
|
|
2140
|
+
if (pixelSnap && !matrix.ignorePixelSnap) {
|
|
2099
2141
|
if (matrix.half && matrix.half * pixelRatio % 2) w.e = round$4(w.e - .5) + .5, w.f = round$4(w.f - .5) + .5; else w.e = round$4(w.e),
|
|
2100
2142
|
w.f = round$4(w.f);
|
|
2101
2143
|
}
|
|
@@ -2378,12 +2420,12 @@ var LeaferUI = function(exports) {
|
|
|
2378
2420
|
const {sin: sin$4, cos: cos$4, hypot: hypot, atan2: atan2$1, ceil: ceil$2, abs: abs$6, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
|
|
2379
2421
|
const {setPoint: setPoint$4, addPoint: addPoint$2} = TwoPointBoundsHelper;
|
|
2380
2422
|
const {set: set, toNumberPoints: toNumberPoints$1} = PointHelper;
|
|
2381
|
-
const {M: M$
|
|
2423
|
+
const {M: M$a, L: L$a, C: C$8, Q: Q$7, Z: Z$8} = PathCommandMap;
|
|
2382
2424
|
const tempPoint$2 = {};
|
|
2383
2425
|
const BezierHelper = {
|
|
2384
2426
|
points(data, originPoints, curve, close) {
|
|
2385
2427
|
let points = toNumberPoints$1(originPoints);
|
|
2386
|
-
data.push(M$
|
|
2428
|
+
data.push(M$a, points[0], points[1]);
|
|
2387
2429
|
if (curve && points.length > 5) {
|
|
2388
2430
|
let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
|
|
2389
2431
|
let ba, cb, d, len = points.length;
|
|
@@ -2490,7 +2532,7 @@ var LeaferUI = function(exports) {
|
|
|
2490
2532
|
let startX = x = rotationCos * radiusX * startCos - rotationSin * radiusY * startSin;
|
|
2491
2533
|
let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
|
|
2492
2534
|
let fromX = cx + x, fromY = cy + y;
|
|
2493
|
-
if (data) data.push(data.length ? L$a : M$
|
|
2535
|
+
if (data) data.push(data.length ? L$a : M$a, fromX, fromY);
|
|
2494
2536
|
if (setPointBounds) setPoint$4(setPointBounds, fromX, fromY);
|
|
2495
2537
|
if (setStartPoint) set(setStartPoint, fromX, fromY);
|
|
2496
2538
|
for (let i = 0; i < parts; i++) {
|
|
@@ -2615,7 +2657,7 @@ var LeaferUI = function(exports) {
|
|
|
2615
2657
|
}
|
|
2616
2658
|
}
|
|
2617
2659
|
};
|
|
2618
|
-
const {M: M$
|
|
2660
|
+
const {M: M$9, m: m, L: L$9, l: l, H: H, h: h, V: V, v: v, C: C$7, c: c, S: S, s: s, Q: Q$6, q: q, T: T, t: t, A: A, a: a, Z: Z$7, z: z, N: N$5, D: D$6, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5} = PathCommandMap;
|
|
2619
2661
|
const {rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1} = BezierHelper;
|
|
2620
2662
|
const {ellipticalArc: ellipticalArc} = EllipseHelper;
|
|
2621
2663
|
const debug$f = Debug.get("PathConvert");
|
|
@@ -2702,10 +2744,10 @@ var LeaferUI = function(exports) {
|
|
|
2702
2744
|
old[i + 1] += x;
|
|
2703
2745
|
old[i + 2] += y;
|
|
2704
2746
|
|
|
2705
|
-
case M$
|
|
2747
|
+
case M$9:
|
|
2706
2748
|
x = old[i + 1];
|
|
2707
2749
|
y = old[i + 2];
|
|
2708
|
-
data.push(M$
|
|
2750
|
+
data.push(M$9, x, y);
|
|
2709
2751
|
i += 3;
|
|
2710
2752
|
break;
|
|
2711
2753
|
|
|
@@ -2892,7 +2934,7 @@ var LeaferUI = function(exports) {
|
|
|
2892
2934
|
list.forEach(item => {
|
|
2893
2935
|
switch (item.name) {
|
|
2894
2936
|
case "M":
|
|
2895
|
-
data.push(M$
|
|
2937
|
+
data.push(M$9, item.x, item.y);
|
|
2896
2938
|
break;
|
|
2897
2939
|
|
|
2898
2940
|
case "L":
|
|
@@ -2929,7 +2971,7 @@ var LeaferUI = function(exports) {
|
|
|
2929
2971
|
}
|
|
2930
2972
|
};
|
|
2931
2973
|
const {current: current, pushData: pushData, copyData: copyData} = PathConvert;
|
|
2932
|
-
const {M: M$
|
|
2974
|
+
const {M: M$8, L: L$8, C: C$6, Q: Q$5, Z: Z$6, N: N$4, D: D$5, X: X$4, G: G$4, F: F$5, O: O$5, P: P$4, U: U$4} = PathCommandMap;
|
|
2933
2975
|
const {getMinDistanceFrom: getMinDistanceFrom, getRadianFrom: getRadianFrom} = PointHelper;
|
|
2934
2976
|
const {tan: tan, min: min, abs: abs$5} = Math;
|
|
2935
2977
|
const startPoint = {};
|
|
@@ -2938,7 +2980,7 @@ var LeaferUI = function(exports) {
|
|
|
2938
2980
|
data.length = 0;
|
|
2939
2981
|
},
|
|
2940
2982
|
moveTo(data, x, y) {
|
|
2941
|
-
data.push(M$
|
|
2983
|
+
data.push(M$8, x, y);
|
|
2942
2984
|
},
|
|
2943
2985
|
lineTo(data, x, y) {
|
|
2944
2986
|
data.push(L$8, x, y);
|
|
@@ -2993,12 +3035,12 @@ var LeaferUI = function(exports) {
|
|
|
2993
3035
|
},
|
|
2994
3036
|
drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2995
3037
|
BezierHelper.ellipse(null, x, y, radiusX, radiusY, isNull(rotation) ? 0 : rotation, isNull(startAngle) ? 0 : startAngle, isNull(endAngle) ? 360 : endAngle, anticlockwise, null, null, startPoint);
|
|
2996
|
-
data.push(M$
|
|
3038
|
+
data.push(M$8, startPoint.x, startPoint.y);
|
|
2997
3039
|
ellipse$3(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2998
3040
|
},
|
|
2999
3041
|
drawArc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
3000
3042
|
BezierHelper.arc(null, x, y, radius, isNull(startAngle) ? 0 : startAngle, isNull(endAngle) ? 360 : endAngle, anticlockwise, null, null, startPoint);
|
|
3001
|
-
data.push(M$
|
|
3043
|
+
data.push(M$8, startPoint.x, startPoint.y);
|
|
3002
3044
|
arc$2(data, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
3003
3045
|
},
|
|
3004
3046
|
drawPoints(data, points, curve, close) {
|
|
@@ -3096,7 +3138,7 @@ var LeaferUI = function(exports) {
|
|
|
3096
3138
|
}
|
|
3097
3139
|
paint() {}
|
|
3098
3140
|
}
|
|
3099
|
-
const {M: M$
|
|
3141
|
+
const {M: M$7, L: L$7, C: C$5, Q: Q$4, Z: Z$5, N: N$3, D: D$4, X: X$3, G: G$3, F: F$4, O: O$4, P: P$3, U: U$3} = PathCommandMap;
|
|
3100
3142
|
const debug$e = Debug.get("PathDrawer");
|
|
3101
3143
|
const PathDrawer = {
|
|
3102
3144
|
drawPathByData(drawer, data) {
|
|
@@ -3106,7 +3148,7 @@ var LeaferUI = function(exports) {
|
|
|
3106
3148
|
while (i < len) {
|
|
3107
3149
|
command = data[i];
|
|
3108
3150
|
switch (command) {
|
|
3109
|
-
case M$
|
|
3151
|
+
case M$7:
|
|
3110
3152
|
drawer.moveTo(data[i + 1], data[i + 2]);
|
|
3111
3153
|
i += 3;
|
|
3112
3154
|
break;
|
|
@@ -3178,7 +3220,7 @@ var LeaferUI = function(exports) {
|
|
|
3178
3220
|
}
|
|
3179
3221
|
}
|
|
3180
3222
|
};
|
|
3181
|
-
const {M: M$
|
|
3223
|
+
const {M: M$6, L: L$6, C: C$4, Q: Q$3, Z: Z$4, N: N$2, D: D$3, X: X$2, G: G$2, F: F$3, O: O$3, P: P$2, U: U$2} = PathCommandMap;
|
|
3182
3224
|
const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
|
|
3183
3225
|
const {addPointBounds: addPointBounds, copy: copy$a, addPoint: addPoint$1, setPoint: setPoint$3, addBounds: addBounds, toBounds: toBounds$2} = TwoPointBoundsHelper;
|
|
3184
3226
|
const debug$d = Debug.get("PathBounds");
|
|
@@ -3205,7 +3247,7 @@ var LeaferUI = function(exports) {
|
|
|
3205
3247
|
}
|
|
3206
3248
|
}
|
|
3207
3249
|
switch (command) {
|
|
3208
|
-
case M$
|
|
3250
|
+
case M$6:
|
|
3209
3251
|
case L$6:
|
|
3210
3252
|
x = data[i + 1];
|
|
3211
3253
|
y = data[i + 2];
|
|
@@ -3304,7 +3346,7 @@ var LeaferUI = function(exports) {
|
|
|
3304
3346
|
}
|
|
3305
3347
|
}
|
|
3306
3348
|
};
|
|
3307
|
-
const {M: M$
|
|
3349
|
+
const {M: M$5, L: L$5, Z: Z$3} = PathCommandMap;
|
|
3308
3350
|
const {getCenterX: getCenterX, getCenterY: getCenterY} = PointHelper;
|
|
3309
3351
|
const {arcTo: arcTo} = PathCommandDataHelper;
|
|
3310
3352
|
const PathCorner = {
|
|
@@ -3316,16 +3358,16 @@ var LeaferUI = function(exports) {
|
|
|
3316
3358
|
while (i < len) {
|
|
3317
3359
|
command = data[i];
|
|
3318
3360
|
switch (command) {
|
|
3319
|
-
case M$
|
|
3361
|
+
case M$5:
|
|
3320
3362
|
startX = lastX = data[i + 1];
|
|
3321
3363
|
startY = lastY = data[i + 2];
|
|
3322
3364
|
i += 3;
|
|
3323
3365
|
if (data[i] === L$5) {
|
|
3324
3366
|
secondX = data[i + 1];
|
|
3325
3367
|
secondY = data[i + 2];
|
|
3326
|
-
smooth.push(M$
|
|
3368
|
+
smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
|
|
3327
3369
|
} else {
|
|
3328
|
-
smooth.push(M$
|
|
3370
|
+
smooth.push(M$5, startX, startY);
|
|
3329
3371
|
}
|
|
3330
3372
|
break;
|
|
3331
3373
|
|
|
@@ -3745,7 +3787,7 @@ var LeaferUI = function(exports) {
|
|
|
3745
3787
|
};
|
|
3746
3788
|
const I$1 = ImageManager;
|
|
3747
3789
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
3748
|
-
const {floor: floor$2, max: max$
|
|
3790
|
+
const {floor: floor$2, max: max$4} = Math;
|
|
3749
3791
|
class LeaferImage {
|
|
3750
3792
|
get url() {
|
|
3751
3793
|
return this.config.url;
|
|
@@ -3833,7 +3875,7 @@ var LeaferUI = function(exports) {
|
|
|
3833
3875
|
}
|
|
3834
3876
|
if (data) return data;
|
|
3835
3877
|
}
|
|
3836
|
-
const canvas = Platform.origin.createCanvas(max$
|
|
3878
|
+
const canvas = Platform.origin.createCanvas(max$4(floor$2(width + (xGap || 0)), 1), max$4(floor$2(height + (yGap || 0)), 1));
|
|
3837
3879
|
const ctx = canvas.getContext("2d");
|
|
3838
3880
|
if (opacity) ctx.globalAlpha = opacity;
|
|
3839
3881
|
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
@@ -4008,6 +4050,17 @@ var LeaferUI = function(exports) {
|
|
|
4008
4050
|
}
|
|
4009
4051
|
}));
|
|
4010
4052
|
}
|
|
4053
|
+
function dimType(defaultValue) {
|
|
4054
|
+
return decorateLeafAttr(defaultValue, key => attr({
|
|
4055
|
+
set(value) {
|
|
4056
|
+
if (this.__setAttr(key, value)) {
|
|
4057
|
+
const data = this.__;
|
|
4058
|
+
DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
|
|
4059
|
+
this.__layout.surfaceChange();
|
|
4060
|
+
}
|
|
4061
|
+
}
|
|
4062
|
+
}));
|
|
4063
|
+
}
|
|
4011
4064
|
function opacityType(defaultValue) {
|
|
4012
4065
|
return decorateLeafAttr(defaultValue, key => attr({
|
|
4013
4066
|
set(value) {
|
|
@@ -4048,7 +4101,7 @@ var LeaferUI = function(exports) {
|
|
|
4048
4101
|
return decorateLeafAttr(defaultValue, key => attr({
|
|
4049
4102
|
set(value) {
|
|
4050
4103
|
if (this.__setAttr(key, value)) {
|
|
4051
|
-
this.__layout.
|
|
4104
|
+
this.__layout.surfaceChange();
|
|
4052
4105
|
this.waitParent(() => {
|
|
4053
4106
|
this.parent.__layout.childrenSortChange();
|
|
4054
4107
|
});
|
|
@@ -4082,7 +4135,7 @@ var LeaferUI = function(exports) {
|
|
|
4082
4135
|
set(value) {
|
|
4083
4136
|
if (this.__setAttr(key, value)) {
|
|
4084
4137
|
this.__layout.hitCanvasChanged = true;
|
|
4085
|
-
if (Debug.showBounds === "hit") this.__layout.
|
|
4138
|
+
if (Debug.showBounds === "hit") this.__layout.surfaceChange();
|
|
4086
4139
|
if (this.leafer) this.leafer.updateCursor();
|
|
4087
4140
|
}
|
|
4088
4141
|
}
|
|
@@ -4554,7 +4607,7 @@ var LeaferUI = function(exports) {
|
|
|
4554
4607
|
}
|
|
4555
4608
|
};
|
|
4556
4609
|
const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$3} = LeafHelper;
|
|
4557
|
-
const {toOuterOf: toOuterOf$
|
|
4610
|
+
const {toOuterOf: toOuterOf$3, getPoints: getPoints, copy: copy$8} = BoundsHelper;
|
|
4558
4611
|
const localContent = "_localContentBounds";
|
|
4559
4612
|
const worldContent = "_worldContentBounds", worldBox = "_worldBoxBounds", worldStroke = "_worldStrokeBounds";
|
|
4560
4613
|
class LeafLayout {
|
|
@@ -4574,7 +4627,7 @@ var LeaferUI = function(exports) {
|
|
|
4574
4627
|
this._renderBounds = bounds;
|
|
4575
4628
|
}
|
|
4576
4629
|
get localContentBounds() {
|
|
4577
|
-
toOuterOf$
|
|
4630
|
+
toOuterOf$3(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {}));
|
|
4578
4631
|
return this[localContent];
|
|
4579
4632
|
}
|
|
4580
4633
|
get localStrokeBounds() {
|
|
@@ -4584,15 +4637,15 @@ var LeaferUI = function(exports) {
|
|
|
4584
4637
|
return this._localRenderBounds || this;
|
|
4585
4638
|
}
|
|
4586
4639
|
get worldContentBounds() {
|
|
4587
|
-
toOuterOf$
|
|
4640
|
+
toOuterOf$3(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {}));
|
|
4588
4641
|
return this[worldContent];
|
|
4589
4642
|
}
|
|
4590
4643
|
get worldBoxBounds() {
|
|
4591
|
-
toOuterOf$
|
|
4644
|
+
toOuterOf$3(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {}));
|
|
4592
4645
|
return this[worldBox];
|
|
4593
4646
|
}
|
|
4594
4647
|
get worldStrokeBounds() {
|
|
4595
|
-
toOuterOf$
|
|
4648
|
+
toOuterOf$3(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {}));
|
|
4596
4649
|
return this[worldStroke];
|
|
4597
4650
|
}
|
|
4598
4651
|
get a() {
|
|
@@ -5363,12 +5416,12 @@ var LeaferUI = function(exports) {
|
|
|
5363
5416
|
};
|
|
5364
5417
|
const {updateMatrix: updateMatrix$3, updateAllMatrix: updateAllMatrix$3} = LeafHelper;
|
|
5365
5418
|
const {updateBounds: updateBounds$2} = BranchHelper;
|
|
5366
|
-
const {toOuterOf: toOuterOf$
|
|
5419
|
+
const {toOuterOf: toOuterOf$2, copyAndSpread: copyAndSpread$3, copy: copy$7} = BoundsHelper;
|
|
5367
5420
|
const {toBounds: toBounds$1} = PathBounds;
|
|
5368
5421
|
const LeafBounds = {
|
|
5369
5422
|
__updateWorldBounds() {
|
|
5370
5423
|
const layout = this.__layout;
|
|
5371
|
-
toOuterOf$
|
|
5424
|
+
toOuterOf$2(layout.renderBounds, this.__world, this.__world);
|
|
5372
5425
|
if (layout.resized) {
|
|
5373
5426
|
if (layout.resized === "inner") this.__onUpdateSize();
|
|
5374
5427
|
if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
|
|
@@ -5424,13 +5477,13 @@ var LeaferUI = function(exports) {
|
|
|
5424
5477
|
__updateLocalBoxBounds() {
|
|
5425
5478
|
if (this.__hasMotionPath) this.__updateMotionPath();
|
|
5426
5479
|
if (this.__hasAutoLayout) this.__updateAutoLayout();
|
|
5427
|
-
toOuterOf$
|
|
5480
|
+
toOuterOf$2(this.__layout.boxBounds, this.__local, this.__local);
|
|
5428
5481
|
},
|
|
5429
5482
|
__updateLocalStrokeBounds() {
|
|
5430
|
-
toOuterOf$
|
|
5483
|
+
toOuterOf$2(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
|
|
5431
5484
|
},
|
|
5432
5485
|
__updateLocalRenderBounds() {
|
|
5433
|
-
toOuterOf$
|
|
5486
|
+
toOuterOf$2(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
|
|
5434
5487
|
},
|
|
5435
5488
|
__updateBoxBounds(_secondLayout, _bounds) {
|
|
5436
5489
|
const b = this.__layout.boxBounds;
|
|
@@ -5468,11 +5521,11 @@ var LeaferUI = function(exports) {
|
|
|
5468
5521
|
},
|
|
5469
5522
|
__updateStrokeBounds(_bounds) {
|
|
5470
5523
|
const layout = this.__layout;
|
|
5471
|
-
copyAndSpread$
|
|
5524
|
+
copyAndSpread$3(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5472
5525
|
},
|
|
5473
5526
|
__updateRenderBounds(_bounds) {
|
|
5474
|
-
const layout = this.__layout;
|
|
5475
|
-
|
|
5527
|
+
const layout = this.__layout, {renderSpread: renderSpread} = layout;
|
|
5528
|
+
isNumber(renderSpread) && renderSpread <= 0 ? copy$7(layout.renderBounds, layout.strokeBounds) : copyAndSpread$3(layout.renderBounds, layout.boxBounds, renderSpread);
|
|
5476
5529
|
}
|
|
5477
5530
|
};
|
|
5478
5531
|
const LeafRender = {
|
|
@@ -5480,6 +5533,7 @@ var LeaferUI = function(exports) {
|
|
|
5480
5533
|
if (options.shape) return this.__renderShape(canvas, options);
|
|
5481
5534
|
if (this.__worldOpacity) {
|
|
5482
5535
|
const data = this.__;
|
|
5536
|
+
if (data.bright && !options.topRendering) return options.topList.add(this);
|
|
5483
5537
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5484
5538
|
canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
|
|
5485
5539
|
if (this.__.__single) {
|
|
@@ -5526,7 +5580,9 @@ var LeaferUI = function(exports) {
|
|
|
5526
5580
|
this.__nowWorld = this.__getNowWorld(options);
|
|
5527
5581
|
if (this.__worldOpacity) {
|
|
5528
5582
|
const data = this.__;
|
|
5529
|
-
if (data.
|
|
5583
|
+
if (data.__useDim) {
|
|
5584
|
+
if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
|
|
5585
|
+
}
|
|
5530
5586
|
if (data.__single && !this.isBranchLeaf) {
|
|
5531
5587
|
if (data.eraser === "path") return this.__renderEraser(canvas, options);
|
|
5532
5588
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
@@ -5561,9 +5617,10 @@ var LeaferUI = function(exports) {
|
|
|
5561
5617
|
};
|
|
5562
5618
|
const tempScaleData$1 = {};
|
|
5563
5619
|
const {LEAF: LEAF, create: create} = IncrementId;
|
|
5620
|
+
const {stintSet: stintSet$3} = DataHelper;
|
|
5564
5621
|
const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
|
|
5565
|
-
const {toOuterOf: toOuterOf} = BoundsHelper;
|
|
5566
|
-
const {copy: copy$6, move: move$
|
|
5622
|
+
const {toOuterOf: toOuterOf$1} = BoundsHelper;
|
|
5623
|
+
const {copy: copy$6, move: move$8} = PointHelper;
|
|
5567
5624
|
const {moveLocal: moveLocal, zoomOfLocal: zoomOfLocal, rotateOfLocal: rotateOfLocal, skewOfLocal: skewOfLocal, moveWorld: moveWorld, zoomOfWorld: zoomOfWorld, rotateOfWorld: rotateOfWorld, skewOfWorld: skewOfWorld, transform: transform, transformWorld: transformWorld, setTransform: setTransform, getFlipTransform: getFlipTransform, getLocalOrigin: getLocalOrigin, getRelativeWorld: getRelativeWorld, drop: drop} = LeafHelper;
|
|
5568
5625
|
exports.Leaf = class Leaf {
|
|
5569
5626
|
get tag() {
|
|
@@ -5837,8 +5894,9 @@ var LeaferUI = function(exports) {
|
|
|
5837
5894
|
if (!this.__cameraWorld) this.__cameraWorld = {};
|
|
5838
5895
|
const cameraWorld = this.__cameraWorld, world = this.__world;
|
|
5839
5896
|
multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
|
|
5840
|
-
toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
|
|
5841
|
-
cameraWorld
|
|
5897
|
+
toOuterOf$1(this.__layout.renderBounds, cameraWorld, cameraWorld);
|
|
5898
|
+
stintSet$3(cameraWorld, "half", world.half);
|
|
5899
|
+
stintSet$3(cameraWorld, "ignorePixelSnap", world.ignorePixelSnap);
|
|
5842
5900
|
return cameraWorld;
|
|
5843
5901
|
} else {
|
|
5844
5902
|
return this.__world;
|
|
@@ -5872,7 +5930,7 @@ var LeaferUI = function(exports) {
|
|
|
5872
5930
|
getWorldBounds(inner, relative, change) {
|
|
5873
5931
|
const matrix = relative ? getRelativeWorld(this, relative) : this.worldTransform;
|
|
5874
5932
|
const to = change ? inner : {};
|
|
5875
|
-
toOuterOf(inner, matrix, to);
|
|
5933
|
+
toOuterOf$1(inner, matrix, to);
|
|
5876
5934
|
return to;
|
|
5877
5935
|
}
|
|
5878
5936
|
worldToLocal(world, to, distance, relative) {
|
|
@@ -5905,7 +5963,7 @@ var LeaferUI = function(exports) {
|
|
|
5905
5963
|
}
|
|
5906
5964
|
getBoxPointByInner(inner, _relative, _distance, change) {
|
|
5907
5965
|
const point = change ? inner : Object.assign({}, inner), {x: x, y: y} = this.boxBounds;
|
|
5908
|
-
move$
|
|
5966
|
+
move$8(point, -x, -y);
|
|
5909
5967
|
return point;
|
|
5910
5968
|
}
|
|
5911
5969
|
getInnerPoint(world, relative, distance, change) {
|
|
@@ -5915,7 +5973,7 @@ var LeaferUI = function(exports) {
|
|
|
5915
5973
|
}
|
|
5916
5974
|
getInnerPointByBox(box, _relative, _distance, change) {
|
|
5917
5975
|
const point = change ? box : Object.assign({}, box), {x: x, y: y} = this.boxBounds;
|
|
5918
|
-
move$
|
|
5976
|
+
move$8(point, x, y);
|
|
5919
5977
|
return point;
|
|
5920
5978
|
}
|
|
5921
5979
|
getInnerPointByLocal(local, _relative, distance, change) {
|
|
@@ -6351,7 +6409,7 @@ var LeaferUI = function(exports) {
|
|
|
6351
6409
|
this.levelMap = null;
|
|
6352
6410
|
}
|
|
6353
6411
|
}
|
|
6354
|
-
const version = "1.9.
|
|
6412
|
+
const version = "1.9.8";
|
|
6355
6413
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6356
6414
|
get allowBackgroundColor() {
|
|
6357
6415
|
return true;
|
|
@@ -6749,6 +6807,7 @@ var LeaferUI = function(exports) {
|
|
|
6749
6807
|
usePartRender: true,
|
|
6750
6808
|
maxFPS: 120
|
|
6751
6809
|
};
|
|
6810
|
+
this.frames = [];
|
|
6752
6811
|
this.target = target;
|
|
6753
6812
|
this.canvas = canvas;
|
|
6754
6813
|
if (userConfig) this.config = DataHelper.default(userConfig, this.config);
|
|
@@ -6878,7 +6937,7 @@ var LeaferUI = function(exports) {
|
|
|
6878
6937
|
};
|
|
6879
6938
|
if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
|
|
6880
6939
|
if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
|
|
6881
|
-
this.target
|
|
6940
|
+
Platform.render(this.target, canvas, options);
|
|
6882
6941
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
6883
6942
|
this.renderOptions = options;
|
|
6884
6943
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
@@ -6901,12 +6960,15 @@ var LeaferUI = function(exports) {
|
|
|
6901
6960
|
const target = this.target;
|
|
6902
6961
|
if (this.requestTime || !target) return;
|
|
6903
6962
|
if (target.parentApp) return target.parentApp.requestRender(false);
|
|
6904
|
-
|
|
6963
|
+
this.requestTime = this.frameTime || Date.now();
|
|
6905
6964
|
const render = () => {
|
|
6906
|
-
const nowFPS = 1e3 / (Date.now() - requestTime);
|
|
6965
|
+
const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
|
|
6907
6966
|
const {maxFPS: maxFPS} = this.config;
|
|
6908
|
-
if (maxFPS && nowFPS > maxFPS
|
|
6909
|
-
|
|
6967
|
+
if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
|
|
6968
|
+
const {frames: frames} = this;
|
|
6969
|
+
if (frames.length > 30) frames.shift();
|
|
6970
|
+
frames.push(nowFPS);
|
|
6971
|
+
this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
|
|
6910
6972
|
this.requestTime = 0;
|
|
6911
6973
|
this.checkRender();
|
|
6912
6974
|
};
|
|
@@ -7147,6 +7209,14 @@ var LeaferUI = function(exports) {
|
|
|
7147
7209
|
selector: (target, options) => new Selector(target, options)
|
|
7148
7210
|
});
|
|
7149
7211
|
Platform.layout = Layouter.fullLayout;
|
|
7212
|
+
Platform.render = function(target, canvas, options) {
|
|
7213
|
+
const topOptions = Object.assign(Object.assign({}, options), {
|
|
7214
|
+
topRendering: true
|
|
7215
|
+
});
|
|
7216
|
+
options.topList = new LeafList;
|
|
7217
|
+
target.__render(canvas, options);
|
|
7218
|
+
if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
|
|
7219
|
+
};
|
|
7150
7220
|
function effectType(defaultValue) {
|
|
7151
7221
|
return decorateLeafAttr(defaultValue, key => attr({
|
|
7152
7222
|
set(value) {
|
|
@@ -7508,39 +7578,40 @@ var LeaferUI = function(exports) {
|
|
|
7508
7578
|
return data;
|
|
7509
7579
|
}
|
|
7510
7580
|
}
|
|
7581
|
+
const {max: max$3, add: add$1} = FourNumberHelper;
|
|
7511
7582
|
const UIBounds = {
|
|
7512
7583
|
__updateStrokeSpread() {
|
|
7513
|
-
let
|
|
7584
|
+
let spread = 0, boxSpread = 0;
|
|
7514
7585
|
const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
|
|
7515
7586
|
if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
|
|
7516
|
-
|
|
7587
|
+
boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
|
|
7517
7588
|
if (!data.__boxStroke) {
|
|
7518
|
-
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 *
|
|
7589
|
+
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
|
|
7519
7590
|
const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
|
|
7520
|
-
|
|
7591
|
+
spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
|
|
7521
7592
|
}
|
|
7522
7593
|
}
|
|
7523
|
-
if (data.__useArrow)
|
|
7594
|
+
if (data.__useArrow) spread += strokeWidth * 5;
|
|
7524
7595
|
if (box) {
|
|
7525
|
-
|
|
7526
|
-
|
|
7596
|
+
spread = max$3(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
|
|
7597
|
+
boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
|
|
7527
7598
|
}
|
|
7528
|
-
this.__layout.strokeBoxSpread =
|
|
7529
|
-
return
|
|
7599
|
+
this.__layout.strokeBoxSpread = boxSpread;
|
|
7600
|
+
return spread;
|
|
7530
7601
|
},
|
|
7531
7602
|
__updateRenderSpread() {
|
|
7532
|
-
let
|
|
7533
|
-
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
|
|
7534
|
-
if (shadow)
|
|
7535
|
-
if (blur)
|
|
7536
|
-
if (filter)
|
|
7537
|
-
if (renderSpread)
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
if (
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
return
|
|
7603
|
+
let spread = 0;
|
|
7604
|
+
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
|
|
7605
|
+
if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
|
|
7606
|
+
if (blur) spread = max$3(spread, blur);
|
|
7607
|
+
if (filter) spread = add$1(spread, Filter.getSpread(filter));
|
|
7608
|
+
if (renderSpread) spread = add$1(spread, renderSpread);
|
|
7609
|
+
if (strokeSpread) spread = add$1(spread, strokeSpread);
|
|
7610
|
+
let shapeSpread = spread;
|
|
7611
|
+
if (innerShadow) shapeSpread = max$3(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
|
|
7612
|
+
if (backgroundBlur) shapeSpread = max$3(shapeSpread, backgroundBlur);
|
|
7613
|
+
this.__layout.renderShapeSpread = shapeSpread;
|
|
7614
|
+
return box ? max$3(box.__updateRenderSpread(), spread) : spread;
|
|
7544
7615
|
}
|
|
7545
7616
|
};
|
|
7546
7617
|
const {float: float$1} = MathHelper;
|
|
@@ -7864,8 +7935,8 @@ var LeaferUI = function(exports) {
|
|
|
7864
7935
|
__decorate([ opacityType(1) ], exports.UI.prototype, "opacity", void 0);
|
|
7865
7936
|
__decorate([ visibleType(true) ], exports.UI.prototype, "visible", void 0);
|
|
7866
7937
|
__decorate([ surfaceType(false) ], exports.UI.prototype, "locked", void 0);
|
|
7867
|
-
__decorate([
|
|
7868
|
-
__decorate([
|
|
7938
|
+
__decorate([ dimType(false) ], exports.UI.prototype, "dim", void 0);
|
|
7939
|
+
__decorate([ dimType(false) ], exports.UI.prototype, "dimskip", void 0);
|
|
7869
7940
|
__decorate([ sortType(0) ], exports.UI.prototype, "zIndex", void 0);
|
|
7870
7941
|
__decorate([ maskType(false) ], exports.UI.prototype, "mask", void 0);
|
|
7871
7942
|
__decorate([ eraserType(false) ], exports.UI.prototype, "eraser", void 0);
|
|
@@ -8682,7 +8753,7 @@ var LeaferUI = function(exports) {
|
|
|
8682
8753
|
__decorate([ dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
|
|
8683
8754
|
__decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
|
|
8684
8755
|
exports.Canvas = __decorate([ registerUI() ], exports.Canvas);
|
|
8685
|
-
const {copyAndSpread: copyAndSpread$
|
|
8756
|
+
const {copyAndSpread: copyAndSpread$2, includes: includes, spread: spread, setList: setList} = BoundsHelper;
|
|
8686
8757
|
exports.Text = class Text extends exports.UI {
|
|
8687
8758
|
get __tag() {
|
|
8688
8759
|
return "Text";
|
|
@@ -8728,13 +8799,13 @@ var LeaferUI = function(exports) {
|
|
|
8728
8799
|
if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
|
|
8729
8800
|
}
|
|
8730
8801
|
__updateRenderSpread() {
|
|
8731
|
-
let
|
|
8732
|
-
if (!
|
|
8733
|
-
return
|
|
8802
|
+
let spread = super.__updateRenderSpread();
|
|
8803
|
+
if (!spread) spread = this.isOverflow ? 1 : 0;
|
|
8804
|
+
return spread;
|
|
8734
8805
|
}
|
|
8735
8806
|
__updateRenderBounds() {
|
|
8736
8807
|
const {renderBounds: renderBounds, renderSpread: renderSpread} = this.__layout;
|
|
8737
|
-
copyAndSpread$
|
|
8808
|
+
copyAndSpread$2(renderBounds, this.__.__textBoxBounds, renderSpread);
|
|
8738
8809
|
if (this.__box) this.__box.__layout.renderBounds = renderBounds;
|
|
8739
8810
|
}
|
|
8740
8811
|
__updateChange() {
|
|
@@ -9093,9 +9164,9 @@ var LeaferUI = function(exports) {
|
|
|
9093
9164
|
static setData(data) {
|
|
9094
9165
|
this.data = data;
|
|
9095
9166
|
}
|
|
9096
|
-
static getValidMove(leaf,
|
|
9097
|
-
const move = leaf.getLocalPoint(
|
|
9098
|
-
PointHelper.move(move,
|
|
9167
|
+
static getValidMove(leaf, localStart, worldTotal, checkLimit = true) {
|
|
9168
|
+
const move = leaf.getLocalPoint(worldTotal, null, true);
|
|
9169
|
+
PointHelper.move(move, localStart.x - leaf.x, localStart.y - leaf.y);
|
|
9099
9170
|
if (checkLimit) this.limitMove(leaf, move);
|
|
9100
9171
|
DragBoundsHelper.axisMove(leaf, move);
|
|
9101
9172
|
return move;
|
|
@@ -10049,8 +10120,8 @@ var LeaferUI = function(exports) {
|
|
|
10049
10120
|
if (isHitPixel) {
|
|
10050
10121
|
const {renderBounds: renderBounds} = this.__layout;
|
|
10051
10122
|
const size = Platform.image.hitCanvasSize;
|
|
10052
|
-
const scale = h.hitScale = tempBounds$
|
|
10053
|
-
const {x: x, y: y, width: width, height: height} = tempBounds$
|
|
10123
|
+
const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
|
|
10124
|
+
const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
|
|
10054
10125
|
h.resize({
|
|
10055
10126
|
width: width,
|
|
10056
10127
|
height: height,
|
|
@@ -10137,8 +10208,8 @@ var LeaferUI = function(exports) {
|
|
|
10137
10208
|
canvas$1.hitPixel = function(radiusPoint, offset, scale = 1) {
|
|
10138
10209
|
let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
|
|
10139
10210
|
if (offset) x -= offset.x, y -= offset.y;
|
|
10140
|
-
tempBounds$
|
|
10141
|
-
const {data: data} = this.context.getImageData(tempBounds$
|
|
10211
|
+
tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
|
|
10212
|
+
const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
|
|
10142
10213
|
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
10143
10214
|
if (data[i + 3] > 0) return true;
|
|
10144
10215
|
}
|
|
@@ -10323,23 +10394,27 @@ var LeaferUI = function(exports) {
|
|
|
10323
10394
|
out.recycle(ui.__nowWorld);
|
|
10324
10395
|
}
|
|
10325
10396
|
}
|
|
10326
|
-
const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
|
|
10397
|
+
const {getSpread: getSpread, copyAndSpread: copyAndSpread$1, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$7, getIntersectData: getIntersectData} = BoundsHelper;
|
|
10398
|
+
const tempBounds$1 = {};
|
|
10327
10399
|
function shape(ui, current, options) {
|
|
10328
10400
|
const canvas = current.getSameCanvas();
|
|
10329
|
-
const nowWorld = ui.__nowWorld,
|
|
10330
|
-
|
|
10401
|
+
const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
|
|
10402
|
+
const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
|
|
10403
|
+
toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$1, layout.boxBounds, layout.strokeSpread),
|
|
10404
|
+
tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
|
|
10405
|
+
let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
|
|
10331
10406
|
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
10332
|
-
if (currentBounds.includes(
|
|
10407
|
+
if (currentBounds.includes(nowWorldShapeBounds)) {
|
|
10333
10408
|
worldCanvas = canvas;
|
|
10334
|
-
bounds = shapeBounds =
|
|
10409
|
+
bounds = shapeBounds = nowWorldShapeBounds;
|
|
10410
|
+
renderBounds = nowWorld;
|
|
10335
10411
|
} else {
|
|
10336
|
-
const {renderShapeSpread: spread} = ui.__layout;
|
|
10337
10412
|
let worldClipBounds;
|
|
10338
10413
|
if (Platform.fullImageShadow) {
|
|
10339
|
-
worldClipBounds =
|
|
10414
|
+
worldClipBounds = nowWorldShapeBounds;
|
|
10340
10415
|
} else {
|
|
10341
|
-
const spreadBounds =
|
|
10342
|
-
worldClipBounds = getIntersectData(spreadBounds,
|
|
10416
|
+
const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
|
|
10417
|
+
worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
|
|
10343
10418
|
}
|
|
10344
10419
|
fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
|
|
10345
10420
|
let {a: fitScaleX, d: fitScaleY} = fitMatrix;
|
|
@@ -10349,8 +10424,10 @@ var LeaferUI = function(exports) {
|
|
|
10349
10424
|
scaleX *= fitScaleX;
|
|
10350
10425
|
scaleY *= fitScaleY;
|
|
10351
10426
|
}
|
|
10352
|
-
shapeBounds = getOuterOf(
|
|
10427
|
+
shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
|
|
10353
10428
|
bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
|
|
10429
|
+
renderBounds = getOuterOf(nowWorld, fitMatrix);
|
|
10430
|
+
move$7(renderBounds, -fitMatrix.e, -fitMatrix.f);
|
|
10354
10431
|
const userMatrix = options.matrix;
|
|
10355
10432
|
if (userMatrix) {
|
|
10356
10433
|
matrix = new Matrix(fitMatrix);
|
|
@@ -10369,6 +10446,7 @@ var LeaferUI = function(exports) {
|
|
|
10369
10446
|
matrix: matrix,
|
|
10370
10447
|
fitMatrix: fitMatrix,
|
|
10371
10448
|
bounds: bounds,
|
|
10449
|
+
renderBounds: renderBounds,
|
|
10372
10450
|
worldCanvas: worldCanvas,
|
|
10373
10451
|
shapeBounds: shapeBounds,
|
|
10374
10452
|
scaleX: scaleX,
|
|
@@ -10466,7 +10544,7 @@ var LeaferUI = function(exports) {
|
|
|
10466
10544
|
drawTextStroke: drawTextStroke,
|
|
10467
10545
|
shape: shape
|
|
10468
10546
|
};
|
|
10469
|
-
let origin$1 = {}, tempMatrix = getMatrixData();
|
|
10547
|
+
let origin$1 = {}, tempMatrix$1 = getMatrixData();
|
|
10470
10548
|
const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper} = MatrixHelper;
|
|
10471
10549
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10472
10550
|
const transform = get$3();
|
|
@@ -10478,12 +10556,12 @@ var LeaferUI = function(exports) {
|
|
|
10478
10556
|
}, rotation);
|
|
10479
10557
|
data.transform = transform;
|
|
10480
10558
|
}
|
|
10481
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew,
|
|
10559
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
10482
10560
|
const transform = get$3();
|
|
10483
10561
|
layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
10484
|
-
if (
|
|
10485
|
-
tempMatrix.a =
|
|
10486
|
-
multiplyParent(transform, tempMatrix);
|
|
10562
|
+
if (clipScaleX) {
|
|
10563
|
+
tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
|
|
10564
|
+
multiplyParent(transform, tempMatrix$1);
|
|
10487
10565
|
}
|
|
10488
10566
|
data.transform = transform;
|
|
10489
10567
|
}
|
|
@@ -10576,7 +10654,12 @@ var LeaferUI = function(exports) {
|
|
|
10576
10654
|
|
|
10577
10655
|
case "normal":
|
|
10578
10656
|
case "clip":
|
|
10579
|
-
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
10657
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
10658
|
+
let clipScaleX, clipScaleY;
|
|
10659
|
+
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
10660
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
10661
|
+
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
10662
|
+
}
|
|
10580
10663
|
break;
|
|
10581
10664
|
|
|
10582
10665
|
case "repeat":
|
|
@@ -10721,7 +10804,7 @@ var LeaferUI = function(exports) {
|
|
|
10721
10804
|
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
10722
10805
|
}
|
|
10723
10806
|
const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
|
|
10724
|
-
const {floor: floor$1, ceil: ceil$1, max: max$
|
|
10807
|
+
const {floor: floor$1, ceil: ceil$1, max: max$2, abs: abs$4} = Math;
|
|
10725
10808
|
function createPattern(ui, paint, pixelRatio) {
|
|
10726
10809
|
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
10727
10810
|
const id = scaleX + "-" + scaleY + "-" + pixelRatio;
|
|
@@ -10769,8 +10852,8 @@ var LeaferUI = function(exports) {
|
|
|
10769
10852
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10770
10853
|
const canvasWidth = width + (xGap || 0);
|
|
10771
10854
|
const canvasHeight = height + (yGap || 0);
|
|
10772
|
-
scaleX /= canvasWidth / max$
|
|
10773
|
-
scaleY /= canvasHeight / max$
|
|
10855
|
+
scaleX /= canvasWidth / max$2(floor$1(canvasWidth), 1);
|
|
10856
|
+
scaleY /= canvasHeight / max$2(floor$1(canvasHeight), 1);
|
|
10774
10857
|
if (!imageMatrix) {
|
|
10775
10858
|
imageMatrix = get$1();
|
|
10776
10859
|
if (transform) copy$4(imageMatrix, transform);
|
|
@@ -10795,17 +10878,15 @@ var LeaferUI = function(exports) {
|
|
|
10795
10878
|
if (allowDraw) {
|
|
10796
10879
|
if (data.repeat) {
|
|
10797
10880
|
allowDraw = false;
|
|
10798
|
-
} else {
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
height *= data.scaleY;
|
|
10806
|
-
}
|
|
10807
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
10881
|
+
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
|
|
10882
|
+
let {width: width, height: height} = data;
|
|
10883
|
+
width *= scaleX * pixelRatio;
|
|
10884
|
+
height *= scaleY * pixelRatio;
|
|
10885
|
+
if (data.scaleX) {
|
|
10886
|
+
width *= data.scaleX;
|
|
10887
|
+
height *= data.scaleY;
|
|
10808
10888
|
}
|
|
10889
|
+
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
10809
10890
|
}
|
|
10810
10891
|
}
|
|
10811
10892
|
if (allowDraw) {
|
|
@@ -10963,17 +11044,17 @@ var LeaferUI = function(exports) {
|
|
|
10963
11044
|
conicGradient: conicGradient,
|
|
10964
11045
|
getTransform: getTransform
|
|
10965
11046
|
};
|
|
10966
|
-
const {copy: copy$3, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
|
|
10967
|
-
const tempBounds = {};
|
|
11047
|
+
const {copy: copy$3, move: move$6, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max$1} = Math;
|
|
11048
|
+
const tempBounds = {}, tempMatrix = new Matrix;
|
|
10968
11049
|
const offsetOutBounds$1 = {};
|
|
10969
11050
|
function shadow$1(ui, current, shape) {
|
|
10970
|
-
let copyBounds,
|
|
10971
|
-
const {__nowWorld: nowWorld
|
|
11051
|
+
let copyBounds, transform;
|
|
11052
|
+
const {__nowWorld: nowWorld} = ui;
|
|
10972
11053
|
const {shadow: shadow} = ui.__;
|
|
10973
|
-
const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
11054
|
+
const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
10974
11055
|
const other = current.getSameCanvas();
|
|
10975
11056
|
const end = shadow.length - 1;
|
|
10976
|
-
toOffsetOutBounds$1(bounds, offsetOutBounds$1);
|
|
11057
|
+
toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
|
|
10977
11058
|
shadow.forEach((item, index) => {
|
|
10978
11059
|
let otherScale = 1;
|
|
10979
11060
|
if (item.scaleFixed) {
|
|
@@ -10981,63 +11062,69 @@ var LeaferUI = function(exports) {
|
|
|
10981
11062
|
if (sx > 1) otherScale = 1 / sx;
|
|
10982
11063
|
}
|
|
10983
11064
|
other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
|
|
10984
|
-
|
|
10985
|
-
|
|
10986
|
-
|
|
11065
|
+
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
|
|
11066
|
+
if (transform) other.setTransform(transform);
|
|
11067
|
+
drawWorldShadow(other, offsetOutBounds$1, shape);
|
|
11068
|
+
if (transform) other.resetTransform();
|
|
11069
|
+
copyBounds = renderBounds;
|
|
10987
11070
|
if (item.box) {
|
|
10988
11071
|
other.restore();
|
|
10989
11072
|
other.save();
|
|
10990
11073
|
if (worldCanvas) {
|
|
10991
|
-
other.copyWorld(other,
|
|
11074
|
+
other.copyWorld(other, renderBounds, nowWorld, "copy");
|
|
10992
11075
|
copyBounds = nowWorld;
|
|
10993
11076
|
}
|
|
10994
11077
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
|
|
10995
11078
|
}
|
|
10996
|
-
|
|
11079
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
10997
11080
|
if (end && index < end) other.clearWorld(copyBounds);
|
|
10998
11081
|
});
|
|
10999
11082
|
other.recycle(copyBounds);
|
|
11000
11083
|
}
|
|
11001
|
-
function
|
|
11002
|
-
let
|
|
11003
|
-
shadow.forEach(item =>
|
|
11004
|
-
|
|
11084
|
+
function getShadowRenderSpread(_ui, shadow) {
|
|
11085
|
+
let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
|
|
11086
|
+
shadow.forEach(item => {
|
|
11087
|
+
x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
|
|
11088
|
+
top = max$1(top, spread + blur - y);
|
|
11089
|
+
right = max$1(right, spread + blur + x);
|
|
11090
|
+
bottom = max$1(bottom, spread + blur + y);
|
|
11091
|
+
left = max$1(left, spread + blur - x);
|
|
11092
|
+
});
|
|
11093
|
+
return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
|
|
11094
|
+
}
|
|
11095
|
+
function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
|
|
11096
|
+
if (shadow.spread) {
|
|
11097
|
+
const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
|
|
11098
|
+
tempMatrix.set().scaleOfOuter({
|
|
11099
|
+
x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
|
|
11100
|
+
y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
|
|
11101
|
+
}, spreadScale);
|
|
11102
|
+
return tempMatrix;
|
|
11103
|
+
}
|
|
11104
|
+
return undefined;
|
|
11005
11105
|
}
|
|
11006
|
-
function drawWorldShadow(canvas, outBounds,
|
|
11007
|
-
const {
|
|
11106
|
+
function drawWorldShadow(canvas, outBounds, shape) {
|
|
11107
|
+
const {shapeBounds: shapeBounds} = shape;
|
|
11108
|
+
let from, to;
|
|
11008
11109
|
if (Platform.fullImageShadow) {
|
|
11009
11110
|
copy$3(tempBounds, canvas.bounds);
|
|
11010
|
-
tempBounds.x
|
|
11011
|
-
|
|
11012
|
-
if (spreadScale) {
|
|
11013
|
-
const {fitMatrix: fitMatrix} = shape;
|
|
11014
|
-
tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
|
|
11015
|
-
tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
|
|
11016
|
-
tempBounds.width *= spreadScale;
|
|
11017
|
-
tempBounds.height *= spreadScale;
|
|
11018
|
-
}
|
|
11019
|
-
canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
|
|
11111
|
+
move$6(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
|
|
11112
|
+
from = canvas.bounds, to = tempBounds;
|
|
11020
11113
|
} else {
|
|
11021
|
-
|
|
11022
|
-
copy$3(tempBounds, outBounds);
|
|
11023
|
-
tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
|
|
11024
|
-
tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
|
|
11025
|
-
tempBounds.width *= spreadScale;
|
|
11026
|
-
tempBounds.height *= spreadScale;
|
|
11027
|
-
}
|
|
11028
|
-
canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
|
|
11114
|
+
from = shapeBounds, to = outBounds;
|
|
11029
11115
|
}
|
|
11116
|
+
canvas.copyWorld(shape.canvas, from, to);
|
|
11030
11117
|
}
|
|
11031
11118
|
const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
|
|
11032
11119
|
const offsetOutBounds = {};
|
|
11033
11120
|
function innerShadow(ui, current, shape) {
|
|
11034
|
-
let copyBounds,
|
|
11035
|
-
const {__nowWorld: nowWorld
|
|
11121
|
+
let copyBounds, transform;
|
|
11122
|
+
const {__nowWorld: nowWorld} = ui;
|
|
11036
11123
|
const {innerShadow: innerShadow} = ui.__;
|
|
11037
|
-
const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
11124
|
+
const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
11038
11125
|
const other = current.getSameCanvas();
|
|
11039
11126
|
const end = innerShadow.length - 1;
|
|
11040
|
-
toOffsetOutBounds(bounds, offsetOutBounds);
|
|
11127
|
+
toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
|
|
11041
11128
|
innerShadow.forEach((item, index) => {
|
|
11042
11129
|
let otherScale = 1;
|
|
11043
11130
|
if (item.scaleFixed) {
|
|
@@ -11046,16 +11133,17 @@ var LeaferUI = function(exports) {
|
|
|
11046
11133
|
}
|
|
11047
11134
|
other.save();
|
|
11048
11135
|
other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
|
|
11049
|
-
|
|
11050
|
-
|
|
11136
|
+
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
|
|
11137
|
+
if (transform) other.setTransform(transform);
|
|
11138
|
+
drawWorldShadow(other, offsetOutBounds, shape);
|
|
11051
11139
|
other.restore();
|
|
11052
11140
|
if (worldCanvas) {
|
|
11053
|
-
other.copyWorld(other,
|
|
11141
|
+
other.copyWorld(other, renderBounds, nowWorld, "copy");
|
|
11054
11142
|
other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
|
|
11055
11143
|
copyBounds = nowWorld;
|
|
11056
11144
|
} else {
|
|
11057
11145
|
other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
|
|
11058
|
-
copyBounds =
|
|
11146
|
+
copyBounds = renderBounds;
|
|
11059
11147
|
}
|
|
11060
11148
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
|
|
11061
11149
|
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
@@ -11063,6 +11151,7 @@ var LeaferUI = function(exports) {
|
|
|
11063
11151
|
});
|
|
11064
11152
|
other.recycle(copyBounds);
|
|
11065
11153
|
}
|
|
11154
|
+
const getInnerShadowSpread = getShadowRenderSpread;
|
|
11066
11155
|
function blur(ui, current, origin) {
|
|
11067
11156
|
const {blur: blur} = ui.__;
|
|
11068
11157
|
origin.setWorldBlur(blur * ui.__nowWorld.a);
|
|
@@ -11075,10 +11164,12 @@ var LeaferUI = function(exports) {
|
|
|
11075
11164
|
innerShadow: innerShadow,
|
|
11076
11165
|
blur: blur,
|
|
11077
11166
|
backgroundBlur: backgroundBlur,
|
|
11078
|
-
|
|
11167
|
+
getShadowRenderSpread: getShadowRenderSpread,
|
|
11168
|
+
getShadowTransform: getShadowTransform,
|
|
11079
11169
|
isTransformShadow(_shadow) {
|
|
11080
11170
|
return undefined;
|
|
11081
|
-
}
|
|
11171
|
+
},
|
|
11172
|
+
getInnerShadowSpread: getInnerShadowSpread
|
|
11082
11173
|
};
|
|
11083
11174
|
const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
|
|
11084
11175
|
let usedGrayscaleAlpha;
|
|
@@ -11092,6 +11183,7 @@ var LeaferUI = function(exports) {
|
|
|
11092
11183
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
|
|
11093
11184
|
maskCanvas = contentCanvas = null;
|
|
11094
11185
|
}
|
|
11186
|
+
if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
11095
11187
|
maskOpacity = child.__.opacity;
|
|
11096
11188
|
usedGrayscaleAlpha = false;
|
|
11097
11189
|
if (mask === "path" || mask === "clipping-path") {
|
|
@@ -11109,7 +11201,6 @@ var LeaferUI = function(exports) {
|
|
|
11109
11201
|
if (!contentCanvas) contentCanvas = getCanvas(canvas);
|
|
11110
11202
|
child.__render(maskCanvas, options);
|
|
11111
11203
|
}
|
|
11112
|
-
if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
11113
11204
|
continue;
|
|
11114
11205
|
}
|
|
11115
11206
|
const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
|
|
@@ -11670,22 +11761,25 @@ var LeaferUI = function(exports) {
|
|
|
11670
11761
|
set(value) {
|
|
11671
11762
|
const old = this[privateKey];
|
|
11672
11763
|
if (old !== value) {
|
|
11673
|
-
|
|
11764
|
+
const t = this;
|
|
11765
|
+
if (t.config) {
|
|
11674
11766
|
const isSelect = key === "target";
|
|
11675
11767
|
if (isSelect) {
|
|
11676
|
-
|
|
11677
|
-
if (this.single) this.element.syncEventer = null;
|
|
11678
|
-
const {beforeSelect: beforeSelect} = this.config;
|
|
11768
|
+
const {beforeSelect: beforeSelect} = t.config;
|
|
11679
11769
|
if (beforeSelect) {
|
|
11680
11770
|
const check = beforeSelect({
|
|
11681
11771
|
target: value
|
|
11682
11772
|
});
|
|
11683
11773
|
if (isObject(check)) value = check; else if (check === false) return;
|
|
11684
11774
|
}
|
|
11775
|
+
t.setDimOthers(false);
|
|
11776
|
+
t.setBright(false);
|
|
11777
|
+
if (isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
|
|
11778
|
+
if (t.single) t.element.syncEventer = null;
|
|
11685
11779
|
}
|
|
11686
11780
|
const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
|
|
11687
11781
|
if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, {
|
|
11688
|
-
editor:
|
|
11782
|
+
editor: t,
|
|
11689
11783
|
value: value,
|
|
11690
11784
|
oldValue: old
|
|
11691
11785
|
}));
|
|
@@ -11852,11 +11946,12 @@ var LeaferUI = function(exports) {
|
|
|
11852
11946
|
return !!this.originList;
|
|
11853
11947
|
}
|
|
11854
11948
|
get running() {
|
|
11855
|
-
const {editor: editor} = this;
|
|
11856
|
-
return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector &&
|
|
11949
|
+
const {editor: editor, app: app} = this;
|
|
11950
|
+
return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && (app && app.mode === "normal");
|
|
11857
11951
|
}
|
|
11858
11952
|
get isMoveMode() {
|
|
11859
|
-
|
|
11953
|
+
const {app: app} = this;
|
|
11954
|
+
return app && app.interaction.moveMode;
|
|
11860
11955
|
}
|
|
11861
11956
|
constructor(editor) {
|
|
11862
11957
|
super();
|
|
@@ -11919,12 +12014,12 @@ var LeaferUI = function(exports) {
|
|
|
11919
12014
|
onTap(e) {
|
|
11920
12015
|
if (e.multiTouch) return;
|
|
11921
12016
|
const {editor: editor} = this;
|
|
11922
|
-
const {select: select} = editor.mergeConfig;
|
|
12017
|
+
const {select: select, selectKeep: selectKeep} = editor.mergeConfig;
|
|
11923
12018
|
if (select === "tap") this.checkAndSelect(e); else if (this.waitSelect) this.waitSelect();
|
|
11924
12019
|
if (this.needRemoveItem) {
|
|
11925
12020
|
editor.removeItem(this.needRemoveItem);
|
|
11926
12021
|
} else if (this.isMoveMode) {
|
|
11927
|
-
editor.target = null;
|
|
12022
|
+
if (!selectKeep) editor.target = null;
|
|
11928
12023
|
}
|
|
11929
12024
|
}
|
|
11930
12025
|
checkAndSelect(e) {
|
|
@@ -11939,7 +12034,7 @@ var LeaferUI = function(exports) {
|
|
|
11939
12034
|
editor.target = find;
|
|
11940
12035
|
}
|
|
11941
12036
|
} else if (this.allow(e.target)) {
|
|
11942
|
-
if (!this.isHoldMultipleSelectKey(e)) editor.target = null;
|
|
12037
|
+
if (!this.isHoldMultipleSelectKey(e) && !this.editor.mergedConfig.selectKeep) editor.target = null;
|
|
11943
12038
|
}
|
|
11944
12039
|
}
|
|
11945
12040
|
}
|
|
@@ -12054,91 +12149,95 @@ var LeaferUI = function(exports) {
|
|
|
12054
12149
|
const {toPoint: toPoint} = AroundHelper;
|
|
12055
12150
|
const {within: within$3, sign: sign$1} = MathHelper;
|
|
12056
12151
|
const EditDataHelper = {
|
|
12057
|
-
getScaleData(target, startBounds, direction,
|
|
12152
|
+
getScaleData(target, startBounds, direction, totalMoveOrScale, lockRatio, around, flipable, scaleMode) {
|
|
12058
12153
|
let align, origin = {}, scaleX = 1, scaleY = 1;
|
|
12059
12154
|
const {boxBounds: boxBounds, widthRange: widthRange, heightRange: heightRange, dragBounds: dragBounds, worldBoxBounds: worldBoxBounds} = target;
|
|
12060
12155
|
const {width: width, height: height} = startBounds;
|
|
12061
|
-
if (around) {
|
|
12062
|
-
totalMove.x *= 2;
|
|
12063
|
-
totalMove.y *= 2;
|
|
12064
|
-
}
|
|
12065
12156
|
const originChangedScaleX = target.scaleX / startBounds.scaleX;
|
|
12066
12157
|
const originChangedScaleY = target.scaleY / startBounds.scaleY;
|
|
12067
12158
|
const signX = sign$1(originChangedScaleX);
|
|
12068
12159
|
const signY = sign$1(originChangedScaleY);
|
|
12069
12160
|
const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
|
|
12070
12161
|
const changedScaleY = scaleMode ? originChangedScaleY : signY * boxBounds.height / height;
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12162
|
+
if (isNumber(totalMoveOrScale)) {
|
|
12163
|
+
scaleX = scaleY = Math.sqrt(totalMoveOrScale);
|
|
12164
|
+
} else {
|
|
12165
|
+
if (around) {
|
|
12166
|
+
totalMoveOrScale.x *= 2;
|
|
12167
|
+
totalMoveOrScale.y *= 2;
|
|
12168
|
+
}
|
|
12169
|
+
totalMoveOrScale.x *= scaleMode ? originChangedScaleX : signX;
|
|
12170
|
+
totalMoveOrScale.y *= scaleMode ? originChangedScaleY : signY;
|
|
12171
|
+
const topScale = (-totalMoveOrScale.y + height) / height;
|
|
12172
|
+
const rightScale = (totalMoveOrScale.x + width) / width;
|
|
12173
|
+
const bottomScale = (totalMoveOrScale.y + height) / height;
|
|
12174
|
+
const leftScale = (-totalMoveOrScale.x + width) / width;
|
|
12175
|
+
switch (direction) {
|
|
12176
|
+
case top$1:
|
|
12177
|
+
scaleY = topScale;
|
|
12178
|
+
align = "bottom";
|
|
12179
|
+
break;
|
|
12082
12180
|
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
12181
|
+
case right$2:
|
|
12182
|
+
scaleX = rightScale;
|
|
12183
|
+
align = "left";
|
|
12184
|
+
break;
|
|
12087
12185
|
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
|
|
12186
|
+
case bottom$1:
|
|
12187
|
+
scaleY = bottomScale;
|
|
12188
|
+
align = "top";
|
|
12189
|
+
break;
|
|
12092
12190
|
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
|
|
12096
|
-
|
|
12191
|
+
case left$2:
|
|
12192
|
+
scaleX = leftScale;
|
|
12193
|
+
align = "right";
|
|
12194
|
+
break;
|
|
12097
12195
|
|
|
12098
|
-
|
|
12099
|
-
|
|
12100
|
-
|
|
12101
|
-
|
|
12102
|
-
|
|
12196
|
+
case topLeft$1:
|
|
12197
|
+
scaleY = topScale;
|
|
12198
|
+
scaleX = leftScale;
|
|
12199
|
+
align = "bottom-right";
|
|
12200
|
+
break;
|
|
12103
12201
|
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12108
|
-
|
|
12202
|
+
case topRight$1:
|
|
12203
|
+
scaleY = topScale;
|
|
12204
|
+
scaleX = rightScale;
|
|
12205
|
+
align = "bottom-left";
|
|
12206
|
+
break;
|
|
12109
12207
|
|
|
12110
|
-
|
|
12111
|
-
|
|
12112
|
-
|
|
12113
|
-
|
|
12114
|
-
|
|
12208
|
+
case bottomRight:
|
|
12209
|
+
scaleY = bottomScale;
|
|
12210
|
+
scaleX = rightScale;
|
|
12211
|
+
align = "top-left";
|
|
12212
|
+
break;
|
|
12115
12213
|
|
|
12116
|
-
|
|
12117
|
-
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12214
|
+
case bottomLeft:
|
|
12215
|
+
scaleY = bottomScale;
|
|
12216
|
+
scaleX = leftScale;
|
|
12217
|
+
align = "top-right";
|
|
12218
|
+
}
|
|
12219
|
+
if (lockRatio) {
|
|
12220
|
+
if (lockRatio === "corner" && direction % 2) {
|
|
12221
|
+
lockRatio = false;
|
|
12222
|
+
} else {
|
|
12223
|
+
let scale;
|
|
12224
|
+
switch (direction) {
|
|
12225
|
+
case top$1:
|
|
12226
|
+
case bottom$1:
|
|
12227
|
+
scale = scaleY;
|
|
12228
|
+
break;
|
|
12131
12229
|
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12230
|
+
case left$2:
|
|
12231
|
+
case right$2:
|
|
12232
|
+
scale = scaleX;
|
|
12233
|
+
break;
|
|
12136
12234
|
|
|
12137
|
-
|
|
12138
|
-
|
|
12235
|
+
default:
|
|
12236
|
+
scale = Math.sqrt(Math.abs(scaleX * scaleY));
|
|
12237
|
+
}
|
|
12238
|
+
scaleX = scaleX < 0 ? -scale : scale;
|
|
12239
|
+
scaleY = scaleY < 0 ? -scale : scale;
|
|
12139
12240
|
}
|
|
12140
|
-
scaleX = scaleX < 0 ? -scale : scale;
|
|
12141
|
-
scaleY = scaleY < 0 ? -scale : scale;
|
|
12142
12241
|
}
|
|
12143
12242
|
}
|
|
12144
12243
|
const useScaleX = scaleX !== 1, useScaleY = scaleY !== 1;
|
|
@@ -12335,13 +12434,18 @@ var LeaferUI = function(exports) {
|
|
|
12335
12434
|
function updatePointCursor(editBox, e) {
|
|
12336
12435
|
const {enterPoint: point, dragging: dragging, skewing: skewing, resizing: resizing, flippedX: flippedX, flippedY: flippedY} = editBox;
|
|
12337
12436
|
if (!point || !editBox.editor.editing || !editBox.canUse) return;
|
|
12437
|
+
if (point.name === "rect") return updateMoveCursor(editBox);
|
|
12338
12438
|
if (point.name === "circle") return;
|
|
12339
|
-
|
|
12439
|
+
let {rotation: rotation} = editBox;
|
|
12440
|
+
const {pointType: pointType} = point, {moveCursor: moveCursor, resizeCursor: resizeCursor, rotateCursor: rotateCursor, skewCursor: skewCursor, moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = editBox.mergeConfig;
|
|
12441
|
+
if (pointType === "move") {
|
|
12442
|
+
point.cursor = moveCursor;
|
|
12443
|
+
if (!moveable) point.visible = false;
|
|
12444
|
+
return;
|
|
12445
|
+
} else if (pointType === "button") {
|
|
12340
12446
|
if (!point.cursor) point.cursor = "pointer";
|
|
12341
12447
|
return;
|
|
12342
12448
|
}
|
|
12343
|
-
let {rotation: rotation} = editBox;
|
|
12344
|
-
const {pointType: pointType} = point, {resizeCursor: resizeCursor, rotateCursor: rotateCursor, skewCursor: skewCursor, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = editBox.mergeConfig;
|
|
12345
12449
|
let showResize = pointType.includes("resize");
|
|
12346
12450
|
if (showResize && rotateable && (editBox.isHoldRotateKey(e) || !resizeable)) showResize = false;
|
|
12347
12451
|
const showSkew = skewable && !showResize && (point.name === "resize-line" || pointType === "skew");
|
|
@@ -12414,10 +12518,13 @@ var LeaferUI = function(exports) {
|
|
|
12414
12518
|
const {moveable: moveable, resizeable: resizeable, rotateable: rotateable} = this.mergeConfig;
|
|
12415
12519
|
return isString(moveable) || isString(resizeable) || isString(rotateable);
|
|
12416
12520
|
}
|
|
12521
|
+
get canDragLimitAnimate() {
|
|
12522
|
+
return this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds;
|
|
12523
|
+
}
|
|
12417
12524
|
constructor(editor) {
|
|
12418
12525
|
super();
|
|
12419
12526
|
this.view = new exports.Group;
|
|
12420
|
-
this.rect = new
|
|
12527
|
+
this.rect = new EditPoint({
|
|
12421
12528
|
name: "rect",
|
|
12422
12529
|
hitFill: "all",
|
|
12423
12530
|
hitStroke: "none",
|
|
@@ -12479,12 +12586,13 @@ var LeaferUI = function(exports) {
|
|
|
12479
12586
|
this.listenPointEvents(resizePoint, "resize", i);
|
|
12480
12587
|
}
|
|
12481
12588
|
this.listenPointEvents(circle, "rotate", 2);
|
|
12589
|
+
this.listenPointEvents(rect, "move", 8);
|
|
12482
12590
|
view.addMany(...rotatePoints, rect, circle, buttons, ...resizeLines, ...resizePoints);
|
|
12483
12591
|
this.add(view);
|
|
12484
12592
|
}
|
|
12485
12593
|
load() {
|
|
12486
|
-
const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints} = this;
|
|
12487
|
-
const {stroke: stroke, strokeWidth: strokeWidth} = mergeConfig;
|
|
12594
|
+
const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints, resizeLines: resizeLines} = this;
|
|
12595
|
+
const {stroke: stroke, strokeWidth: strokeWidth, resizeLine: resizeLine} = mergeConfig;
|
|
12488
12596
|
const pointsStyle = this.getPointsStyle();
|
|
12489
12597
|
const middlePointsStyle = this.getMiddlePointsStyle();
|
|
12490
12598
|
this.visible = !target.locked;
|
|
@@ -12493,6 +12601,10 @@ var LeaferUI = function(exports) {
|
|
|
12493
12601
|
resizeP = resizePoints[i];
|
|
12494
12602
|
resizeP.set(this.getPointStyle(i % 2 ? middlePointsStyle[(i - 1) / 2 % middlePointsStyle.length] : pointsStyle[i / 2 % pointsStyle.length]));
|
|
12495
12603
|
resizeP.rotation = (i - (i % 2 ? 1 : 0)) / 2 * 90;
|
|
12604
|
+
if (i % 2) resizeLines[(i - 1) / 2].set(Object.assign({
|
|
12605
|
+
pointType: "resize",
|
|
12606
|
+
rotation: (i - 1) / 2 * 90
|
|
12607
|
+
}, resizeLine || {}));
|
|
12496
12608
|
}
|
|
12497
12609
|
circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
|
|
12498
12610
|
rect.set(Object.assign({
|
|
@@ -12537,10 +12649,12 @@ var LeaferUI = function(exports) {
|
|
|
12537
12649
|
if (this.app) this.rect.syncEventer = this.app.interaction.bottomList = null;
|
|
12538
12650
|
}
|
|
12539
12651
|
updateBounds(bounds) {
|
|
12540
|
-
const {
|
|
12541
|
-
const {
|
|
12542
|
-
const {middlePoint: middlePoint, resizeable: resizeable, rotateable: rotateable, hideOnSmall: hideOnSmall, editBox: editBox, mask: mask, spread: spread, hideRotatePoints: hideRotatePoints, hideResizeLines: hideResizeLines} = mergeConfig;
|
|
12652
|
+
const {editor: editor, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, buttons: buttons, resizePoints: resizePoints, rotatePoints: rotatePoints, resizeLines: resizeLines} = this;
|
|
12653
|
+
const {editMask: editMask} = editor;
|
|
12654
|
+
const {middlePoint: middlePoint, resizeable: resizeable, rotateable: rotateable, hideOnSmall: hideOnSmall, editBox: editBox, mask: mask, dimOthers: dimOthers, bright: bright, spread: spread, hideRotatePoints: hideRotatePoints, hideResizeLines: hideResizeLines} = mergeConfig;
|
|
12543
12655
|
editMask.visible = mask ? true : 0;
|
|
12656
|
+
editor.setDimOthers(dimOthers);
|
|
12657
|
+
editor.setBright(!!dimOthers || bright);
|
|
12544
12658
|
if (spread) BoundsHelper.spread(bounds, spread);
|
|
12545
12659
|
if (this.view.worldOpacity) {
|
|
12546
12660
|
const {width: width, height: height} = bounds;
|
|
@@ -12561,10 +12675,10 @@ var LeaferUI = function(exports) {
|
|
|
12561
12675
|
resizeL.visible = resizeP.visible && !hideResizeLines;
|
|
12562
12676
|
resizeP.visible = rotateP.visible = showPoints && !!middlePoint;
|
|
12563
12677
|
if ((i + 1) / 2 % 2) {
|
|
12564
|
-
resizeL.width = width;
|
|
12678
|
+
resizeL.width = width + resizeL.height;
|
|
12565
12679
|
if (hideOnSmall && resizeP.width * 2 > width) resizeP.visible = false;
|
|
12566
12680
|
} else {
|
|
12567
|
-
resizeL.
|
|
12681
|
+
resizeL.width = height + resizeL.height;
|
|
12568
12682
|
if (hideOnSmall && resizeP.width * 2 > height) resizeP.visible = false;
|
|
12569
12683
|
}
|
|
12570
12684
|
}
|
|
@@ -12640,10 +12754,9 @@ var LeaferUI = function(exports) {
|
|
|
12640
12754
|
onDragStart(e) {
|
|
12641
12755
|
this.dragging = true;
|
|
12642
12756
|
const point = this.dragPoint = e.current, {pointType: pointType} = point;
|
|
12643
|
-
const {
|
|
12644
|
-
if (
|
|
12757
|
+
const {moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = this.mergeConfig;
|
|
12758
|
+
if (pointType === "move") {
|
|
12645
12759
|
moveable && (this.moving = true);
|
|
12646
|
-
editor.opacity = hideOnMove ? 0 : 1;
|
|
12647
12760
|
} else {
|
|
12648
12761
|
if (pointType.includes("rotate") || this.isHoldRotateKey(e) || !resizeable) {
|
|
12649
12762
|
rotateable && (this.rotating = true);
|
|
@@ -12652,69 +12765,74 @@ var LeaferUI = function(exports) {
|
|
|
12652
12765
|
} else if (pointType === "resize") resizeable && (this.resizing = true);
|
|
12653
12766
|
if (pointType === "skew") skewable && (this.skewing = true);
|
|
12654
12767
|
}
|
|
12655
|
-
|
|
12656
|
-
dragStartData.y = e.y;
|
|
12657
|
-
dragStartData.point = {
|
|
12658
|
-
x: target.x,
|
|
12659
|
-
y: target.y
|
|
12660
|
-
};
|
|
12661
|
-
dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
|
|
12662
|
-
dragStartData.rotation = target.rotation;
|
|
12663
|
-
if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = editor.leafList.keys;
|
|
12664
|
-
}
|
|
12665
|
-
onDragEnd(e) {
|
|
12666
|
-
if (this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds) this.transformTool.onMove(e);
|
|
12667
|
-
this.dragPoint = null;
|
|
12668
|
-
this.resetDoing();
|
|
12669
|
-
const {name: name, pointType: pointType} = e.current;
|
|
12670
|
-
if (name === "rect") this.editor.opacity = 1;
|
|
12671
|
-
if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = null;
|
|
12768
|
+
this.onTransformStart(e);
|
|
12672
12769
|
}
|
|
12673
12770
|
onDrag(e) {
|
|
12674
12771
|
const {transformTool: transformTool, moving: moving, resizing: resizing, rotating: rotating, skewing: skewing} = this;
|
|
12675
12772
|
if (moving) {
|
|
12676
12773
|
transformTool.onMove(e);
|
|
12677
|
-
updateMoveCursor(this);
|
|
12678
12774
|
} else if (resizing || rotating || skewing) {
|
|
12679
12775
|
const point = e.current;
|
|
12680
12776
|
if (point.pointType) this.enterPoint = point;
|
|
12681
12777
|
if (rotating) transformTool.onRotate(e);
|
|
12682
12778
|
if (resizing) transformTool.onScale(e);
|
|
12683
12779
|
if (skewing) transformTool.onSkew(e);
|
|
12684
|
-
updatePointCursor(this, e);
|
|
12685
12780
|
}
|
|
12781
|
+
updatePointCursor(this, e);
|
|
12686
12782
|
}
|
|
12687
|
-
|
|
12688
|
-
|
|
12783
|
+
onDragEnd(e) {
|
|
12784
|
+
this.onTransformEnd(e);
|
|
12785
|
+
this.dragPoint = null;
|
|
12786
|
+
}
|
|
12787
|
+
onTransformStart(e) {
|
|
12788
|
+
if (this.canUse) {
|
|
12789
|
+
if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
|
|
12790
|
+
if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
|
|
12791
|
+
const {dragStartData: dragStartData, target: target} = this;
|
|
12792
|
+
dragStartData.x = e.x;
|
|
12793
|
+
dragStartData.y = e.y;
|
|
12794
|
+
dragStartData.totalOffset = getPointData();
|
|
12795
|
+
dragStartData.point = {
|
|
12796
|
+
x: target.x,
|
|
12797
|
+
y: target.y
|
|
12798
|
+
};
|
|
12799
|
+
dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
|
|
12800
|
+
dragStartData.rotation = target.rotation;
|
|
12801
|
+
}
|
|
12802
|
+
}
|
|
12803
|
+
onTransformEnd(e) {
|
|
12804
|
+
if (this.canUse) {
|
|
12805
|
+
if (this.canDragLimitAnimate && (e instanceof exports.DragEvent || e instanceof exports.MoveEvent)) this.transformTool.onMove(e);
|
|
12806
|
+
if (this.resizing) ResizeEvent.resizingKeys = null;
|
|
12807
|
+
this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
|
|
12808
|
+
this.editor.opacity = 1;
|
|
12809
|
+
this.update();
|
|
12810
|
+
}
|
|
12689
12811
|
}
|
|
12690
12812
|
onMove(e) {
|
|
12691
12813
|
if (this.canGesture && e.moveType !== "drag") {
|
|
12692
12814
|
e.stop();
|
|
12693
|
-
if (isString(this.
|
|
12815
|
+
if (isString(this.mergedConfig.moveable)) {
|
|
12694
12816
|
this.gesturing = this.moving = true;
|
|
12695
|
-
this.transformTool.onMove(e);
|
|
12817
|
+
e.type === exports.MoveEvent.START ? this.onTransformStart(e) : this.transformTool.onMove(e);
|
|
12696
12818
|
}
|
|
12697
12819
|
}
|
|
12698
12820
|
}
|
|
12699
|
-
onMoveEnd(e) {
|
|
12700
|
-
if (this.moving) this.transformTool.onMove(e);
|
|
12701
|
-
this.resetDoing();
|
|
12702
|
-
}
|
|
12703
12821
|
onScale(e) {
|
|
12704
12822
|
if (this.canGesture) {
|
|
12705
12823
|
e.stop();
|
|
12706
|
-
if (isString(this.
|
|
12824
|
+
if (isString(this.mergedConfig.resizeable)) {
|
|
12707
12825
|
this.gesturing = this.resizing = true;
|
|
12708
|
-
this.transformTool.onScale(e);
|
|
12826
|
+
e.type === exports.ZoomEvent.START ? this.onTransformStart(e) : this.transformTool.onScale(e);
|
|
12709
12827
|
}
|
|
12710
12828
|
}
|
|
12711
12829
|
}
|
|
12712
12830
|
onRotate(e) {
|
|
12713
12831
|
if (this.canGesture) {
|
|
12714
12832
|
e.stop();
|
|
12715
|
-
if (isString(this.
|
|
12833
|
+
if (isString(this.mergedConfig.rotateable)) {
|
|
12716
12834
|
this.gesturing = this.rotating = true;
|
|
12717
|
-
this.transformTool.onRotate(e);
|
|
12835
|
+
e.type === exports.RotateEvent.START ? this.onTransformStart(e) : this.transformTool.onRotate(e);
|
|
12718
12836
|
}
|
|
12719
12837
|
}
|
|
12720
12838
|
}
|
|
@@ -12727,8 +12845,7 @@ var LeaferUI = function(exports) {
|
|
|
12727
12845
|
updatePointCursor(this, e);
|
|
12728
12846
|
}
|
|
12729
12847
|
onArrow(e) {
|
|
12730
|
-
|
|
12731
|
-
if (this.canUse && editor.editing && this.mergeConfig.keyEvent) {
|
|
12848
|
+
if (this.canUse && this.mergeConfig.keyEvent) {
|
|
12732
12849
|
let x = 0, y = 0;
|
|
12733
12850
|
const distance = e.shiftKey ? 10 : 1;
|
|
12734
12851
|
switch (e.code) {
|
|
@@ -12747,7 +12864,7 @@ var LeaferUI = function(exports) {
|
|
|
12747
12864
|
case "ArrowRight":
|
|
12748
12865
|
x = distance;
|
|
12749
12866
|
}
|
|
12750
|
-
if (x || y) transformTool.move(x, y);
|
|
12867
|
+
if (x || y) this.transformTool.move(x, y);
|
|
12751
12868
|
}
|
|
12752
12869
|
}
|
|
12753
12870
|
onDoubleTap(e) {
|
|
@@ -12778,19 +12895,17 @@ var LeaferUI = function(exports) {
|
|
|
12778
12895
|
listenPointEvents(point, type, direction) {
|
|
12779
12896
|
point.direction = direction;
|
|
12780
12897
|
point.pointType = type;
|
|
12781
|
-
|
|
12782
|
-
this.enterPoint = null;
|
|
12783
|
-
} ] ];
|
|
12784
|
-
if (point.name !== "circle") events.push([ exports.PointerEvent.ENTER, e => {
|
|
12898
|
+
this.__eventIds.push(point.on_([ [ exports.DragEvent.START, this.onDragStart, this ], [ exports.DragEvent.DRAG, this.onDrag, this ], [ exports.DragEvent.END, this.onDragEnd, this ], [ exports.PointerEvent.ENTER, e => {
|
|
12785
12899
|
this.enterPoint = point, updatePointCursor(this, e);
|
|
12786
|
-
} ])
|
|
12787
|
-
|
|
12900
|
+
} ], [ exports.PointerEvent.LEAVE, () => {
|
|
12901
|
+
this.enterPoint = null;
|
|
12902
|
+
} ] ]));
|
|
12788
12903
|
}
|
|
12789
12904
|
__listenEvents() {
|
|
12790
12905
|
const {rect: rect, editor: editor, __eventIds: events} = this;
|
|
12791
|
-
events.push(rect.on_([ [ exports.
|
|
12906
|
+
events.push(rect.on_([ [ exports.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ exports.PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
|
|
12792
12907
|
this.waitLeafer(() => {
|
|
12793
|
-
events.push(editor.app.on_([ [ [ exports.KeyEvent.HOLD, exports.KeyEvent.UP ], this.onKey, this ], [ exports.KeyEvent.DOWN, this.onArrow, this ], [ exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true ], [ exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true ], [ exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true ], [ exports.MoveEvent.END,
|
|
12908
|
+
events.push(editor.app.on_([ [ [ exports.KeyEvent.HOLD, exports.KeyEvent.UP ], this.onKey, this ], [ exports.KeyEvent.DOWN, this.onArrow, this ], [ [ exports.MoveEvent.START, exports.MoveEvent.BEFORE_MOVE ], this.onMove, this, true ], [ [ exports.ZoomEvent.START, exports.ZoomEvent.BEFORE_ZOOM ], this.onScale, this, true ], [ [ exports.RotateEvent.START, exports.RotateEvent.BEFORE_ROTATE ], this.onRotate, this, true ], [ [ exports.MoveEvent.END, exports.ZoomEvent.END, exports.RotateEvent.END ], this.onTransformEnd, this ] ]));
|
|
12794
12909
|
});
|
|
12795
12910
|
}
|
|
12796
12911
|
__removeListenEvents() {
|
|
@@ -13139,56 +13254,61 @@ var LeaferUI = function(exports) {
|
|
|
13139
13254
|
const isMoveEnd = e.type === exports.MoveEvent.END || e.type === exports.DragEvent.END;
|
|
13140
13255
|
const axisDrag = isString(target.draggable);
|
|
13141
13256
|
const checkLimitMove = !dragLimitAnimate || isMoveEnd || axisDrag;
|
|
13257
|
+
const total = {
|
|
13258
|
+
x: e.totalX,
|
|
13259
|
+
y: e.totalY
|
|
13260
|
+
};
|
|
13142
13261
|
if (e instanceof exports.MoveEvent) {
|
|
13143
|
-
move
|
|
13144
|
-
|
|
13145
|
-
|
|
13146
|
-
|
|
13147
|
-
x: e.totalX,
|
|
13148
|
-
y: e.totalY
|
|
13149
|
-
};
|
|
13150
|
-
if (e.shiftKey) {
|
|
13151
|
-
if (Math.abs(total.x) > Math.abs(total.y)) total.y = 0; else total.x = 0;
|
|
13152
|
-
}
|
|
13153
|
-
move = exports.DragEvent.getValidMove(target, dragStartData.point, total, checkLimitMove);
|
|
13262
|
+
PointHelper.move(total, target.getWorldPointByLocal(dragStartData.totalOffset, null, true));
|
|
13263
|
+
}
|
|
13264
|
+
if (e.shiftKey) {
|
|
13265
|
+
if (Math.abs(total.x) > Math.abs(total.y)) total.y = 0; else total.x = 0;
|
|
13154
13266
|
}
|
|
13267
|
+
move = exports.DragEvent.getValidMove(target, dragStartData.point, total, checkLimitMove);
|
|
13155
13268
|
if (move.x || move.y) {
|
|
13156
13269
|
if (dragLimitAnimate && !axisDrag && isMoveEnd) LeafHelper.animateMove(this, move, isNumber(dragLimitAnimate) ? dragLimitAnimate : .3); else this.move(move);
|
|
13157
13270
|
}
|
|
13158
13271
|
}
|
|
13159
13272
|
onScale(e) {
|
|
13160
13273
|
const {target: target, mergeConfig: mergeConfig, single: single, dragStartData: dragStartData} = this.editBox;
|
|
13161
|
-
let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig;
|
|
13274
|
+
let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig, totalMove;
|
|
13162
13275
|
if (e instanceof exports.ZoomEvent) {
|
|
13163
|
-
|
|
13276
|
+
around = target.getBoxPoint(e);
|
|
13277
|
+
totalMove = e.totalScale;
|
|
13164
13278
|
} else {
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
|
|
13172
|
-
|
|
13173
|
-
|
|
13279
|
+
totalMove = e.getInnerTotal(target);
|
|
13280
|
+
}
|
|
13281
|
+
const {direction: direction} = e.current;
|
|
13282
|
+
if (e.shiftKey || target.lockRatio) lockRatio = true;
|
|
13283
|
+
const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, totalMove, lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === "scale");
|
|
13284
|
+
const targetX = target.x, targetY = target.y;
|
|
13285
|
+
if (e instanceof exports.DragEvent && this.editTool && this.editTool.onScaleWithDrag) {
|
|
13286
|
+
data.drag = e;
|
|
13287
|
+
this.scaleWithDrag(data);
|
|
13288
|
+
} else {
|
|
13289
|
+
this.scaleOf(data.origin, data.scaleX, data.scaleY);
|
|
13174
13290
|
}
|
|
13291
|
+
PointHelper.move(dragStartData.totalOffset, target.x - targetX, target.y - targetY);
|
|
13175
13292
|
}
|
|
13176
13293
|
onRotate(e) {
|
|
13177
13294
|
const {target: target, mergeConfig: mergeConfig, dragStartData: dragStartData} = this.editBox;
|
|
13178
|
-
const {around: around, rotateAround: rotateAround, rotateGap: rotateGap} = mergeConfig;
|
|
13295
|
+
const {around: around, rotateAround: rotateAround, rotateGap: rotateGap, diagonalRotateKey: diagonalRotateKey} = mergeConfig;
|
|
13179
13296
|
const {direction: direction} = e.current;
|
|
13180
13297
|
let origin, rotation;
|
|
13181
13298
|
if (e instanceof exports.RotateEvent) {
|
|
13182
13299
|
rotation = e.rotation;
|
|
13183
13300
|
origin = rotateAround ? AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
|
|
13184
13301
|
} else {
|
|
13185
|
-
const
|
|
13302
|
+
const isDiagonalRotate = diagonalRotateKey ? e.isHoldKeys(diagonalRotateKey) : e.shiftKey;
|
|
13303
|
+
const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, isDiagonalRotate ? null : rotateAround || target.around || target.origin || around || "center");
|
|
13186
13304
|
rotation = dragStartData.rotation + data.rotation - target.rotation;
|
|
13187
13305
|
origin = data.origin;
|
|
13188
13306
|
}
|
|
13189
13307
|
rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
|
|
13190
13308
|
if (!rotation) return;
|
|
13309
|
+
const targetX = target.x, targetY = target.y;
|
|
13191
13310
|
this.rotateOf(origin, rotation);
|
|
13311
|
+
PointHelper.move(dragStartData.totalOffset, target.x - targetX, target.y - targetY);
|
|
13192
13312
|
}
|
|
13193
13313
|
onSkew(e) {
|
|
13194
13314
|
const {target: target, mergeConfig: mergeConfig} = this.editBox;
|
|
@@ -13466,6 +13586,16 @@ var LeaferUI = function(exports) {
|
|
|
13466
13586
|
shiftItem(item) {
|
|
13467
13587
|
this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
|
|
13468
13588
|
}
|
|
13589
|
+
setDimOthers(value, attrName = "dim", list) {
|
|
13590
|
+
if (!list) {
|
|
13591
|
+
const {dimTarget: dimTarget, targetLeafer: targetLeafer} = this;
|
|
13592
|
+
list = dimTarget ? isArray(dimTarget) ? dimTarget : [ dimTarget ] : [ targetLeafer ];
|
|
13593
|
+
}
|
|
13594
|
+
if (list[0] && list[0][attrName] !== (value || false)) list.forEach(item => DataHelper.stintSet(item, attrName, value));
|
|
13595
|
+
}
|
|
13596
|
+
setBright(value) {
|
|
13597
|
+
this.setDimOthers(value, "bright", this.list);
|
|
13598
|
+
}
|
|
13469
13599
|
update() {
|
|
13470
13600
|
if (this.editing) {
|
|
13471
13601
|
if (!this.element.parent) return this.cancel();
|
|
@@ -13686,8 +13816,8 @@ var LeaferUI = function(exports) {
|
|
|
13686
13816
|
}
|
|
13687
13817
|
};
|
|
13688
13818
|
__decorate([ mergeConfigAttr() ], exports.Editor.prototype, "mergeConfig", void 0);
|
|
13689
|
-
__decorate([ targetAttr(onHover) ], exports.Editor.prototype, "hoverTarget", void 0);
|
|
13690
13819
|
__decorate([ targetAttr(onTarget) ], exports.Editor.prototype, "target", void 0);
|
|
13820
|
+
__decorate([ targetAttr(onHover) ], exports.Editor.prototype, "hoverTarget", void 0);
|
|
13691
13821
|
exports.Editor = __decorate([ useModule(TransformTool, [ "editBox", "editTool", "emitEvent" ]) ], exports.Editor);
|
|
13692
13822
|
class InnerEditor {
|
|
13693
13823
|
static registerInnerEditor() {
|
|
@@ -13908,7 +14038,7 @@ var LeaferUI = function(exports) {
|
|
|
13908
14038
|
}
|
|
13909
14039
|
};
|
|
13910
14040
|
exports.LineEditTool = __decorate([ registerEditTool() ], exports.LineEditTool);
|
|
13911
|
-
const {M: M$
|
|
14041
|
+
const {M: M$4, L: L$3, C: C$3, Q: Q$2, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$2, P: P$1, U: U$1} = PathCommandMap;
|
|
13912
14042
|
const PathScaler = {
|
|
13913
14043
|
scale(data, scaleX, scaleY) {
|
|
13914
14044
|
if (!data) return;
|
|
@@ -13917,7 +14047,7 @@ var LeaferUI = function(exports) {
|
|
|
13917
14047
|
while (i < len) {
|
|
13918
14048
|
command = data[i];
|
|
13919
14049
|
switch (command) {
|
|
13920
|
-
case M$
|
|
14050
|
+
case M$4:
|
|
13921
14051
|
case L$3:
|
|
13922
14052
|
scalePoints(data, scaleX, scaleY, i, 1);
|
|
13923
14053
|
i += 3;
|
|
@@ -14334,28 +14464,24 @@ var LeaferUI = function(exports) {
|
|
|
14334
14464
|
const data = text.__;
|
|
14335
14465
|
if (data.__autoWidth) {
|
|
14336
14466
|
width += 20;
|
|
14337
|
-
|
|
14338
|
-
|
|
14339
|
-
|
|
14340
|
-
|
|
14341
|
-
break;
|
|
14467
|
+
switch (data.textAlign) {
|
|
14468
|
+
case "center":
|
|
14469
|
+
offsetX = data.autoSizeAlign ? -width / 2 : -10;
|
|
14470
|
+
break;
|
|
14342
14471
|
|
|
14343
|
-
|
|
14344
|
-
|
|
14345
|
-
}
|
|
14472
|
+
case "right":
|
|
14473
|
+
offsetX = data.autoSizeAlign ? -width : -20;
|
|
14346
14474
|
}
|
|
14347
14475
|
}
|
|
14348
14476
|
if (data.__autoHeight) {
|
|
14349
14477
|
height += 20;
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
break;
|
|
14478
|
+
switch (data.verticalAlign) {
|
|
14479
|
+
case "middle":
|
|
14480
|
+
offsetY = data.autoSizeAlign ? -height / 2 : -10;
|
|
14481
|
+
break;
|
|
14355
14482
|
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
}
|
|
14483
|
+
case "bottom":
|
|
14484
|
+
offsetY = data.autoSizeAlign ? -height : -20;
|
|
14359
14485
|
}
|
|
14360
14486
|
}
|
|
14361
14487
|
const {x: x, y: y} = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
|
|
@@ -14459,6 +14585,13 @@ var LeaferUI = function(exports) {
|
|
|
14459
14585
|
register("design", design);
|
|
14460
14586
|
register("document", document$1);
|
|
14461
14587
|
const MultiTouchHelper = {
|
|
14588
|
+
state: {
|
|
14589
|
+
type: "none",
|
|
14590
|
+
typeCount: 0,
|
|
14591
|
+
startTime: 0,
|
|
14592
|
+
totalData: null,
|
|
14593
|
+
center: {}
|
|
14594
|
+
},
|
|
14462
14595
|
getData(list) {
|
|
14463
14596
|
const a = list[0], b = list[1];
|
|
14464
14597
|
const lastCenter = PointHelper.getCenter(a.from, b.from);
|
|
@@ -14477,8 +14610,51 @@ var LeaferUI = function(exports) {
|
|
|
14477
14610
|
rotation: rotation,
|
|
14478
14611
|
center: center
|
|
14479
14612
|
};
|
|
14613
|
+
},
|
|
14614
|
+
getType(data, config) {
|
|
14615
|
+
const moveScore = Math.hypot(data.move.x, data.move.y) / (config.move || 5);
|
|
14616
|
+
const scaleScore = Math.abs(data.scale - 1) / (config.scale || .03);
|
|
14617
|
+
const rotateScore = Math.abs(data.rotation) / (config.rotation || 2);
|
|
14618
|
+
if (moveScore < 1 && scaleScore < 1 && rotateScore < 1) return "none";
|
|
14619
|
+
if (moveScore >= scaleScore && moveScore >= rotateScore) return "move";
|
|
14620
|
+
if (scaleScore >= rotateScore) return "zoom";
|
|
14621
|
+
return "rotate";
|
|
14622
|
+
},
|
|
14623
|
+
detect(data, config) {
|
|
14624
|
+
const {state: state} = M$3;
|
|
14625
|
+
const type = M$3.getType(data, config);
|
|
14626
|
+
if (!state.totalData) {
|
|
14627
|
+
state.startTime = Date.now();
|
|
14628
|
+
state.center = data.center;
|
|
14629
|
+
}
|
|
14630
|
+
M$3.add(data, state.totalData);
|
|
14631
|
+
state.totalData = data;
|
|
14632
|
+
if (type === state.type) {
|
|
14633
|
+
state.typeCount++;
|
|
14634
|
+
if (state.typeCount >= (config.count || 3) && type !== "none") return type;
|
|
14635
|
+
} else {
|
|
14636
|
+
state.type = type;
|
|
14637
|
+
state.typeCount = 1;
|
|
14638
|
+
}
|
|
14639
|
+
if (Date.now() - state.startTime >= (config.time || 160)) return M$3.getType(state.totalData, config);
|
|
14640
|
+
return "none";
|
|
14641
|
+
},
|
|
14642
|
+
add(data, add) {
|
|
14643
|
+
if (!add) return;
|
|
14644
|
+
PointHelper.move(data.move, add.move);
|
|
14645
|
+
data.scale *= add.scale;
|
|
14646
|
+
data.rotation += add.rotation;
|
|
14647
|
+
data.center = add.center;
|
|
14648
|
+
},
|
|
14649
|
+
reset() {
|
|
14650
|
+
const {state: state} = M$3;
|
|
14651
|
+
state.type = "none";
|
|
14652
|
+
state.typeCount = 0;
|
|
14653
|
+
state.startTime = 0;
|
|
14654
|
+
state.totalData = null;
|
|
14480
14655
|
}
|
|
14481
14656
|
};
|
|
14657
|
+
const M$3 = MultiTouchHelper;
|
|
14482
14658
|
const {abs: abs$2, max: max} = Math, {sign: sign, within: within$2} = MathHelper;
|
|
14483
14659
|
const WheelEventHelper = {
|
|
14484
14660
|
getMove(event, config) {
|
|
@@ -14516,9 +14692,19 @@ var LeaferUI = function(exports) {
|
|
|
14516
14692
|
return scale;
|
|
14517
14693
|
}
|
|
14518
14694
|
};
|
|
14695
|
+
let totalX, totalY, totalScale, totalRotation;
|
|
14519
14696
|
class Transformer {
|
|
14520
14697
|
get transforming() {
|
|
14521
|
-
return
|
|
14698
|
+
return this.moving || this.zooming || this.rotating;
|
|
14699
|
+
}
|
|
14700
|
+
get moving() {
|
|
14701
|
+
return !!this.moveData;
|
|
14702
|
+
}
|
|
14703
|
+
get zooming() {
|
|
14704
|
+
return !!this.zoomData;
|
|
14705
|
+
}
|
|
14706
|
+
get rotating() {
|
|
14707
|
+
return !!this.rotateData;
|
|
14522
14708
|
}
|
|
14523
14709
|
constructor(interaction) {
|
|
14524
14710
|
this.interaction = interaction;
|
|
@@ -14528,13 +14714,18 @@ var LeaferUI = function(exports) {
|
|
|
14528
14714
|
if (!data.moveType) data.moveType = "move";
|
|
14529
14715
|
if (!this.moveData) {
|
|
14530
14716
|
this.setPath(data);
|
|
14717
|
+
totalX = 0, totalY = 0;
|
|
14531
14718
|
this.moveData = Object.assign(Object.assign({}, data), {
|
|
14532
14719
|
moveX: 0,
|
|
14533
|
-
moveY: 0
|
|
14720
|
+
moveY: 0,
|
|
14721
|
+
totalX: totalX,
|
|
14722
|
+
totalY: totalY
|
|
14534
14723
|
});
|
|
14535
14724
|
interaction.emit(exports.MoveEvent.START, this.moveData);
|
|
14536
14725
|
}
|
|
14537
14726
|
data.path = this.moveData.path;
|
|
14727
|
+
data.totalX = totalX = totalX + data.moveX;
|
|
14728
|
+
data.totalY = totalY = totalY + data.moveY;
|
|
14538
14729
|
interaction.emit(exports.MoveEvent.BEFORE_MOVE, data);
|
|
14539
14730
|
interaction.emit(exports.MoveEvent.MOVE, data);
|
|
14540
14731
|
this.transformEndWait();
|
|
@@ -14543,12 +14734,15 @@ var LeaferUI = function(exports) {
|
|
|
14543
14734
|
const {interaction: interaction} = this;
|
|
14544
14735
|
if (!this.zoomData) {
|
|
14545
14736
|
this.setPath(data);
|
|
14737
|
+
totalScale = 1;
|
|
14546
14738
|
this.zoomData = Object.assign(Object.assign({}, data), {
|
|
14547
|
-
scale: 1
|
|
14739
|
+
scale: 1,
|
|
14740
|
+
totalScale: totalScale
|
|
14548
14741
|
});
|
|
14549
14742
|
interaction.emit(exports.ZoomEvent.START, this.zoomData);
|
|
14550
14743
|
}
|
|
14551
14744
|
data.path = this.zoomData.path;
|
|
14745
|
+
data.totalScale = totalScale = totalScale * data.scale;
|
|
14552
14746
|
interaction.emit(exports.ZoomEvent.BEFORE_ZOOM, data);
|
|
14553
14747
|
interaction.emit(exports.ZoomEvent.ZOOM, data);
|
|
14554
14748
|
this.transformEndWait();
|
|
@@ -14557,12 +14751,15 @@ var LeaferUI = function(exports) {
|
|
|
14557
14751
|
const {interaction: interaction} = this;
|
|
14558
14752
|
if (!this.rotateData) {
|
|
14559
14753
|
this.setPath(data);
|
|
14754
|
+
totalRotation = 0;
|
|
14560
14755
|
this.rotateData = Object.assign(Object.assign({}, data), {
|
|
14561
|
-
rotation: 0
|
|
14756
|
+
rotation: 0,
|
|
14757
|
+
totalRotation: totalRotation
|
|
14562
14758
|
});
|
|
14563
14759
|
interaction.emit(exports.RotateEvent.START, this.rotateData);
|
|
14564
14760
|
}
|
|
14565
14761
|
data.path = this.rotateData.path;
|
|
14762
|
+
data.totalRotation = totalRotation = totalRotation + data.rotation;
|
|
14566
14763
|
interaction.emit(exports.RotateEvent.BEFORE_ROTATE, data);
|
|
14567
14764
|
interaction.emit(exports.RotateEvent.ROTATE, data);
|
|
14568
14765
|
this.transformEndWait();
|
|
@@ -14581,9 +14778,16 @@ var LeaferUI = function(exports) {
|
|
|
14581
14778
|
}
|
|
14582
14779
|
transformEnd() {
|
|
14583
14780
|
const {interaction: interaction, moveData: moveData, zoomData: zoomData, rotateData: rotateData} = this;
|
|
14584
|
-
if (moveData) interaction.emit(exports.MoveEvent.END, moveData)
|
|
14585
|
-
|
|
14586
|
-
|
|
14781
|
+
if (moveData) interaction.emit(exports.MoveEvent.END, Object.assign(Object.assign({}, moveData), {
|
|
14782
|
+
totalX: totalX,
|
|
14783
|
+
totalY: totalY
|
|
14784
|
+
}));
|
|
14785
|
+
if (zoomData) interaction.emit(exports.ZoomEvent.END, Object.assign(Object.assign({}, zoomData), {
|
|
14786
|
+
totalScale: totalScale
|
|
14787
|
+
}));
|
|
14788
|
+
if (rotateData) interaction.emit(exports.RotateEvent.END, Object.assign(Object.assign({}, rotateData), {
|
|
14789
|
+
totalRotation: totalRotation
|
|
14790
|
+
}));
|
|
14587
14791
|
this.reset();
|
|
14588
14792
|
}
|
|
14589
14793
|
reset() {
|
|
@@ -14665,14 +14869,39 @@ var LeaferUI = function(exports) {
|
|
|
14665
14869
|
}
|
|
14666
14870
|
};
|
|
14667
14871
|
interaction.multiTouch = function(data, list) {
|
|
14668
|
-
|
|
14669
|
-
|
|
14670
|
-
Object.assign(data, center);
|
|
14671
|
-
data.multiTouch = true;
|
|
14872
|
+
const {disabled: disabled, singleGesture: singleGesture} = this.config.multiTouch;
|
|
14873
|
+
if (disabled) return;
|
|
14672
14874
|
this.pointerWaitCancel();
|
|
14673
|
-
|
|
14674
|
-
this.
|
|
14675
|
-
|
|
14875
|
+
let gestureData = MultiTouchHelper.getData(list);
|
|
14876
|
+
let {moving: moving, zooming: zooming, rotating: rotating} = this.transformer;
|
|
14877
|
+
if (singleGesture) {
|
|
14878
|
+
if (!this.transformer.transforming) {
|
|
14879
|
+
const type = MultiTouchHelper.detect(gestureData, isObject(singleGesture) ? singleGesture : {});
|
|
14880
|
+
switch (type) {
|
|
14881
|
+
case "move":
|
|
14882
|
+
moving = true;
|
|
14883
|
+
break;
|
|
14884
|
+
|
|
14885
|
+
case "zoom":
|
|
14886
|
+
zooming = true;
|
|
14887
|
+
break;
|
|
14888
|
+
|
|
14889
|
+
case "rotate":
|
|
14890
|
+
rotating = true;
|
|
14891
|
+
break;
|
|
14892
|
+
|
|
14893
|
+
default:
|
|
14894
|
+
return;
|
|
14895
|
+
}
|
|
14896
|
+
MultiTouchHelper.reset();
|
|
14897
|
+
}
|
|
14898
|
+
if (!moving) gestureData.center = MultiTouchHelper.state.center;
|
|
14899
|
+
} else moving = zooming = rotating = true;
|
|
14900
|
+
Object.assign(data, gestureData.center);
|
|
14901
|
+
data.multiTouch = true;
|
|
14902
|
+
if (rotating) this.rotate(getRotateEventData(gestureData.rotation, data));
|
|
14903
|
+
if (zooming) this.zoom(getZoomEventData(gestureData.scale, data));
|
|
14904
|
+
if (moving) this.move(getMoveEventData(gestureData.move, data));
|
|
14676
14905
|
};
|
|
14677
14906
|
const dragger = Dragger.prototype;
|
|
14678
14907
|
const {abs: abs$1} = Math;
|
|
@@ -17408,6 +17637,17 @@ var LeaferUI = function(exports) {
|
|
|
17408
17637
|
exports.UI.addAttr("disabledStyle", undefined, stateStyleType);
|
|
17409
17638
|
exports.UI.addAttr("placeholderStyle", undefined, stateStyleType);
|
|
17410
17639
|
exports.UI.addAttr("button", false, dataType);
|
|
17640
|
+
ui$1.set = function(data, transition) {
|
|
17641
|
+
if (data) {
|
|
17642
|
+
if (transition) {
|
|
17643
|
+
if (transition === "temp") {
|
|
17644
|
+
this.lockNormalStyle = true;
|
|
17645
|
+
Object.assign(this, data);
|
|
17646
|
+
this.lockNormalStyle = false;
|
|
17647
|
+
} else this.animate(data, transition);
|
|
17648
|
+
} else Object.assign(this, data);
|
|
17649
|
+
}
|
|
17650
|
+
};
|
|
17411
17651
|
ui$1.focus = function(value = true) {
|
|
17412
17652
|
this.waitLeafer(() => {
|
|
17413
17653
|
let {focusData: focusData} = this.app.interaction;
|
|
@@ -17809,14 +18049,10 @@ var LeaferUI = function(exports) {
|
|
|
17809
18049
|
renderOptions.bounds = canvas.bounds;
|
|
17810
18050
|
}
|
|
17811
18051
|
canvas.save();
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
leaf.fill = oldFill;
|
|
17817
|
-
} else {
|
|
17818
|
-
leaf.__render(canvas, renderOptions);
|
|
17819
|
-
}
|
|
18052
|
+
const igroneFill = isFrame && !isUndefined(fill), oldFill = leaf.get("fill");
|
|
18053
|
+
if (igroneFill) leaf.fill = "";
|
|
18054
|
+
Platform.render(leaf, canvas, renderOptions);
|
|
18055
|
+
if (igroneFill) leaf.fill = oldFill;
|
|
17820
18056
|
canvas.restore();
|
|
17821
18057
|
if (sliceLeaf) sliceLeaf.__updateWorldOpacity();
|
|
17822
18058
|
if (trim) {
|
|
@@ -17962,6 +18198,8 @@ var LeaferUI = function(exports) {
|
|
|
17962
18198
|
return width;
|
|
17963
18199
|
}
|
|
17964
18200
|
});
|
|
18201
|
+
Plugin.add("bright");
|
|
18202
|
+
exports.UI.addAttr("bright", false, dimType);
|
|
17965
18203
|
exports.AlignHelper = AlignHelper;
|
|
17966
18204
|
exports.AnimateEasing = AnimateEasing;
|
|
17967
18205
|
exports.AnimateEvent = AnimateEvent;
|
|
@@ -18008,6 +18246,7 @@ var LeaferUI = function(exports) {
|
|
|
18008
18246
|
exports.FileHelper = FileHelper;
|
|
18009
18247
|
exports.Filter = Filter;
|
|
18010
18248
|
exports.Finder = Finder;
|
|
18249
|
+
exports.FourNumberHelper = FourNumberHelper;
|
|
18011
18250
|
exports.FrameData = FrameData;
|
|
18012
18251
|
exports.GroupData = GroupData;
|
|
18013
18252
|
exports.HTMLTextData = HTMLTextData;
|
|
@@ -18134,6 +18373,7 @@ var LeaferUI = function(exports) {
|
|
|
18134
18373
|
exports.defineDataProcessor = defineDataProcessor;
|
|
18135
18374
|
exports.defineKey = defineKey;
|
|
18136
18375
|
exports.defineLeafAttr = defineLeafAttr;
|
|
18376
|
+
exports.dimType = dimType;
|
|
18137
18377
|
exports.doBoundsType = doBoundsType;
|
|
18138
18378
|
exports.doStrokeType = doStrokeType;
|
|
18139
18379
|
exports.effectType = effectType;
|
|
@@ -18185,8 +18425,8 @@ var LeaferUI = function(exports) {
|
|
|
18185
18425
|
exports.stateType = stateType;
|
|
18186
18426
|
exports.strokeType = strokeType;
|
|
18187
18427
|
exports.surfaceType = surfaceType;
|
|
18188
|
-
exports.tempBounds = tempBounds$
|
|
18189
|
-
exports.tempMatrix = tempMatrix$
|
|
18428
|
+
exports.tempBounds = tempBounds$2;
|
|
18429
|
+
exports.tempMatrix = tempMatrix$2;
|
|
18190
18430
|
exports.tempPoint = tempPoint$3;
|
|
18191
18431
|
exports.tryToNumber = tryToNumber;
|
|
18192
18432
|
exports.useCanvas = useCanvas;
|