@leafer-draw/worker 1.0.0 → 1.0.2
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 +2389 -0
- package/dist/worker.esm.js +37 -35
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +215 -112
- package/dist/worker.min.cjs +1 -0
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +215 -113
- package/dist/worker.module.min.js +1 -1
- package/package.json +13 -7
package/dist/worker.js
CHANGED
|
@@ -51,6 +51,8 @@ var LeaferUI = (function (exports) {
|
|
|
51
51
|
const { round, pow: pow$1, PI: PI$4 } = Math;
|
|
52
52
|
const MathHelper = {
|
|
53
53
|
within(value, min, max) {
|
|
54
|
+
if (typeof min === 'object')
|
|
55
|
+
max = min.max, min = min.min;
|
|
54
56
|
if (min !== undefined && value < min)
|
|
55
57
|
value = min;
|
|
56
58
|
if (max !== undefined && value > max)
|
|
@@ -112,6 +114,19 @@ var LeaferUI = (function (exports) {
|
|
|
112
114
|
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
113
115
|
num = round(num * a) / a;
|
|
114
116
|
return num === -0 ? 0 : num;
|
|
117
|
+
},
|
|
118
|
+
getScaleData(scale, size, originSize, scaleData) {
|
|
119
|
+
if (!scaleData)
|
|
120
|
+
scaleData = {};
|
|
121
|
+
if (size) {
|
|
122
|
+
scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
|
|
123
|
+
scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
|
|
124
|
+
}
|
|
125
|
+
else if (scale) {
|
|
126
|
+
scaleData.scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
127
|
+
scaleData.scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
128
|
+
}
|
|
129
|
+
return scaleData;
|
|
115
130
|
}
|
|
116
131
|
};
|
|
117
132
|
const OneRadian = PI$4 / 180;
|
|
@@ -153,10 +168,10 @@ var LeaferUI = (function (exports) {
|
|
|
153
168
|
t.e += x;
|
|
154
169
|
t.f += y;
|
|
155
170
|
},
|
|
156
|
-
translateInner(t, x, y,
|
|
171
|
+
translateInner(t, x, y, hasOrigin) {
|
|
157
172
|
t.e += t.a * x + t.c * y;
|
|
158
173
|
t.f += t.b * x + t.d * y;
|
|
159
|
-
if (
|
|
174
|
+
if (hasOrigin)
|
|
160
175
|
t.e -= x, t.f -= y;
|
|
161
176
|
},
|
|
162
177
|
scale(t, scaleX, scaleY = scaleX) {
|
|
@@ -315,7 +330,7 @@ var LeaferUI = (function (exports) {
|
|
|
315
330
|
to.y -= (f * a - e * b) * s;
|
|
316
331
|
}
|
|
317
332
|
},
|
|
318
|
-
setLayout(t, layout, origin, bcChanged) {
|
|
333
|
+
setLayout(t, layout, origin, around, bcChanged) {
|
|
319
334
|
const { x, y, scaleX, scaleY } = layout;
|
|
320
335
|
if (bcChanged === undefined)
|
|
321
336
|
bcChanged = layout.rotation || layout.skewX || layout.skewY;
|
|
@@ -347,10 +362,10 @@ var LeaferUI = (function (exports) {
|
|
|
347
362
|
}
|
|
348
363
|
t.e = x;
|
|
349
364
|
t.f = y;
|
|
350
|
-
if (origin)
|
|
351
|
-
M$6.translateInner(t, -origin.x, -origin.y,
|
|
365
|
+
if (origin = origin || around)
|
|
366
|
+
M$6.translateInner(t, -origin.x, -origin.y, !around);
|
|
352
367
|
},
|
|
353
|
-
getLayout(t, origin, firstSkewY) {
|
|
368
|
+
getLayout(t, origin, around, firstSkewY) {
|
|
354
369
|
const { a, b, c, d, e, f } = t;
|
|
355
370
|
let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
|
|
356
371
|
if (b || c) {
|
|
@@ -379,9 +394,11 @@ var LeaferUI = (function (exports) {
|
|
|
379
394
|
scaleY = d;
|
|
380
395
|
rotation = skewX = skewY = 0;
|
|
381
396
|
}
|
|
382
|
-
if (origin) {
|
|
397
|
+
if (origin = around || origin) {
|
|
383
398
|
x += origin.x * a + origin.y * c;
|
|
384
399
|
y += origin.x * b + origin.y * d;
|
|
400
|
+
if (!around)
|
|
401
|
+
x -= origin.x, y -= origin.y;
|
|
385
402
|
}
|
|
386
403
|
return { x, y, scaleX, scaleY, rotation, skewX, skewY };
|
|
387
404
|
},
|
|
@@ -408,7 +425,7 @@ var LeaferUI = (function (exports) {
|
|
|
408
425
|
};
|
|
409
426
|
const M$6 = MatrixHelper;
|
|
410
427
|
|
|
411
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
428
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
412
429
|
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
413
430
|
const PointHelper = {
|
|
414
431
|
defaultPoint: getPointData(),
|
|
@@ -464,7 +481,7 @@ var LeaferUI = (function (exports) {
|
|
|
464
481
|
tempToOuterOf(t, matrix) {
|
|
465
482
|
const { tempPoint: temp } = P$5;
|
|
466
483
|
copy$a(temp, t);
|
|
467
|
-
toOuterPoint$
|
|
484
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
468
485
|
return temp;
|
|
469
486
|
},
|
|
470
487
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -483,7 +500,7 @@ var LeaferUI = (function (exports) {
|
|
|
483
500
|
toInnerPoint$2(matrix, t, to);
|
|
484
501
|
},
|
|
485
502
|
toOuterOf(t, matrix, to) {
|
|
486
|
-
toOuterPoint$
|
|
503
|
+
toOuterPoint$3(matrix, t, to);
|
|
487
504
|
},
|
|
488
505
|
getCenter(t, to) {
|
|
489
506
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -709,12 +726,12 @@ var LeaferUI = (function (exports) {
|
|
|
709
726
|
toInnerPoint(outer, to, distance) {
|
|
710
727
|
MatrixHelper.toInnerPoint(this, outer, to, distance);
|
|
711
728
|
}
|
|
712
|
-
setLayout(data, origin) {
|
|
713
|
-
MatrixHelper.setLayout(this, data, origin);
|
|
729
|
+
setLayout(data, origin, around) {
|
|
730
|
+
MatrixHelper.setLayout(this, data, origin, around);
|
|
714
731
|
return this;
|
|
715
732
|
}
|
|
716
|
-
getLayout(origin, firstSkewY) {
|
|
717
|
-
return MatrixHelper.getLayout(this, origin, firstSkewY);
|
|
733
|
+
getLayout(origin, around, firstSkewY) {
|
|
734
|
+
return MatrixHelper.getLayout(this, origin, around, firstSkewY);
|
|
718
735
|
}
|
|
719
736
|
withScale(scaleX, scaleY) {
|
|
720
737
|
return MatrixHelper.withScale(this, scaleX, scaleY);
|
|
@@ -763,7 +780,7 @@ var LeaferUI = (function (exports) {
|
|
|
763
780
|
const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
|
|
764
781
|
|
|
765
782
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
|
|
766
|
-
const { toOuterPoint: toOuterPoint$
|
|
783
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
767
784
|
const { float, fourNumber } = MathHelper;
|
|
768
785
|
const { floor, ceil: ceil$2 } = Math;
|
|
769
786
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
@@ -783,17 +800,24 @@ var LeaferUI = (function (exports) {
|
|
|
783
800
|
t.width = bounds.width;
|
|
784
801
|
t.height = bounds.height;
|
|
785
802
|
},
|
|
786
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
803
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
804
|
+
const { x, y, width, height } = bounds;
|
|
787
805
|
if (spread instanceof Array) {
|
|
788
806
|
const four = fourNumber(spread);
|
|
789
807
|
isShrink
|
|
790
|
-
? B.set(t,
|
|
791
|
-
: B.set(t,
|
|
808
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
809
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
792
810
|
}
|
|
793
811
|
else {
|
|
794
812
|
if (isShrink)
|
|
795
813
|
spread = -spread;
|
|
796
|
-
B.set(t,
|
|
814
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
815
|
+
}
|
|
816
|
+
if (side) {
|
|
817
|
+
if (side === 'width')
|
|
818
|
+
t.y = y, t.height = height;
|
|
819
|
+
else
|
|
820
|
+
t.x = x, t.width = width;
|
|
797
821
|
}
|
|
798
822
|
},
|
|
799
823
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -870,16 +894,16 @@ var LeaferUI = (function (exports) {
|
|
|
870
894
|
else {
|
|
871
895
|
point.x = t.x;
|
|
872
896
|
point.y = t.y;
|
|
873
|
-
toOuterPoint$
|
|
897
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
874
898
|
setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
875
899
|
point.x = t.x + t.width;
|
|
876
|
-
toOuterPoint$
|
|
900
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
877
901
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
878
902
|
point.y = t.y + t.height;
|
|
879
|
-
toOuterPoint$
|
|
903
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
880
904
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
881
905
|
point.x = t.x;
|
|
882
|
-
toOuterPoint$
|
|
906
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
883
907
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
884
908
|
toBounds$4(tempPointBounds$1, to);
|
|
885
909
|
}
|
|
@@ -893,16 +917,16 @@ var LeaferUI = (function (exports) {
|
|
|
893
917
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
894
918
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
895
919
|
},
|
|
896
|
-
getSpread(t, spread) {
|
|
920
|
+
getSpread(t, spread, side) {
|
|
897
921
|
const n = {};
|
|
898
|
-
B.copyAndSpread(n, t, spread);
|
|
922
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
899
923
|
return n;
|
|
900
924
|
},
|
|
901
|
-
spread(t, spread) {
|
|
902
|
-
B.copyAndSpread(t, t, spread);
|
|
925
|
+
spread(t, spread, side) {
|
|
926
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
903
927
|
},
|
|
904
|
-
shrink(t, shrink) {
|
|
905
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
928
|
+
shrink(t, shrink, side) {
|
|
929
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
906
930
|
},
|
|
907
931
|
ceil(t) {
|
|
908
932
|
const { x, y } = t;
|
|
@@ -1085,12 +1109,12 @@ var LeaferUI = (function (exports) {
|
|
|
1085
1109
|
getFitMatrix(put, baseScale) {
|
|
1086
1110
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1087
1111
|
}
|
|
1088
|
-
spread(fourNumber) {
|
|
1089
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1112
|
+
spread(fourNumber, side) {
|
|
1113
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1090
1114
|
return this;
|
|
1091
1115
|
}
|
|
1092
|
-
shrink(fourNumber) {
|
|
1093
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1116
|
+
shrink(fourNumber, side) {
|
|
1117
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1094
1118
|
return this;
|
|
1095
1119
|
}
|
|
1096
1120
|
ceil() {
|
|
@@ -2002,7 +2026,7 @@ var LeaferUI = (function (exports) {
|
|
|
2002
2026
|
DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
|
|
2003
2027
|
this.size.pixelRatio || (this.size.pixelRatio = 1);
|
|
2004
2028
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2005
|
-
if (!this.unreal) {
|
|
2029
|
+
if (this.context && !this.unreal) {
|
|
2006
2030
|
this.updateViewSize();
|
|
2007
2031
|
this.smooth = this.config.smooth;
|
|
2008
2032
|
}
|
|
@@ -2175,7 +2199,7 @@ var LeaferUI = (function (exports) {
|
|
|
2175
2199
|
this.manager ? this.manager.recycle(this) : this.destroy();
|
|
2176
2200
|
}
|
|
2177
2201
|
}
|
|
2178
|
-
updateRender() { }
|
|
2202
|
+
updateRender(_bounds) { }
|
|
2179
2203
|
unrealCanvas() { }
|
|
2180
2204
|
destroy() {
|
|
2181
2205
|
this.manager = this.view = this.parentView = null;
|
|
@@ -2907,60 +2931,75 @@ var LeaferUI = (function (exports) {
|
|
|
2907
2931
|
}
|
|
2908
2932
|
beginPath() {
|
|
2909
2933
|
beginPath(this.__path);
|
|
2934
|
+
this.paint();
|
|
2910
2935
|
return this;
|
|
2911
2936
|
}
|
|
2912
2937
|
moveTo(x, y) {
|
|
2913
2938
|
moveTo$4(this.__path, x, y);
|
|
2939
|
+
this.paint();
|
|
2914
2940
|
return this;
|
|
2915
2941
|
}
|
|
2916
2942
|
lineTo(x, y) {
|
|
2917
2943
|
lineTo$3(this.__path, x, y);
|
|
2944
|
+
this.paint();
|
|
2918
2945
|
return this;
|
|
2919
2946
|
}
|
|
2920
2947
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2921
2948
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2949
|
+
this.paint();
|
|
2922
2950
|
return this;
|
|
2923
2951
|
}
|
|
2924
2952
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2925
2953
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2954
|
+
this.paint();
|
|
2926
2955
|
return this;
|
|
2927
2956
|
}
|
|
2928
2957
|
closePath() {
|
|
2929
2958
|
closePath$3(this.__path);
|
|
2959
|
+
this.paint();
|
|
2930
2960
|
return this;
|
|
2931
2961
|
}
|
|
2932
2962
|
rect(x, y, width, height) {
|
|
2933
2963
|
rect$1(this.__path, x, y, width, height);
|
|
2964
|
+
this.paint();
|
|
2934
2965
|
return this;
|
|
2935
2966
|
}
|
|
2936
2967
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2937
2968
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2969
|
+
this.paint();
|
|
2938
2970
|
return this;
|
|
2939
2971
|
}
|
|
2940
2972
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2941
2973
|
ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2974
|
+
this.paint();
|
|
2942
2975
|
return this;
|
|
2943
2976
|
}
|
|
2944
2977
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2945
2978
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2979
|
+
this.paint();
|
|
2946
2980
|
return this;
|
|
2947
2981
|
}
|
|
2948
2982
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2949
2983
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2984
|
+
this.paint();
|
|
2950
2985
|
return this;
|
|
2951
2986
|
}
|
|
2952
2987
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2953
2988
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2989
|
+
this.paint();
|
|
2954
2990
|
return this;
|
|
2955
2991
|
}
|
|
2956
2992
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2957
2993
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2994
|
+
this.paint();
|
|
2958
2995
|
return this;
|
|
2959
2996
|
}
|
|
2960
2997
|
drawPoints(points, curve, close) {
|
|
2961
2998
|
drawPoints$2(this.__path, points, curve, close);
|
|
2999
|
+
this.paint();
|
|
2962
3000
|
return this;
|
|
2963
3001
|
}
|
|
3002
|
+
paint() { }
|
|
2964
3003
|
}
|
|
2965
3004
|
|
|
2966
3005
|
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
@@ -3982,7 +4021,7 @@ var LeaferUI = (function (exports) {
|
|
|
3982
4021
|
};
|
|
3983
4022
|
}
|
|
3984
4023
|
|
|
3985
|
-
const { copy: copy$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4024
|
+
const { copy: copy$6, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3986
4025
|
const matrix = {};
|
|
3987
4026
|
const LeafHelper = {
|
|
3988
4027
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4047,10 +4086,9 @@ var LeaferUI = (function (exports) {
|
|
|
4047
4086
|
}
|
|
4048
4087
|
return true;
|
|
4049
4088
|
},
|
|
4050
|
-
moveWorld(t, x, y = 0) {
|
|
4089
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4051
4090
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4052
|
-
|
|
4053
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4091
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4054
4092
|
L.moveLocal(t, local.x, local.y);
|
|
4055
4093
|
},
|
|
4056
4094
|
moveLocal(t, x, y = 0) {
|
|
@@ -4069,8 +4107,13 @@ var LeaferUI = (function (exports) {
|
|
|
4069
4107
|
zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
|
|
4070
4108
|
copy$6(matrix, t.__localMatrix);
|
|
4071
4109
|
scaleOfOuter$2(matrix, origin, scaleX, scaleY);
|
|
4072
|
-
|
|
4073
|
-
|
|
4110
|
+
if (t.origin || t.around) {
|
|
4111
|
+
L.setTransform(t, matrix, resize);
|
|
4112
|
+
}
|
|
4113
|
+
else {
|
|
4114
|
+
moveByMatrix(t, matrix);
|
|
4115
|
+
t.scaleResize(scaleX, scaleY, resize !== true);
|
|
4116
|
+
}
|
|
4074
4117
|
},
|
|
4075
4118
|
rotateOfWorld(t, origin, angle) {
|
|
4076
4119
|
L.rotateOfLocal(t, getTempLocal(t, origin), angle);
|
|
@@ -4078,8 +4121,13 @@ var LeaferUI = (function (exports) {
|
|
|
4078
4121
|
rotateOfLocal(t, origin, angle) {
|
|
4079
4122
|
copy$6(matrix, t.__localMatrix);
|
|
4080
4123
|
rotateOfOuter$2(matrix, origin, angle);
|
|
4081
|
-
|
|
4082
|
-
|
|
4124
|
+
if (t.origin || t.around) {
|
|
4125
|
+
L.setTransform(t, matrix);
|
|
4126
|
+
}
|
|
4127
|
+
else {
|
|
4128
|
+
moveByMatrix(t, matrix);
|
|
4129
|
+
t.rotation = MathHelper.formatRotation(t.rotation + angle);
|
|
4130
|
+
}
|
|
4083
4131
|
},
|
|
4084
4132
|
skewOfWorld(t, origin, skewX, skewY, resize) {
|
|
4085
4133
|
L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
|
|
@@ -4102,7 +4150,7 @@ var LeaferUI = (function (exports) {
|
|
|
4102
4150
|
L.setTransform(t, matrix, resize);
|
|
4103
4151
|
},
|
|
4104
4152
|
setTransform(t, transform, resize) {
|
|
4105
|
-
const layout = getLayout(transform);
|
|
4153
|
+
const layout = getLayout(transform, t.origin && L.getInnerOrigin(t, t.origin), t.around && L.getInnerOrigin(t, t.around));
|
|
4106
4154
|
if (resize) {
|
|
4107
4155
|
const scaleX = layout.scaleX / t.scaleX;
|
|
4108
4156
|
const scaleY = layout.scaleY / t.scaleY;
|
|
@@ -4115,13 +4163,19 @@ var LeaferUI = (function (exports) {
|
|
|
4115
4163
|
t.set(layout);
|
|
4116
4164
|
}
|
|
4117
4165
|
},
|
|
4166
|
+
getFlipTransform(t, axis) {
|
|
4167
|
+
const m = getMatrixData();
|
|
4168
|
+
const sign = axis === 'x' ? 1 : -1;
|
|
4169
|
+
scaleOfOuter$2(m, L.getLocalOrigin(t, 'center'), -1 * sign, 1 * sign);
|
|
4170
|
+
return m;
|
|
4171
|
+
},
|
|
4118
4172
|
getLocalOrigin(t, origin) {
|
|
4119
4173
|
return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
|
|
4120
4174
|
},
|
|
4121
4175
|
getInnerOrigin(t, origin) {
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
return
|
|
4176
|
+
const innerOrigin = {};
|
|
4177
|
+
AroundHelper.toPoint(origin, t.boxBounds, innerOrigin);
|
|
4178
|
+
return innerOrigin;
|
|
4125
4179
|
},
|
|
4126
4180
|
getRelativeWorld(t, relative, temp) {
|
|
4127
4181
|
copy$6(matrix, t.worldTransform);
|
|
@@ -4548,7 +4602,10 @@ var LeaferUI = (function (exports) {
|
|
|
4548
4602
|
on(type, listener, options) {
|
|
4549
4603
|
let capture, once;
|
|
4550
4604
|
if (options) {
|
|
4551
|
-
if (
|
|
4605
|
+
if (options === 'once') {
|
|
4606
|
+
once = true;
|
|
4607
|
+
}
|
|
4608
|
+
else if (typeof options === 'boolean') {
|
|
4552
4609
|
capture = options;
|
|
4553
4610
|
}
|
|
4554
4611
|
else {
|
|
@@ -4579,7 +4636,7 @@ var LeaferUI = (function (exports) {
|
|
|
4579
4636
|
if (listener) {
|
|
4580
4637
|
let capture;
|
|
4581
4638
|
if (options)
|
|
4582
|
-
capture = typeof options === 'boolean' ? options : options.capture;
|
|
4639
|
+
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4583
4640
|
let events, index;
|
|
4584
4641
|
const map = __getListenerMap(this, capture);
|
|
4585
4642
|
typeList.forEach(type => {
|
|
@@ -4881,7 +4938,7 @@ var LeaferUI = (function (exports) {
|
|
|
4881
4938
|
const layout = this.__layout, local = this.__local, data = this.__;
|
|
4882
4939
|
if (layout.affectScaleOrRotation) {
|
|
4883
4940
|
if (layout.scaleChanged || layout.rotationChanged) {
|
|
4884
|
-
setLayout(local, data, null, layout.affectRotation);
|
|
4941
|
+
setLayout(local, data, null, null, layout.affectRotation);
|
|
4885
4942
|
layout.scaleChanged = layout.rotationChanged = false;
|
|
4886
4943
|
}
|
|
4887
4944
|
}
|
|
@@ -4889,7 +4946,7 @@ var LeaferUI = (function (exports) {
|
|
|
4889
4946
|
local.f = data.y + data.offsetY;
|
|
4890
4947
|
if (data.around || data.origin) {
|
|
4891
4948
|
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
|
|
4892
|
-
translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.
|
|
4949
|
+
translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
|
|
4893
4950
|
}
|
|
4894
4951
|
}
|
|
4895
4952
|
this.__layout.matrixChanged = false;
|
|
@@ -4898,7 +4955,7 @@ var LeaferUI = (function (exports) {
|
|
|
4898
4955
|
|
|
4899
4956
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
4900
4957
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4901
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
4958
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$4 } = BoundsHelper;
|
|
4902
4959
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4903
4960
|
const LeafBounds = {
|
|
4904
4961
|
__updateWorldBounds() {
|
|
@@ -4999,7 +5056,7 @@ var LeaferUI = (function (exports) {
|
|
|
4999
5056
|
updateAllMatrix$2(this);
|
|
5000
5057
|
updateBounds$1(this, this);
|
|
5001
5058
|
if (this.__.__autoSide)
|
|
5002
|
-
this.__updateBoxBounds();
|
|
5059
|
+
this.__updateBoxBounds(true);
|
|
5003
5060
|
}
|
|
5004
5061
|
else {
|
|
5005
5062
|
updateAllMatrix$2(this);
|
|
@@ -5017,11 +5074,11 @@ var LeaferUI = (function (exports) {
|
|
|
5017
5074
|
},
|
|
5018
5075
|
__updateStrokeBounds() {
|
|
5019
5076
|
const layout = this.__layout;
|
|
5020
|
-
copyAndSpread$
|
|
5077
|
+
copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5021
5078
|
},
|
|
5022
5079
|
__updateRenderBounds() {
|
|
5023
5080
|
const layout = this.__layout;
|
|
5024
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5081
|
+
layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$4(layout.renderBounds, layout.strokeBounds);
|
|
5025
5082
|
}
|
|
5026
5083
|
};
|
|
5027
5084
|
|
|
@@ -5118,7 +5175,7 @@ var LeaferUI = (function (exports) {
|
|
|
5118
5175
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5119
5176
|
const { toOuterOf } = BoundsHelper;
|
|
5120
5177
|
const { copy: copy$3 } = PointHelper;
|
|
5121
|
-
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5178
|
+
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5122
5179
|
exports.Leaf = class Leaf {
|
|
5123
5180
|
get tag() { return this.__tag; }
|
|
5124
5181
|
set tag(_value) { }
|
|
@@ -5144,6 +5201,8 @@ var LeaferUI = (function (exports) {
|
|
|
5144
5201
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5145
5202
|
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5146
5203
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5204
|
+
set event(map) { let event; for (let key in map)
|
|
5205
|
+
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
|
|
5147
5206
|
constructor(data) {
|
|
5148
5207
|
this.innerId = create(LEAF);
|
|
5149
5208
|
this.reset(data);
|
|
@@ -5379,6 +5438,9 @@ var LeaferUI = (function (exports) {
|
|
|
5379
5438
|
move(x, y) {
|
|
5380
5439
|
moveLocal(this, x, y);
|
|
5381
5440
|
}
|
|
5441
|
+
moveInner(x, y) {
|
|
5442
|
+
moveWorld(this, x, y, true);
|
|
5443
|
+
}
|
|
5382
5444
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5383
5445
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5384
5446
|
}
|
|
@@ -5403,6 +5465,9 @@ var LeaferUI = (function (exports) {
|
|
|
5403
5465
|
skewOfWorld(worldOrigin, skewX, skewY, resize) {
|
|
5404
5466
|
skewOfWorld(this, worldOrigin, skewX, skewY, resize);
|
|
5405
5467
|
}
|
|
5468
|
+
flip(axis) {
|
|
5469
|
+
transform(this, getFlipTransform(this, axis));
|
|
5470
|
+
}
|
|
5406
5471
|
scaleResize(scaleX, scaleY = scaleX, _noResize) {
|
|
5407
5472
|
this.scaleX *= scaleX;
|
|
5408
5473
|
this.scaleY *= scaleY;
|
|
@@ -5760,7 +5825,7 @@ var LeaferUI = (function (exports) {
|
|
|
5760
5825
|
}
|
|
5761
5826
|
}
|
|
5762
5827
|
|
|
5763
|
-
const version = "1.0.
|
|
5828
|
+
const version = "1.0.1";
|
|
5764
5829
|
const inviteCode = {};
|
|
5765
5830
|
|
|
5766
5831
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -5830,7 +5895,7 @@ var LeaferUI = (function (exports) {
|
|
|
5830
5895
|
Platform.name = 'web';
|
|
5831
5896
|
Platform.isWorker = true;
|
|
5832
5897
|
Platform.requestRender = function (render) { requestAnimationFrame(render); };
|
|
5833
|
-
Platform
|
|
5898
|
+
defineKey(Platform, 'devicePixelRatio', { get() { return 1; } });
|
|
5834
5899
|
const { userAgent } = navigator;
|
|
5835
5900
|
if (userAgent.indexOf("Firefox") > -1) {
|
|
5836
5901
|
Platform.conicGradientRotate90 = true;
|
|
@@ -6326,14 +6391,14 @@ var LeaferUI = (function (exports) {
|
|
|
6326
6391
|
if (Debug.showRepaint)
|
|
6327
6392
|
this.canvas.strokeWorld(bounds, 'red');
|
|
6328
6393
|
this.target.__render(this.canvas, options);
|
|
6329
|
-
this.renderBounds = realBounds || bounds;
|
|
6394
|
+
this.renderBounds = realBounds = realBounds || bounds;
|
|
6330
6395
|
this.renderOptions = options;
|
|
6331
|
-
this.totalBounds.isEmpty() ? this.totalBounds =
|
|
6396
|
+
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
6332
6397
|
if (Debug.showHitView)
|
|
6333
6398
|
this.renderHitView(options);
|
|
6334
6399
|
if (Debug.showBoundsView)
|
|
6335
6400
|
this.renderBoundsView(options);
|
|
6336
|
-
this.canvas.updateRender();
|
|
6401
|
+
this.canvas.updateRender(realBounds);
|
|
6337
6402
|
}
|
|
6338
6403
|
renderHitView(_options) { }
|
|
6339
6404
|
renderBoundsView(_options) { }
|
|
@@ -6642,6 +6707,11 @@ var LeaferUI = (function (exports) {
|
|
|
6642
6707
|
}
|
|
6643
6708
|
|
|
6644
6709
|
class LeaferData extends GroupData {
|
|
6710
|
+
__getInputData() {
|
|
6711
|
+
const data = super.__getInputData();
|
|
6712
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
6713
|
+
return data;
|
|
6714
|
+
}
|
|
6645
6715
|
}
|
|
6646
6716
|
|
|
6647
6717
|
class FrameData extends BoxData {
|
|
@@ -6719,6 +6789,11 @@ var LeaferUI = (function (exports) {
|
|
|
6719
6789
|
}
|
|
6720
6790
|
|
|
6721
6791
|
class CanvasData extends RectData {
|
|
6792
|
+
__getInputData() {
|
|
6793
|
+
const data = super.__getInputData();
|
|
6794
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
6795
|
+
return data;
|
|
6796
|
+
}
|
|
6722
6797
|
}
|
|
6723
6798
|
|
|
6724
6799
|
const UIBounds = {
|
|
@@ -7384,7 +7459,7 @@ var LeaferUI = (function (exports) {
|
|
|
7384
7459
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7385
7460
|
if (this.isApp)
|
|
7386
7461
|
this.__setApp();
|
|
7387
|
-
this.__checkAutoLayout(config);
|
|
7462
|
+
this.__checkAutoLayout(config, parentApp);
|
|
7388
7463
|
this.view = canvas.view;
|
|
7389
7464
|
if (parentApp) {
|
|
7390
7465
|
this.__bindApp(parentApp);
|
|
@@ -7485,9 +7560,10 @@ var LeaferUI = (function (exports) {
|
|
|
7485
7560
|
this.leafer = leafer;
|
|
7486
7561
|
this.__level = 1;
|
|
7487
7562
|
}
|
|
7488
|
-
__checkAutoLayout(config) {
|
|
7489
|
-
if (!
|
|
7490
|
-
|
|
7563
|
+
__checkAutoLayout(config, parentApp) {
|
|
7564
|
+
if (!parentApp) {
|
|
7565
|
+
if (!config.width || !config.height)
|
|
7566
|
+
this.autoLayout = new AutoBounds(config);
|
|
7491
7567
|
this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
|
|
7492
7568
|
}
|
|
7493
7569
|
}
|
|
@@ -7622,12 +7698,21 @@ var LeaferUI = (function (exports) {
|
|
|
7622
7698
|
list.push(item);
|
|
7623
7699
|
}
|
|
7624
7700
|
}
|
|
7625
|
-
zoom(_zoomType, _padding, _fixedScale) {
|
|
7701
|
+
zoom(_zoomType, _padding, _fixedScale) {
|
|
7702
|
+
return debug$1.error('need @leafer-in/view');
|
|
7703
|
+
}
|
|
7626
7704
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
7627
7705
|
getValidScale(changeScale) { return changeScale; }
|
|
7628
7706
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
7629
7707
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
7630
7708
|
}
|
|
7709
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
7710
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
7711
|
+
}
|
|
7712
|
+
updateClientBounds() {
|
|
7713
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
7714
|
+
}
|
|
7715
|
+
receiveEvent(_event) { }
|
|
7631
7716
|
__checkUpdateLayout() {
|
|
7632
7717
|
this.__layout.update();
|
|
7633
7718
|
}
|
|
@@ -7711,7 +7796,7 @@ var LeaferUI = (function (exports) {
|
|
|
7711
7796
|
const rect = exports.Rect.prototype;
|
|
7712
7797
|
const group = exports.Group.prototype;
|
|
7713
7798
|
const childrenRenderBounds = {};
|
|
7714
|
-
const { copy: copy$2, add, includes: includes$1 } = BoundsHelper;
|
|
7799
|
+
const { copy: copy$2, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
7715
7800
|
exports.Box = class Box extends exports.Group {
|
|
7716
7801
|
get __tag() { return 'Box'; }
|
|
7717
7802
|
get isBranchLeaf() { return true; }
|
|
@@ -7725,20 +7810,23 @@ var LeaferUI = (function (exports) {
|
|
|
7725
7810
|
return this.__updateRectRenderSpread() || -1;
|
|
7726
7811
|
}
|
|
7727
7812
|
__updateRectBoxBounds() { }
|
|
7728
|
-
__updateBoxBounds() {
|
|
7813
|
+
__updateBoxBounds(secondLayout) {
|
|
7729
7814
|
const data = this.__;
|
|
7730
7815
|
if (this.children.length) {
|
|
7731
7816
|
if (data.__autoSide) {
|
|
7732
7817
|
if (this.leafer && this.leafer.ready)
|
|
7733
7818
|
this.leafer.layouter.addExtra(this);
|
|
7734
7819
|
super.__updateBoxBounds();
|
|
7820
|
+
const { boxBounds } = this.__layout;
|
|
7735
7821
|
if (!data.__autoSize) {
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
7822
|
+
if (data.__autoWidth)
|
|
7823
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
7824
|
+
else
|
|
7825
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
7741
7826
|
}
|
|
7827
|
+
if (secondLayout && data.flow && data.padding)
|
|
7828
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
7829
|
+
this.__updateNaturalSize();
|
|
7742
7830
|
}
|
|
7743
7831
|
else {
|
|
7744
7832
|
this.__updateRectBoxBounds();
|
|
@@ -7758,13 +7846,13 @@ var LeaferUI = (function (exports) {
|
|
|
7758
7846
|
super.__updateRenderBounds();
|
|
7759
7847
|
copy$2(childrenRenderBounds, renderBounds);
|
|
7760
7848
|
this.__updateRectRenderBounds();
|
|
7761
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
7849
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
7762
7850
|
}
|
|
7763
7851
|
else {
|
|
7764
7852
|
this.__updateRectRenderBounds();
|
|
7765
7853
|
}
|
|
7766
7854
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
7767
|
-
if (
|
|
7855
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
7768
7856
|
add(renderBounds, childrenRenderBounds);
|
|
7769
7857
|
}
|
|
7770
7858
|
__updateRectRenderBounds() { }
|
|
@@ -8098,14 +8186,26 @@ var LeaferUI = (function (exports) {
|
|
|
8098
8186
|
exports.Image = __decorate([
|
|
8099
8187
|
registerUI()
|
|
8100
8188
|
], exports.Image);
|
|
8189
|
+
const MyImage = exports.Image;
|
|
8101
8190
|
|
|
8102
8191
|
exports.Canvas = class Canvas extends exports.Rect {
|
|
8103
8192
|
get __tag() { return 'Canvas'; }
|
|
8193
|
+
get ready() { return !this.url; }
|
|
8104
8194
|
constructor(data) {
|
|
8105
8195
|
super(data);
|
|
8106
8196
|
this.canvas = Creator.canvas(this.__);
|
|
8107
8197
|
this.context = this.canvas.context;
|
|
8108
8198
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8199
|
+
if (data && data.url)
|
|
8200
|
+
this.drawImage(data.url);
|
|
8201
|
+
}
|
|
8202
|
+
drawImage(url) {
|
|
8203
|
+
new LeaferImage({ url }).load((image) => {
|
|
8204
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8205
|
+
this.url = undefined;
|
|
8206
|
+
this.paint();
|
|
8207
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8208
|
+
});
|
|
8109
8209
|
}
|
|
8110
8210
|
draw(ui, offset, scale, rotation) {
|
|
8111
8211
|
ui.__layout.update();
|
|
@@ -8149,8 +8249,7 @@ var LeaferUI = (function (exports) {
|
|
|
8149
8249
|
destroy() {
|
|
8150
8250
|
if (this.canvas) {
|
|
8151
8251
|
this.canvas.destroy();
|
|
8152
|
-
this.canvas = null;
|
|
8153
|
-
this.context = null;
|
|
8252
|
+
this.canvas = this.context = null;
|
|
8154
8253
|
}
|
|
8155
8254
|
super.destroy();
|
|
8156
8255
|
}
|
|
@@ -8165,7 +8264,7 @@ var LeaferUI = (function (exports) {
|
|
|
8165
8264
|
resizeType(100)
|
|
8166
8265
|
], exports.Canvas.prototype, "height", void 0);
|
|
8167
8266
|
__decorate([
|
|
8168
|
-
resizeType(
|
|
8267
|
+
resizeType(1)
|
|
8169
8268
|
], exports.Canvas.prototype, "pixelRatio", void 0);
|
|
8170
8269
|
__decorate([
|
|
8171
8270
|
resizeType(true)
|
|
@@ -8189,13 +8288,13 @@ var LeaferUI = (function (exports) {
|
|
|
8189
8288
|
super(data);
|
|
8190
8289
|
}
|
|
8191
8290
|
__drawHitPath(canvas) {
|
|
8192
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8291
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8193
8292
|
canvas.beginPath();
|
|
8194
8293
|
if (this.__.__letterSpacing < 0) {
|
|
8195
8294
|
this.__drawPathByData(canvas);
|
|
8196
8295
|
}
|
|
8197
8296
|
else {
|
|
8198
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8297
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8199
8298
|
}
|
|
8200
8299
|
}
|
|
8201
8300
|
__drawPathByData(drawer, _data) {
|
|
@@ -8388,7 +8487,8 @@ var LeaferUI = (function (exports) {
|
|
|
8388
8487
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8389
8488
|
clearPath() { return this; }
|
|
8390
8489
|
paint() {
|
|
8391
|
-
this.pathElement.
|
|
8490
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8491
|
+
this.pathElement.forceUpdate('path');
|
|
8392
8492
|
}
|
|
8393
8493
|
};
|
|
8394
8494
|
__decorate([
|
|
@@ -8398,7 +8498,7 @@ var LeaferUI = (function (exports) {
|
|
|
8398
8498
|
penPathType()
|
|
8399
8499
|
], exports.Pen.prototype, "path", void 0);
|
|
8400
8500
|
exports.Pen = __decorate([
|
|
8401
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8501
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8402
8502
|
registerUI()
|
|
8403
8503
|
], exports.Pen);
|
|
8404
8504
|
function penPathType() {
|
|
@@ -8760,10 +8860,13 @@ var LeaferUI = (function (exports) {
|
|
|
8760
8860
|
const { get: get$2, translate } = MatrixHelper;
|
|
8761
8861
|
const tempBox = new Bounds();
|
|
8762
8862
|
const tempPoint = {};
|
|
8863
|
+
const tempScaleData = {};
|
|
8763
8864
|
function createData(leafPaint, image, paint, box) {
|
|
8764
|
-
const { blendMode } = paint;
|
|
8865
|
+
const { blendMode, sync } = paint;
|
|
8765
8866
|
if (blendMode)
|
|
8766
8867
|
leafPaint.blendMode = blendMode;
|
|
8868
|
+
if (sync)
|
|
8869
|
+
leafPaint.sync = sync;
|
|
8767
8870
|
leafPaint.data = getPatternData(paint, box, image);
|
|
8768
8871
|
}
|
|
8769
8872
|
function getPatternData(paint, box, image) {
|
|
@@ -8783,13 +8886,10 @@ var LeaferUI = (function (exports) {
|
|
|
8783
8886
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
8784
8887
|
}
|
|
8785
8888
|
}
|
|
8786
|
-
else if (size) {
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
else if (scale) {
|
|
8791
|
-
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
8792
|
-
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
8889
|
+
else if (scale || size) {
|
|
8890
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
8891
|
+
scaleX = tempScaleData.scaleX;
|
|
8892
|
+
scaleY = tempScaleData.scaleY;
|
|
8793
8893
|
}
|
|
8794
8894
|
if (align) {
|
|
8795
8895
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -8994,7 +9094,7 @@ var LeaferUI = (function (exports) {
|
|
|
8994
9094
|
const { abs } = Math;
|
|
8995
9095
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
8996
9096
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
8997
|
-
if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
|
|
9097
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
|
|
8998
9098
|
return false;
|
|
8999
9099
|
}
|
|
9000
9100
|
else {
|
|
@@ -9028,7 +9128,7 @@ var LeaferUI = (function (exports) {
|
|
|
9028
9128
|
return true;
|
|
9029
9129
|
}
|
|
9030
9130
|
else {
|
|
9031
|
-
if (!paint.style || Export.running) {
|
|
9131
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
9032
9132
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
9033
9133
|
}
|
|
9034
9134
|
else {
|
|
@@ -9898,6 +9998,7 @@ var LeaferUI = (function (exports) {
|
|
|
9898
9998
|
export(leaf, filename, options) {
|
|
9899
9999
|
this.running = true;
|
|
9900
10000
|
const fileType = FileHelper.fileType(filename);
|
|
10001
|
+
const isDownload = filename.includes('.');
|
|
9901
10002
|
options = FileHelper.getExportOptions(options);
|
|
9902
10003
|
return addTask((success) => new Promise((resolve) => {
|
|
9903
10004
|
const over = (result) => {
|
|
@@ -9907,19 +10008,13 @@ var LeaferUI = (function (exports) {
|
|
|
9907
10008
|
};
|
|
9908
10009
|
const { toURL } = Platform;
|
|
9909
10010
|
const { download } = Platform.origin;
|
|
9910
|
-
if (
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
else if (fileType === 'json') {
|
|
9914
|
-
download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
9915
|
-
return over({ data: true });
|
|
10011
|
+
if (fileType === 'json') {
|
|
10012
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
10013
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
9916
10014
|
}
|
|
9917
|
-
if (
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
else if (fileType === 'svg') {
|
|
9921
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
9922
|
-
return over({ data: true });
|
|
10015
|
+
if (fileType === 'svg') {
|
|
10016
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
10017
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
9923
10018
|
}
|
|
9924
10019
|
const { leafer } = leaf;
|
|
9925
10020
|
if (leafer) {
|
|
@@ -9928,14 +10023,8 @@ var LeaferUI = (function (exports) {
|
|
|
9928
10023
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
9929
10024
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
9930
10025
|
const { slice, trim, onCanvas } = options;
|
|
9931
|
-
let scale = options.scale || 1;
|
|
9932
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
9933
10026
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
9934
10027
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
9935
|
-
if (leaf.isApp) {
|
|
9936
|
-
scale *= pixelRatio;
|
|
9937
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
9938
|
-
}
|
|
9939
10028
|
const screenshot = options.screenshot || leaf.isApp;
|
|
9940
10029
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
9941
10030
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -9969,10 +10058,21 @@ var LeaferUI = (function (exports) {
|
|
|
9969
10058
|
}
|
|
9970
10059
|
renderBounds = leaf.getBounds('render', relative);
|
|
9971
10060
|
}
|
|
9972
|
-
const {
|
|
10061
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
10062
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
10063
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
10064
|
+
if (leaf.isApp) {
|
|
10065
|
+
scaleData.scaleX *= pixelRatio;
|
|
10066
|
+
scaleData.scaleY *= pixelRatio;
|
|
10067
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
10068
|
+
}
|
|
10069
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
10070
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
9973
10071
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
9974
|
-
|
|
10072
|
+
let sliceLeaf;
|
|
9975
10073
|
if (slice) {
|
|
10074
|
+
sliceLeaf = leaf;
|
|
10075
|
+
sliceLeaf.__worldOpacity = 0;
|
|
9976
10076
|
leaf = leafer;
|
|
9977
10077
|
renderOptions.bounds = canvas.bounds;
|
|
9978
10078
|
}
|
|
@@ -9987,6 +10087,8 @@ var LeaferUI = (function (exports) {
|
|
|
9987
10087
|
leaf.__render(canvas, renderOptions);
|
|
9988
10088
|
}
|
|
9989
10089
|
canvas.restore();
|
|
10090
|
+
if (sliceLeaf)
|
|
10091
|
+
sliceLeaf.__updateWorldOpacity();
|
|
9990
10092
|
if (trim) {
|
|
9991
10093
|
trimBounds = getTrimBounds(canvas);
|
|
9992
10094
|
const old = canvas, { width, height } = trimBounds;
|
|
@@ -10123,6 +10225,7 @@ var LeaferUI = (function (exports) {
|
|
|
10123
10225
|
exports.MathHelper = MathHelper;
|
|
10124
10226
|
exports.Matrix = Matrix;
|
|
10125
10227
|
exports.MatrixHelper = MatrixHelper;
|
|
10228
|
+
exports.MyImage = MyImage;
|
|
10126
10229
|
exports.NeedConvertToCanvasCommandMap = NeedConvertToCanvasCommandMap;
|
|
10127
10230
|
exports.OneRadian = OneRadian;
|
|
10128
10231
|
exports.PI2 = PI2;
|