leafer-draw 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/web.cjs +2562 -0
- package/dist/web.esm.js +77 -61
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +255 -138
- package/dist/web.min.cjs +1 -0
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +255 -139
- package/dist/web.module.min.js +1 -1
- package/package.json +9 -3
package/dist/web.module.js
CHANGED
|
@@ -48,6 +48,8 @@ const I$1 = IncrementId;
|
|
|
48
48
|
const { round, pow: pow$1, PI: PI$4 } = Math;
|
|
49
49
|
const MathHelper = {
|
|
50
50
|
within(value, min, max) {
|
|
51
|
+
if (typeof min === 'object')
|
|
52
|
+
max = min.max, min = min.min;
|
|
51
53
|
if (min !== undefined && value < min)
|
|
52
54
|
value = min;
|
|
53
55
|
if (max !== undefined && value > max)
|
|
@@ -109,6 +111,19 @@ const MathHelper = {
|
|
|
109
111
|
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
110
112
|
num = round(num * a) / a;
|
|
111
113
|
return num === -0 ? 0 : num;
|
|
114
|
+
},
|
|
115
|
+
getScaleData(scale, size, originSize, scaleData) {
|
|
116
|
+
if (!scaleData)
|
|
117
|
+
scaleData = {};
|
|
118
|
+
if (size) {
|
|
119
|
+
scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
|
|
120
|
+
scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
|
|
121
|
+
}
|
|
122
|
+
else if (scale) {
|
|
123
|
+
scaleData.scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
124
|
+
scaleData.scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
125
|
+
}
|
|
126
|
+
return scaleData;
|
|
112
127
|
}
|
|
113
128
|
};
|
|
114
129
|
const OneRadian = PI$4 / 180;
|
|
@@ -150,10 +165,10 @@ const MatrixHelper = {
|
|
|
150
165
|
t.e += x;
|
|
151
166
|
t.f += y;
|
|
152
167
|
},
|
|
153
|
-
translateInner(t, x, y,
|
|
168
|
+
translateInner(t, x, y, hasOrigin) {
|
|
154
169
|
t.e += t.a * x + t.c * y;
|
|
155
170
|
t.f += t.b * x + t.d * y;
|
|
156
|
-
if (
|
|
171
|
+
if (hasOrigin)
|
|
157
172
|
t.e -= x, t.f -= y;
|
|
158
173
|
},
|
|
159
174
|
scale(t, scaleX, scaleY = scaleX) {
|
|
@@ -312,7 +327,7 @@ const MatrixHelper = {
|
|
|
312
327
|
to.y -= (f * a - e * b) * s;
|
|
313
328
|
}
|
|
314
329
|
},
|
|
315
|
-
setLayout(t, layout, origin, bcChanged) {
|
|
330
|
+
setLayout(t, layout, origin, around, bcChanged) {
|
|
316
331
|
const { x, y, scaleX, scaleY } = layout;
|
|
317
332
|
if (bcChanged === undefined)
|
|
318
333
|
bcChanged = layout.rotation || layout.skewX || layout.skewY;
|
|
@@ -344,10 +359,10 @@ const MatrixHelper = {
|
|
|
344
359
|
}
|
|
345
360
|
t.e = x;
|
|
346
361
|
t.f = y;
|
|
347
|
-
if (origin)
|
|
348
|
-
M$6.translateInner(t, -origin.x, -origin.y,
|
|
362
|
+
if (origin = origin || around)
|
|
363
|
+
M$6.translateInner(t, -origin.x, -origin.y, !around);
|
|
349
364
|
},
|
|
350
|
-
getLayout(t, origin, firstSkewY) {
|
|
365
|
+
getLayout(t, origin, around, firstSkewY) {
|
|
351
366
|
const { a, b, c, d, e, f } = t;
|
|
352
367
|
let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
|
|
353
368
|
if (b || c) {
|
|
@@ -376,9 +391,11 @@ const MatrixHelper = {
|
|
|
376
391
|
scaleY = d;
|
|
377
392
|
rotation = skewX = skewY = 0;
|
|
378
393
|
}
|
|
379
|
-
if (origin) {
|
|
394
|
+
if (origin = around || origin) {
|
|
380
395
|
x += origin.x * a + origin.y * c;
|
|
381
396
|
y += origin.x * b + origin.y * d;
|
|
397
|
+
if (!around)
|
|
398
|
+
x -= origin.x, y -= origin.y;
|
|
382
399
|
}
|
|
383
400
|
return { x, y, scaleX, scaleY, rotation, skewX, skewY };
|
|
384
401
|
},
|
|
@@ -405,7 +422,7 @@ const MatrixHelper = {
|
|
|
405
422
|
};
|
|
406
423
|
const M$6 = MatrixHelper;
|
|
407
424
|
|
|
408
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
425
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
409
426
|
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
410
427
|
const PointHelper = {
|
|
411
428
|
defaultPoint: getPointData(),
|
|
@@ -461,7 +478,7 @@ const PointHelper = {
|
|
|
461
478
|
tempToOuterOf(t, matrix) {
|
|
462
479
|
const { tempPoint: temp } = P$5;
|
|
463
480
|
copy$a(temp, t);
|
|
464
|
-
toOuterPoint$
|
|
481
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
465
482
|
return temp;
|
|
466
483
|
},
|
|
467
484
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -480,7 +497,7 @@ const PointHelper = {
|
|
|
480
497
|
toInnerPoint$2(matrix, t, to);
|
|
481
498
|
},
|
|
482
499
|
toOuterOf(t, matrix, to) {
|
|
483
|
-
toOuterPoint$
|
|
500
|
+
toOuterPoint$3(matrix, t, to);
|
|
484
501
|
},
|
|
485
502
|
getCenter(t, to) {
|
|
486
503
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -706,12 +723,12 @@ class Matrix {
|
|
|
706
723
|
toInnerPoint(outer, to, distance) {
|
|
707
724
|
MatrixHelper.toInnerPoint(this, outer, to, distance);
|
|
708
725
|
}
|
|
709
|
-
setLayout(data, origin) {
|
|
710
|
-
MatrixHelper.setLayout(this, data, origin);
|
|
726
|
+
setLayout(data, origin, around) {
|
|
727
|
+
MatrixHelper.setLayout(this, data, origin, around);
|
|
711
728
|
return this;
|
|
712
729
|
}
|
|
713
|
-
getLayout(origin, firstSkewY) {
|
|
714
|
-
return MatrixHelper.getLayout(this, origin, firstSkewY);
|
|
730
|
+
getLayout(origin, around, firstSkewY) {
|
|
731
|
+
return MatrixHelper.getLayout(this, origin, around, firstSkewY);
|
|
715
732
|
}
|
|
716
733
|
withScale(scaleX, scaleY) {
|
|
717
734
|
return MatrixHelper.withScale(this, scaleX, scaleY);
|
|
@@ -760,7 +777,7 @@ const TwoPointBoundsHelper = {
|
|
|
760
777
|
const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
|
|
761
778
|
|
|
762
779
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
|
|
763
|
-
const { toOuterPoint: toOuterPoint$
|
|
780
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
764
781
|
const { float, fourNumber } = MathHelper;
|
|
765
782
|
const { floor, ceil: ceil$2 } = Math;
|
|
766
783
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
@@ -780,17 +797,24 @@ const BoundsHelper = {
|
|
|
780
797
|
t.width = bounds.width;
|
|
781
798
|
t.height = bounds.height;
|
|
782
799
|
},
|
|
783
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
800
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
801
|
+
const { x, y, width, height } = bounds;
|
|
784
802
|
if (spread instanceof Array) {
|
|
785
803
|
const four = fourNumber(spread);
|
|
786
804
|
isShrink
|
|
787
|
-
? B.set(t,
|
|
788
|
-
: B.set(t,
|
|
805
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
806
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
789
807
|
}
|
|
790
808
|
else {
|
|
791
809
|
if (isShrink)
|
|
792
810
|
spread = -spread;
|
|
793
|
-
B.set(t,
|
|
811
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
812
|
+
}
|
|
813
|
+
if (side) {
|
|
814
|
+
if (side === 'width')
|
|
815
|
+
t.y = y, t.height = height;
|
|
816
|
+
else
|
|
817
|
+
t.x = x, t.width = width;
|
|
794
818
|
}
|
|
795
819
|
},
|
|
796
820
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -867,16 +891,16 @@ const BoundsHelper = {
|
|
|
867
891
|
else {
|
|
868
892
|
point.x = t.x;
|
|
869
893
|
point.y = t.y;
|
|
870
|
-
toOuterPoint$
|
|
894
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
871
895
|
setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
872
896
|
point.x = t.x + t.width;
|
|
873
|
-
toOuterPoint$
|
|
897
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
874
898
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
875
899
|
point.y = t.y + t.height;
|
|
876
|
-
toOuterPoint$
|
|
900
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
877
901
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
878
902
|
point.x = t.x;
|
|
879
|
-
toOuterPoint$
|
|
903
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
880
904
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
881
905
|
toBounds$4(tempPointBounds$1, to);
|
|
882
906
|
}
|
|
@@ -890,16 +914,16 @@ const BoundsHelper = {
|
|
|
890
914
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
891
915
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
892
916
|
},
|
|
893
|
-
getSpread(t, spread) {
|
|
917
|
+
getSpread(t, spread, side) {
|
|
894
918
|
const n = {};
|
|
895
|
-
B.copyAndSpread(n, t, spread);
|
|
919
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
896
920
|
return n;
|
|
897
921
|
},
|
|
898
|
-
spread(t, spread) {
|
|
899
|
-
B.copyAndSpread(t, t, spread);
|
|
922
|
+
spread(t, spread, side) {
|
|
923
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
900
924
|
},
|
|
901
|
-
shrink(t, shrink) {
|
|
902
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
925
|
+
shrink(t, shrink, side) {
|
|
926
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
903
927
|
},
|
|
904
928
|
ceil(t) {
|
|
905
929
|
const { x, y } = t;
|
|
@@ -1082,12 +1106,12 @@ class Bounds {
|
|
|
1082
1106
|
getFitMatrix(put, baseScale) {
|
|
1083
1107
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1084
1108
|
}
|
|
1085
|
-
spread(fourNumber) {
|
|
1086
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1109
|
+
spread(fourNumber, side) {
|
|
1110
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1087
1111
|
return this;
|
|
1088
1112
|
}
|
|
1089
|
-
shrink(fourNumber) {
|
|
1090
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1113
|
+
shrink(fourNumber, side) {
|
|
1114
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1091
1115
|
return this;
|
|
1092
1116
|
}
|
|
1093
1117
|
ceil() {
|
|
@@ -1999,7 +2023,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
1999
2023
|
DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
|
|
2000
2024
|
this.size.pixelRatio || (this.size.pixelRatio = 1);
|
|
2001
2025
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2002
|
-
if (!this.unreal) {
|
|
2026
|
+
if (this.context && !this.unreal) {
|
|
2003
2027
|
this.updateViewSize();
|
|
2004
2028
|
this.smooth = this.config.smooth;
|
|
2005
2029
|
}
|
|
@@ -2172,7 +2196,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2172
2196
|
this.manager ? this.manager.recycle(this) : this.destroy();
|
|
2173
2197
|
}
|
|
2174
2198
|
}
|
|
2175
|
-
updateRender() { }
|
|
2199
|
+
updateRender(_bounds) { }
|
|
2176
2200
|
unrealCanvas() { }
|
|
2177
2201
|
destroy() {
|
|
2178
2202
|
this.manager = this.view = this.parentView = null;
|
|
@@ -2904,60 +2928,75 @@ class PathCreator {
|
|
|
2904
2928
|
}
|
|
2905
2929
|
beginPath() {
|
|
2906
2930
|
beginPath(this.__path);
|
|
2931
|
+
this.paint();
|
|
2907
2932
|
return this;
|
|
2908
2933
|
}
|
|
2909
2934
|
moveTo(x, y) {
|
|
2910
2935
|
moveTo$4(this.__path, x, y);
|
|
2936
|
+
this.paint();
|
|
2911
2937
|
return this;
|
|
2912
2938
|
}
|
|
2913
2939
|
lineTo(x, y) {
|
|
2914
2940
|
lineTo$3(this.__path, x, y);
|
|
2941
|
+
this.paint();
|
|
2915
2942
|
return this;
|
|
2916
2943
|
}
|
|
2917
2944
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2918
2945
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2946
|
+
this.paint();
|
|
2919
2947
|
return this;
|
|
2920
2948
|
}
|
|
2921
2949
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2922
2950
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2951
|
+
this.paint();
|
|
2923
2952
|
return this;
|
|
2924
2953
|
}
|
|
2925
2954
|
closePath() {
|
|
2926
2955
|
closePath$3(this.__path);
|
|
2956
|
+
this.paint();
|
|
2927
2957
|
return this;
|
|
2928
2958
|
}
|
|
2929
2959
|
rect(x, y, width, height) {
|
|
2930
2960
|
rect$1(this.__path, x, y, width, height);
|
|
2961
|
+
this.paint();
|
|
2931
2962
|
return this;
|
|
2932
2963
|
}
|
|
2933
2964
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2934
2965
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2966
|
+
this.paint();
|
|
2935
2967
|
return this;
|
|
2936
2968
|
}
|
|
2937
2969
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2938
2970
|
ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2971
|
+
this.paint();
|
|
2939
2972
|
return this;
|
|
2940
2973
|
}
|
|
2941
2974
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2942
2975
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2976
|
+
this.paint();
|
|
2943
2977
|
return this;
|
|
2944
2978
|
}
|
|
2945
2979
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2946
2980
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2981
|
+
this.paint();
|
|
2947
2982
|
return this;
|
|
2948
2983
|
}
|
|
2949
2984
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2950
2985
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2986
|
+
this.paint();
|
|
2951
2987
|
return this;
|
|
2952
2988
|
}
|
|
2953
2989
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2954
2990
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2991
|
+
this.paint();
|
|
2955
2992
|
return this;
|
|
2956
2993
|
}
|
|
2957
2994
|
drawPoints(points, curve, close) {
|
|
2958
2995
|
drawPoints$2(this.__path, points, curve, close);
|
|
2996
|
+
this.paint();
|
|
2959
2997
|
return this;
|
|
2960
2998
|
}
|
|
2999
|
+
paint() { }
|
|
2961
3000
|
}
|
|
2962
3001
|
|
|
2963
3002
|
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;
|
|
@@ -3979,7 +4018,7 @@ function registerUIEvent() {
|
|
|
3979
4018
|
};
|
|
3980
4019
|
}
|
|
3981
4020
|
|
|
3982
|
-
const { copy: copy$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4021
|
+
const { copy: copy$6, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3983
4022
|
const matrix = {};
|
|
3984
4023
|
const LeafHelper = {
|
|
3985
4024
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4044,10 +4083,9 @@ const LeafHelper = {
|
|
|
4044
4083
|
}
|
|
4045
4084
|
return true;
|
|
4046
4085
|
},
|
|
4047
|
-
moveWorld(t, x, y = 0) {
|
|
4086
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4048
4087
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4049
|
-
|
|
4050
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4088
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4051
4089
|
L.moveLocal(t, local.x, local.y);
|
|
4052
4090
|
},
|
|
4053
4091
|
moveLocal(t, x, y = 0) {
|
|
@@ -4066,8 +4104,13 @@ const LeafHelper = {
|
|
|
4066
4104
|
zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
|
|
4067
4105
|
copy$6(matrix, t.__localMatrix);
|
|
4068
4106
|
scaleOfOuter$2(matrix, origin, scaleX, scaleY);
|
|
4069
|
-
|
|
4070
|
-
|
|
4107
|
+
if (t.origin || t.around) {
|
|
4108
|
+
L.setTransform(t, matrix, resize);
|
|
4109
|
+
}
|
|
4110
|
+
else {
|
|
4111
|
+
moveByMatrix(t, matrix);
|
|
4112
|
+
t.scaleResize(scaleX, scaleY, resize !== true);
|
|
4113
|
+
}
|
|
4071
4114
|
},
|
|
4072
4115
|
rotateOfWorld(t, origin, angle) {
|
|
4073
4116
|
L.rotateOfLocal(t, getTempLocal(t, origin), angle);
|
|
@@ -4075,8 +4118,13 @@ const LeafHelper = {
|
|
|
4075
4118
|
rotateOfLocal(t, origin, angle) {
|
|
4076
4119
|
copy$6(matrix, t.__localMatrix);
|
|
4077
4120
|
rotateOfOuter$2(matrix, origin, angle);
|
|
4078
|
-
|
|
4079
|
-
|
|
4121
|
+
if (t.origin || t.around) {
|
|
4122
|
+
L.setTransform(t, matrix);
|
|
4123
|
+
}
|
|
4124
|
+
else {
|
|
4125
|
+
moveByMatrix(t, matrix);
|
|
4126
|
+
t.rotation = MathHelper.formatRotation(t.rotation + angle);
|
|
4127
|
+
}
|
|
4080
4128
|
},
|
|
4081
4129
|
skewOfWorld(t, origin, skewX, skewY, resize) {
|
|
4082
4130
|
L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
|
|
@@ -4099,7 +4147,7 @@ const LeafHelper = {
|
|
|
4099
4147
|
L.setTransform(t, matrix, resize);
|
|
4100
4148
|
},
|
|
4101
4149
|
setTransform(t, transform, resize) {
|
|
4102
|
-
const layout = getLayout(transform);
|
|
4150
|
+
const layout = getLayout(transform, t.origin && L.getInnerOrigin(t, t.origin), t.around && L.getInnerOrigin(t, t.around));
|
|
4103
4151
|
if (resize) {
|
|
4104
4152
|
const scaleX = layout.scaleX / t.scaleX;
|
|
4105
4153
|
const scaleY = layout.scaleY / t.scaleY;
|
|
@@ -4112,13 +4160,19 @@ const LeafHelper = {
|
|
|
4112
4160
|
t.set(layout);
|
|
4113
4161
|
}
|
|
4114
4162
|
},
|
|
4163
|
+
getFlipTransform(t, axis) {
|
|
4164
|
+
const m = getMatrixData();
|
|
4165
|
+
const sign = axis === 'x' ? 1 : -1;
|
|
4166
|
+
scaleOfOuter$2(m, L.getLocalOrigin(t, 'center'), -1 * sign, 1 * sign);
|
|
4167
|
+
return m;
|
|
4168
|
+
},
|
|
4115
4169
|
getLocalOrigin(t, origin) {
|
|
4116
4170
|
return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
|
|
4117
4171
|
},
|
|
4118
4172
|
getInnerOrigin(t, origin) {
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
return
|
|
4173
|
+
const innerOrigin = {};
|
|
4174
|
+
AroundHelper.toPoint(origin, t.boxBounds, innerOrigin);
|
|
4175
|
+
return innerOrigin;
|
|
4122
4176
|
},
|
|
4123
4177
|
getRelativeWorld(t, relative, temp) {
|
|
4124
4178
|
copy$6(matrix, t.worldTransform);
|
|
@@ -4545,7 +4599,10 @@ const LeafEventer = {
|
|
|
4545
4599
|
on(type, listener, options) {
|
|
4546
4600
|
let capture, once;
|
|
4547
4601
|
if (options) {
|
|
4548
|
-
if (
|
|
4602
|
+
if (options === 'once') {
|
|
4603
|
+
once = true;
|
|
4604
|
+
}
|
|
4605
|
+
else if (typeof options === 'boolean') {
|
|
4549
4606
|
capture = options;
|
|
4550
4607
|
}
|
|
4551
4608
|
else {
|
|
@@ -4576,7 +4633,7 @@ const LeafEventer = {
|
|
|
4576
4633
|
if (listener) {
|
|
4577
4634
|
let capture;
|
|
4578
4635
|
if (options)
|
|
4579
|
-
capture = typeof options === 'boolean' ? options : options.capture;
|
|
4636
|
+
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4580
4637
|
let events, index;
|
|
4581
4638
|
const map = __getListenerMap(this, capture);
|
|
4582
4639
|
typeList.forEach(type => {
|
|
@@ -4878,7 +4935,7 @@ const LeafMatrix = {
|
|
|
4878
4935
|
const layout = this.__layout, local = this.__local, data = this.__;
|
|
4879
4936
|
if (layout.affectScaleOrRotation) {
|
|
4880
4937
|
if (layout.scaleChanged || layout.rotationChanged) {
|
|
4881
|
-
setLayout(local, data, null, layout.affectRotation);
|
|
4938
|
+
setLayout(local, data, null, null, layout.affectRotation);
|
|
4882
4939
|
layout.scaleChanged = layout.rotationChanged = false;
|
|
4883
4940
|
}
|
|
4884
4941
|
}
|
|
@@ -4886,7 +4943,7 @@ const LeafMatrix = {
|
|
|
4886
4943
|
local.f = data.y + data.offsetY;
|
|
4887
4944
|
if (data.around || data.origin) {
|
|
4888
4945
|
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
|
|
4889
|
-
translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.
|
|
4946
|
+
translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
|
|
4890
4947
|
}
|
|
4891
4948
|
}
|
|
4892
4949
|
this.__layout.matrixChanged = false;
|
|
@@ -4895,7 +4952,7 @@ const LeafMatrix = {
|
|
|
4895
4952
|
|
|
4896
4953
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
4897
4954
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4898
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
4955
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$4 } = BoundsHelper;
|
|
4899
4956
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4900
4957
|
const LeafBounds = {
|
|
4901
4958
|
__updateWorldBounds() {
|
|
@@ -4996,7 +5053,7 @@ const LeafBounds = {
|
|
|
4996
5053
|
updateAllMatrix$2(this);
|
|
4997
5054
|
updateBounds$1(this, this);
|
|
4998
5055
|
if (this.__.__autoSide)
|
|
4999
|
-
this.__updateBoxBounds();
|
|
5056
|
+
this.__updateBoxBounds(true);
|
|
5000
5057
|
}
|
|
5001
5058
|
else {
|
|
5002
5059
|
updateAllMatrix$2(this);
|
|
@@ -5014,11 +5071,11 @@ const LeafBounds = {
|
|
|
5014
5071
|
},
|
|
5015
5072
|
__updateStrokeBounds() {
|
|
5016
5073
|
const layout = this.__layout;
|
|
5017
|
-
copyAndSpread$
|
|
5074
|
+
copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5018
5075
|
},
|
|
5019
5076
|
__updateRenderBounds() {
|
|
5020
5077
|
const layout = this.__layout;
|
|
5021
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5078
|
+
layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$4(layout.renderBounds, layout.strokeBounds);
|
|
5022
5079
|
}
|
|
5023
5080
|
};
|
|
5024
5081
|
|
|
@@ -5115,7 +5172,7 @@ const { LEAF, create } = IncrementId;
|
|
|
5115
5172
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5116
5173
|
const { toOuterOf } = BoundsHelper;
|
|
5117
5174
|
const { copy: copy$3 } = PointHelper;
|
|
5118
|
-
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5175
|
+
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5119
5176
|
let Leaf = class Leaf {
|
|
5120
5177
|
get tag() { return this.__tag; }
|
|
5121
5178
|
set tag(_value) { }
|
|
@@ -5141,6 +5198,8 @@ let Leaf = class Leaf {
|
|
|
5141
5198
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5142
5199
|
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5143
5200
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5201
|
+
set event(map) { let event; for (let key in map)
|
|
5202
|
+
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
|
|
5144
5203
|
constructor(data) {
|
|
5145
5204
|
this.innerId = create(LEAF);
|
|
5146
5205
|
this.reset(data);
|
|
@@ -5376,6 +5435,9 @@ let Leaf = class Leaf {
|
|
|
5376
5435
|
move(x, y) {
|
|
5377
5436
|
moveLocal(this, x, y);
|
|
5378
5437
|
}
|
|
5438
|
+
moveInner(x, y) {
|
|
5439
|
+
moveWorld(this, x, y, true);
|
|
5440
|
+
}
|
|
5379
5441
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5380
5442
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5381
5443
|
}
|
|
@@ -5400,6 +5462,9 @@ let Leaf = class Leaf {
|
|
|
5400
5462
|
skewOfWorld(worldOrigin, skewX, skewY, resize) {
|
|
5401
5463
|
skewOfWorld(this, worldOrigin, skewX, skewY, resize);
|
|
5402
5464
|
}
|
|
5465
|
+
flip(axis) {
|
|
5466
|
+
transform(this, getFlipTransform(this, axis));
|
|
5467
|
+
}
|
|
5403
5468
|
scaleResize(scaleX, scaleY = scaleX, _noResize) {
|
|
5404
5469
|
this.scaleX *= scaleX;
|
|
5405
5470
|
this.scaleY *= scaleY;
|
|
@@ -5757,7 +5822,7 @@ class LeafLevelList {
|
|
|
5757
5822
|
}
|
|
5758
5823
|
}
|
|
5759
5824
|
|
|
5760
|
-
const version = "1.0.
|
|
5825
|
+
const version = "1.0.1";
|
|
5761
5826
|
const inviteCode = {};
|
|
5762
5827
|
|
|
5763
5828
|
const debug$5 = Debug.get('LeaferCanvas');
|
|
@@ -5781,7 +5846,8 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5781
5846
|
}
|
|
5782
5847
|
}
|
|
5783
5848
|
init() {
|
|
5784
|
-
const {
|
|
5849
|
+
const { config } = this;
|
|
5850
|
+
const view = config.view || config.canvas;
|
|
5785
5851
|
view ? this.__createViewFrom(view) : this.__createView();
|
|
5786
5852
|
const { style } = this.view;
|
|
5787
5853
|
style.display || (style.display = 'block');
|
|
@@ -5796,7 +5862,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5796
5862
|
}
|
|
5797
5863
|
this.__createContext();
|
|
5798
5864
|
if (!this.autoLayout)
|
|
5799
|
-
this.resize(
|
|
5865
|
+
this.resize(config);
|
|
5800
5866
|
}
|
|
5801
5867
|
set backgroundColor(color) { this.view.style.backgroundColor = color; }
|
|
5802
5868
|
get backgroundColor() { return this.view.style.backgroundColor; }
|
|
@@ -5852,26 +5918,37 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5852
5918
|
this.clientBounds = this.view.getBoundingClientRect();
|
|
5853
5919
|
}
|
|
5854
5920
|
startAutoLayout(autoBounds, listener) {
|
|
5855
|
-
this.autoBounds = autoBounds;
|
|
5856
5921
|
this.resizeListener = listener;
|
|
5857
|
-
|
|
5858
|
-
this.
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
this.
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
this.
|
|
5866
|
-
|
|
5922
|
+
if (autoBounds) {
|
|
5923
|
+
this.autoBounds = autoBounds;
|
|
5924
|
+
try {
|
|
5925
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
5926
|
+
this.updateClientBounds();
|
|
5927
|
+
for (const entry of entries)
|
|
5928
|
+
this.checkAutoBounds(entry.contentRect);
|
|
5929
|
+
});
|
|
5930
|
+
const parent = this.parentView;
|
|
5931
|
+
if (parent) {
|
|
5932
|
+
this.resizeObserver.observe(parent);
|
|
5933
|
+
this.checkAutoBounds(parent.getBoundingClientRect());
|
|
5934
|
+
}
|
|
5935
|
+
else {
|
|
5936
|
+
this.checkAutoBounds(this.view);
|
|
5937
|
+
debug$5.warn('no parent');
|
|
5938
|
+
}
|
|
5867
5939
|
}
|
|
5868
|
-
|
|
5869
|
-
this.
|
|
5870
|
-
debug$5.warn('no parent');
|
|
5940
|
+
catch (_a) {
|
|
5941
|
+
this.imitateResizeObserver();
|
|
5871
5942
|
}
|
|
5872
5943
|
}
|
|
5873
|
-
|
|
5874
|
-
|
|
5944
|
+
else {
|
|
5945
|
+
window.addEventListener('resize', () => {
|
|
5946
|
+
const pixelRatio = Platform.devicePixelRatio;
|
|
5947
|
+
if (this.pixelRatio !== pixelRatio) {
|
|
5948
|
+
const { width, height } = this;
|
|
5949
|
+
this.emitResize({ width, height, pixelRatio });
|
|
5950
|
+
}
|
|
5951
|
+
});
|
|
5875
5952
|
}
|
|
5876
5953
|
}
|
|
5877
5954
|
imitateResizeObserver() {
|
|
@@ -5884,17 +5961,12 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5884
5961
|
checkAutoBounds(parentSize) {
|
|
5885
5962
|
const view = this.view;
|
|
5886
5963
|
const { x, y, width, height } = this.autoBounds.getBoundsFrom(parentSize);
|
|
5887
|
-
|
|
5964
|
+
const size = { width, height, pixelRatio: Platform.devicePixelRatio };
|
|
5965
|
+
if (!this.isSameSize(size)) {
|
|
5888
5966
|
const { style } = view;
|
|
5889
|
-
const { pixelRatio } = this;
|
|
5890
5967
|
style.marginLeft = x + 'px';
|
|
5891
5968
|
style.marginTop = y + 'px';
|
|
5892
|
-
|
|
5893
|
-
const oldSize = {};
|
|
5894
|
-
DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
|
|
5895
|
-
this.resize(size);
|
|
5896
|
-
if (this.width !== undefined)
|
|
5897
|
-
this.resizeListener(new ResizeEvent(size, oldSize));
|
|
5969
|
+
this.emitResize(size);
|
|
5898
5970
|
}
|
|
5899
5971
|
}
|
|
5900
5972
|
stopAutoLayout() {
|
|
@@ -5905,6 +5977,13 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5905
5977
|
this.resizeObserver = null;
|
|
5906
5978
|
}
|
|
5907
5979
|
}
|
|
5980
|
+
emitResize(size) {
|
|
5981
|
+
const oldSize = {};
|
|
5982
|
+
DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
|
|
5983
|
+
this.resize(size);
|
|
5984
|
+
if (this.width !== undefined)
|
|
5985
|
+
this.resizeListener(new ResizeEvent(size, oldSize));
|
|
5986
|
+
}
|
|
5908
5987
|
unrealCanvas() {
|
|
5909
5988
|
if (!this.unreal && this.parentView) {
|
|
5910
5989
|
const view = this.view;
|
|
@@ -5985,7 +6064,7 @@ function useCanvas(_canvasType, _power) {
|
|
|
5985
6064
|
Platform.name = 'web';
|
|
5986
6065
|
Platform.isMobile = 'ontouchstart' in window;
|
|
5987
6066
|
Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
|
|
5988
|
-
Platform
|
|
6067
|
+
defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, devicePixelRatio); } });
|
|
5989
6068
|
const { userAgent } = navigator;
|
|
5990
6069
|
if (userAgent.indexOf("Firefox") > -1) {
|
|
5991
6070
|
Platform.conicGradientRotate90 = true;
|
|
@@ -6482,14 +6561,14 @@ class Renderer {
|
|
|
6482
6561
|
if (Debug.showRepaint)
|
|
6483
6562
|
this.canvas.strokeWorld(bounds, 'red');
|
|
6484
6563
|
this.target.__render(this.canvas, options);
|
|
6485
|
-
this.renderBounds = realBounds || bounds;
|
|
6564
|
+
this.renderBounds = realBounds = realBounds || bounds;
|
|
6486
6565
|
this.renderOptions = options;
|
|
6487
|
-
this.totalBounds.isEmpty() ? this.totalBounds =
|
|
6566
|
+
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
6488
6567
|
if (Debug.showHitView)
|
|
6489
6568
|
this.renderHitView(options);
|
|
6490
6569
|
if (Debug.showBoundsView)
|
|
6491
6570
|
this.renderBoundsView(options);
|
|
6492
|
-
this.canvas.updateRender();
|
|
6571
|
+
this.canvas.updateRender(realBounds);
|
|
6493
6572
|
}
|
|
6494
6573
|
renderHitView(_options) { }
|
|
6495
6574
|
renderBoundsView(_options) { }
|
|
@@ -6798,6 +6877,11 @@ class BoxData extends GroupData {
|
|
|
6798
6877
|
}
|
|
6799
6878
|
|
|
6800
6879
|
class LeaferData extends GroupData {
|
|
6880
|
+
__getInputData() {
|
|
6881
|
+
const data = super.__getInputData();
|
|
6882
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
6883
|
+
return data;
|
|
6884
|
+
}
|
|
6801
6885
|
}
|
|
6802
6886
|
|
|
6803
6887
|
class FrameData extends BoxData {
|
|
@@ -6875,6 +6959,11 @@ class ImageData extends RectData {
|
|
|
6875
6959
|
}
|
|
6876
6960
|
|
|
6877
6961
|
class CanvasData extends RectData {
|
|
6962
|
+
__getInputData() {
|
|
6963
|
+
const data = super.__getInputData();
|
|
6964
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
6965
|
+
return data;
|
|
6966
|
+
}
|
|
6878
6967
|
}
|
|
6879
6968
|
|
|
6880
6969
|
const UIBounds = {
|
|
@@ -7540,7 +7629,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7540
7629
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7541
7630
|
if (this.isApp)
|
|
7542
7631
|
this.__setApp();
|
|
7543
|
-
this.__checkAutoLayout(config);
|
|
7632
|
+
this.__checkAutoLayout(config, parentApp);
|
|
7544
7633
|
this.view = canvas.view;
|
|
7545
7634
|
if (parentApp) {
|
|
7546
7635
|
this.__bindApp(parentApp);
|
|
@@ -7641,9 +7730,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7641
7730
|
this.leafer = leafer;
|
|
7642
7731
|
this.__level = 1;
|
|
7643
7732
|
}
|
|
7644
|
-
__checkAutoLayout(config) {
|
|
7645
|
-
if (!
|
|
7646
|
-
|
|
7733
|
+
__checkAutoLayout(config, parentApp) {
|
|
7734
|
+
if (!parentApp) {
|
|
7735
|
+
if (!config.width || !config.height)
|
|
7736
|
+
this.autoLayout = new AutoBounds(config);
|
|
7647
7737
|
this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
|
|
7648
7738
|
}
|
|
7649
7739
|
}
|
|
@@ -7778,12 +7868,21 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7778
7868
|
list.push(item);
|
|
7779
7869
|
}
|
|
7780
7870
|
}
|
|
7781
|
-
zoom(_zoomType, _padding, _fixedScale) {
|
|
7871
|
+
zoom(_zoomType, _padding, _fixedScale) {
|
|
7872
|
+
return debug$1.error('need @leafer-in/view');
|
|
7873
|
+
}
|
|
7782
7874
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
7783
7875
|
getValidScale(changeScale) { return changeScale; }
|
|
7784
7876
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
7785
7877
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
7786
7878
|
}
|
|
7879
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
7880
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
7881
|
+
}
|
|
7882
|
+
updateClientBounds() {
|
|
7883
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
7884
|
+
}
|
|
7885
|
+
receiveEvent(_event) { }
|
|
7787
7886
|
__checkUpdateLayout() {
|
|
7788
7887
|
this.__layout.update();
|
|
7789
7888
|
}
|
|
@@ -7867,7 +7966,7 @@ Rect = __decorate([
|
|
|
7867
7966
|
const rect = Rect.prototype;
|
|
7868
7967
|
const group = Group.prototype;
|
|
7869
7968
|
const childrenRenderBounds = {};
|
|
7870
|
-
const { copy: copy$2, add, includes: includes$1 } = BoundsHelper;
|
|
7969
|
+
const { copy: copy$2, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
7871
7970
|
let Box = class Box extends Group {
|
|
7872
7971
|
get __tag() { return 'Box'; }
|
|
7873
7972
|
get isBranchLeaf() { return true; }
|
|
@@ -7881,20 +7980,23 @@ let Box = class Box extends Group {
|
|
|
7881
7980
|
return this.__updateRectRenderSpread() || -1;
|
|
7882
7981
|
}
|
|
7883
7982
|
__updateRectBoxBounds() { }
|
|
7884
|
-
__updateBoxBounds() {
|
|
7983
|
+
__updateBoxBounds(secondLayout) {
|
|
7885
7984
|
const data = this.__;
|
|
7886
7985
|
if (this.children.length) {
|
|
7887
7986
|
if (data.__autoSide) {
|
|
7888
7987
|
if (this.leafer && this.leafer.ready)
|
|
7889
7988
|
this.leafer.layouter.addExtra(this);
|
|
7890
7989
|
super.__updateBoxBounds();
|
|
7990
|
+
const { boxBounds } = this.__layout;
|
|
7891
7991
|
if (!data.__autoSize) {
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
7992
|
+
if (data.__autoWidth)
|
|
7993
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
7994
|
+
else
|
|
7995
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
7897
7996
|
}
|
|
7997
|
+
if (secondLayout && data.flow && data.padding)
|
|
7998
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
7999
|
+
this.__updateNaturalSize();
|
|
7898
8000
|
}
|
|
7899
8001
|
else {
|
|
7900
8002
|
this.__updateRectBoxBounds();
|
|
@@ -7914,13 +8016,13 @@ let Box = class Box extends Group {
|
|
|
7914
8016
|
super.__updateRenderBounds();
|
|
7915
8017
|
copy$2(childrenRenderBounds, renderBounds);
|
|
7916
8018
|
this.__updateRectRenderBounds();
|
|
7917
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
8019
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
7918
8020
|
}
|
|
7919
8021
|
else {
|
|
7920
8022
|
this.__updateRectRenderBounds();
|
|
7921
8023
|
}
|
|
7922
8024
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
7923
|
-
if (
|
|
8025
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
7924
8026
|
add(renderBounds, childrenRenderBounds);
|
|
7925
8027
|
}
|
|
7926
8028
|
__updateRectRenderBounds() { }
|
|
@@ -8254,14 +8356,26 @@ __decorate([
|
|
|
8254
8356
|
Image$1 = __decorate([
|
|
8255
8357
|
registerUI()
|
|
8256
8358
|
], Image$1);
|
|
8359
|
+
const MyImage = Image$1;
|
|
8257
8360
|
|
|
8258
8361
|
let Canvas = class Canvas extends Rect {
|
|
8259
8362
|
get __tag() { return 'Canvas'; }
|
|
8363
|
+
get ready() { return !this.url; }
|
|
8260
8364
|
constructor(data) {
|
|
8261
8365
|
super(data);
|
|
8262
8366
|
this.canvas = Creator.canvas(this.__);
|
|
8263
8367
|
this.context = this.canvas.context;
|
|
8264
8368
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8369
|
+
if (data && data.url)
|
|
8370
|
+
this.drawImage(data.url);
|
|
8371
|
+
}
|
|
8372
|
+
drawImage(url) {
|
|
8373
|
+
new LeaferImage({ url }).load((image) => {
|
|
8374
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8375
|
+
this.url = undefined;
|
|
8376
|
+
this.paint();
|
|
8377
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8378
|
+
});
|
|
8265
8379
|
}
|
|
8266
8380
|
draw(ui, offset, scale, rotation) {
|
|
8267
8381
|
ui.__layout.update();
|
|
@@ -8305,8 +8419,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8305
8419
|
destroy() {
|
|
8306
8420
|
if (this.canvas) {
|
|
8307
8421
|
this.canvas.destroy();
|
|
8308
|
-
this.canvas = null;
|
|
8309
|
-
this.context = null;
|
|
8422
|
+
this.canvas = this.context = null;
|
|
8310
8423
|
}
|
|
8311
8424
|
super.destroy();
|
|
8312
8425
|
}
|
|
@@ -8321,7 +8434,7 @@ __decorate([
|
|
|
8321
8434
|
resizeType(100)
|
|
8322
8435
|
], Canvas.prototype, "height", void 0);
|
|
8323
8436
|
__decorate([
|
|
8324
|
-
resizeType(
|
|
8437
|
+
resizeType(1)
|
|
8325
8438
|
], Canvas.prototype, "pixelRatio", void 0);
|
|
8326
8439
|
__decorate([
|
|
8327
8440
|
resizeType(true)
|
|
@@ -8345,13 +8458,13 @@ let Text = class Text extends UI {
|
|
|
8345
8458
|
super(data);
|
|
8346
8459
|
}
|
|
8347
8460
|
__drawHitPath(canvas) {
|
|
8348
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8461
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8349
8462
|
canvas.beginPath();
|
|
8350
8463
|
if (this.__.__letterSpacing < 0) {
|
|
8351
8464
|
this.__drawPathByData(canvas);
|
|
8352
8465
|
}
|
|
8353
8466
|
else {
|
|
8354
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8467
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8355
8468
|
}
|
|
8356
8469
|
}
|
|
8357
8470
|
__drawPathByData(drawer, _data) {
|
|
@@ -8544,7 +8657,8 @@ let Pen = class Pen extends Group {
|
|
|
8544
8657
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8545
8658
|
clearPath() { return this; }
|
|
8546
8659
|
paint() {
|
|
8547
|
-
this.pathElement.
|
|
8660
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8661
|
+
this.pathElement.forceUpdate('path');
|
|
8548
8662
|
}
|
|
8549
8663
|
};
|
|
8550
8664
|
__decorate([
|
|
@@ -8554,7 +8668,7 @@ __decorate([
|
|
|
8554
8668
|
penPathType()
|
|
8555
8669
|
], Pen.prototype, "path", void 0);
|
|
8556
8670
|
Pen = __decorate([
|
|
8557
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8671
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8558
8672
|
registerUI()
|
|
8559
8673
|
], Pen);
|
|
8560
8674
|
function penPathType() {
|
|
@@ -8916,10 +9030,13 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
8916
9030
|
const { get: get$2, translate } = MatrixHelper;
|
|
8917
9031
|
const tempBox = new Bounds();
|
|
8918
9032
|
const tempPoint = {};
|
|
9033
|
+
const tempScaleData = {};
|
|
8919
9034
|
function createData(leafPaint, image, paint, box) {
|
|
8920
|
-
const { blendMode } = paint;
|
|
9035
|
+
const { blendMode, sync } = paint;
|
|
8921
9036
|
if (blendMode)
|
|
8922
9037
|
leafPaint.blendMode = blendMode;
|
|
9038
|
+
if (sync)
|
|
9039
|
+
leafPaint.sync = sync;
|
|
8923
9040
|
leafPaint.data = getPatternData(paint, box, image);
|
|
8924
9041
|
}
|
|
8925
9042
|
function getPatternData(paint, box, image) {
|
|
@@ -8939,13 +9056,10 @@ function getPatternData(paint, box, image) {
|
|
|
8939
9056
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
8940
9057
|
}
|
|
8941
9058
|
}
|
|
8942
|
-
else if (size) {
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
else if (scale) {
|
|
8947
|
-
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
8948
|
-
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
9059
|
+
else if (scale || size) {
|
|
9060
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
9061
|
+
scaleX = tempScaleData.scaleX;
|
|
9062
|
+
scaleY = tempScaleData.scaleY;
|
|
8949
9063
|
}
|
|
8950
9064
|
if (align) {
|
|
8951
9065
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -9150,7 +9264,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
9150
9264
|
const { abs } = Math;
|
|
9151
9265
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
9152
9266
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
9153
|
-
if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
|
|
9267
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
|
|
9154
9268
|
return false;
|
|
9155
9269
|
}
|
|
9156
9270
|
else {
|
|
@@ -9184,7 +9298,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
9184
9298
|
return true;
|
|
9185
9299
|
}
|
|
9186
9300
|
else {
|
|
9187
|
-
if (!paint.style || Export.running) {
|
|
9301
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
9188
9302
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
9189
9303
|
}
|
|
9190
9304
|
else {
|
|
@@ -10054,6 +10168,7 @@ const ExportModule = {
|
|
|
10054
10168
|
export(leaf, filename, options) {
|
|
10055
10169
|
this.running = true;
|
|
10056
10170
|
const fileType = FileHelper.fileType(filename);
|
|
10171
|
+
const isDownload = filename.includes('.');
|
|
10057
10172
|
options = FileHelper.getExportOptions(options);
|
|
10058
10173
|
return addTask((success) => new Promise((resolve) => {
|
|
10059
10174
|
const over = (result) => {
|
|
@@ -10063,19 +10178,13 @@ const ExportModule = {
|
|
|
10063
10178
|
};
|
|
10064
10179
|
const { toURL } = Platform;
|
|
10065
10180
|
const { download } = Platform.origin;
|
|
10066
|
-
if (
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
else if (fileType === 'json') {
|
|
10070
|
-
download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
10071
|
-
return over({ data: true });
|
|
10072
|
-
}
|
|
10073
|
-
if (filename === 'svg') {
|
|
10074
|
-
return over({ data: leaf.toSVG() });
|
|
10181
|
+
if (fileType === 'json') {
|
|
10182
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
10183
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
10075
10184
|
}
|
|
10076
|
-
|
|
10077
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
10078
|
-
return over({ data: true });
|
|
10185
|
+
if (fileType === 'svg') {
|
|
10186
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
10187
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
10079
10188
|
}
|
|
10080
10189
|
const { leafer } = leaf;
|
|
10081
10190
|
if (leafer) {
|
|
@@ -10084,14 +10193,8 @@ const ExportModule = {
|
|
|
10084
10193
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
10085
10194
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
10086
10195
|
const { slice, trim, onCanvas } = options;
|
|
10087
|
-
let scale = options.scale || 1;
|
|
10088
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
10089
10196
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
10090
10197
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
10091
|
-
if (leaf.isApp) {
|
|
10092
|
-
scale *= pixelRatio;
|
|
10093
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
10094
|
-
}
|
|
10095
10198
|
const screenshot = options.screenshot || leaf.isApp;
|
|
10096
10199
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
10097
10200
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -10125,10 +10228,21 @@ const ExportModule = {
|
|
|
10125
10228
|
}
|
|
10126
10229
|
renderBounds = leaf.getBounds('render', relative);
|
|
10127
10230
|
}
|
|
10128
|
-
const {
|
|
10231
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
10232
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
10233
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
10234
|
+
if (leaf.isApp) {
|
|
10235
|
+
scaleData.scaleX *= pixelRatio;
|
|
10236
|
+
scaleData.scaleY *= pixelRatio;
|
|
10237
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
10238
|
+
}
|
|
10239
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
10240
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
10129
10241
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
10130
|
-
|
|
10242
|
+
let sliceLeaf;
|
|
10131
10243
|
if (slice) {
|
|
10244
|
+
sliceLeaf = leaf;
|
|
10245
|
+
sliceLeaf.__worldOpacity = 0;
|
|
10132
10246
|
leaf = leafer;
|
|
10133
10247
|
renderOptions.bounds = canvas.bounds;
|
|
10134
10248
|
}
|
|
@@ -10143,6 +10257,8 @@ const ExportModule = {
|
|
|
10143
10257
|
leaf.__render(canvas, renderOptions);
|
|
10144
10258
|
}
|
|
10145
10259
|
canvas.restore();
|
|
10260
|
+
if (sliceLeaf)
|
|
10261
|
+
sliceLeaf.__updateWorldOpacity();
|
|
10146
10262
|
if (trim) {
|
|
10147
10263
|
trimBounds = getTrimBounds(canvas);
|
|
10148
10264
|
const old = canvas, { width, height } = trimBounds;
|
|
@@ -10227,4 +10343,4 @@ Object.assign(Export, ExportModule);
|
|
|
10227
10343
|
|
|
10228
10344
|
useCanvas();
|
|
10229
10345
|
|
|
10230
|
-
export { AlignHelper, AnimateEvent, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
10346
|
+
export { AlignHelper, AnimateEvent, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|