leafer-draw 1.6.2 → 1.6.3
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 +172 -172
- package/dist/web.esm.js +175 -175
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +1101 -449
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +1100 -449
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +2 -2
package/dist/web.module.js
CHANGED
|
@@ -23,8 +23,6 @@ const Platform = {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const Creator = {};
|
|
27
|
-
|
|
28
26
|
const IncrementId = {
|
|
29
27
|
RUNTIME: 'runtime',
|
|
30
28
|
LEAF: 'leaf',
|
|
@@ -150,7 +148,7 @@ function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
|
|
|
150
148
|
|
|
151
149
|
const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
|
|
152
150
|
const { float: float$1 } = MathHelper;
|
|
153
|
-
const tempPoint$
|
|
151
|
+
const tempPoint$3 = {};
|
|
154
152
|
function getWorld() {
|
|
155
153
|
return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
|
|
156
154
|
}
|
|
@@ -193,8 +191,8 @@ const MatrixHelper = {
|
|
|
193
191
|
t.d *= scaleY;
|
|
194
192
|
},
|
|
195
193
|
scaleOfOuter(t, origin, scaleX, scaleY) {
|
|
196
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
197
|
-
M$6.scaleOfInner(t, tempPoint$
|
|
194
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
195
|
+
M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
|
|
198
196
|
},
|
|
199
197
|
scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
|
|
200
198
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -212,8 +210,8 @@ const MatrixHelper = {
|
|
|
212
210
|
t.d = c * sinR + d * cosR;
|
|
213
211
|
},
|
|
214
212
|
rotateOfOuter(t, origin, rotation) {
|
|
215
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
216
|
-
M$6.rotateOfInner(t, tempPoint$
|
|
213
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
214
|
+
M$6.rotateOfInner(t, tempPoint$3, rotation);
|
|
217
215
|
},
|
|
218
216
|
rotateOfInner(t, origin, rotation) {
|
|
219
217
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -234,8 +232,8 @@ const MatrixHelper = {
|
|
|
234
232
|
}
|
|
235
233
|
},
|
|
236
234
|
skewOfOuter(t, origin, skewX, skewY) {
|
|
237
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
238
|
-
M$6.skewOfInner(t, tempPoint$
|
|
235
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
236
|
+
M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
|
|
239
237
|
},
|
|
240
238
|
skewOfInner(t, origin, skewX, skewY = 0) {
|
|
241
239
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -464,8 +462,10 @@ const PointHelper = {
|
|
|
464
462
|
t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
|
|
465
463
|
},
|
|
466
464
|
move(t, x, y) {
|
|
467
|
-
|
|
468
|
-
|
|
465
|
+
if (typeof x === 'object')
|
|
466
|
+
t.x += x.x, t.y += x.y;
|
|
467
|
+
else
|
|
468
|
+
t.x += x, t.y += y;
|
|
469
469
|
},
|
|
470
470
|
scale(t, scaleX, scaleY = scaleX) {
|
|
471
471
|
if (t.x)
|
|
@@ -490,19 +490,19 @@ const PointHelper = {
|
|
|
490
490
|
},
|
|
491
491
|
tempToInnerOf(t, matrix) {
|
|
492
492
|
const { tempPoint: temp } = P$5;
|
|
493
|
-
copy$
|
|
493
|
+
copy$b(temp, t);
|
|
494
494
|
toInnerPoint$2(matrix, temp, temp);
|
|
495
495
|
return temp;
|
|
496
496
|
},
|
|
497
497
|
tempToOuterOf(t, matrix) {
|
|
498
498
|
const { tempPoint: temp } = P$5;
|
|
499
|
-
copy$
|
|
499
|
+
copy$b(temp, t);
|
|
500
500
|
toOuterPoint$3(matrix, temp, temp);
|
|
501
501
|
return temp;
|
|
502
502
|
},
|
|
503
503
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
504
504
|
const { tempRadiusPoint: temp } = P$5;
|
|
505
|
-
copy$
|
|
505
|
+
copy$b(temp, t);
|
|
506
506
|
P$5.toInnerRadiusPointOf(t, matrix, temp);
|
|
507
507
|
return temp;
|
|
508
508
|
},
|
|
@@ -575,7 +575,7 @@ const PointHelper = {
|
|
|
575
575
|
}
|
|
576
576
|
};
|
|
577
577
|
const P$5 = PointHelper;
|
|
578
|
-
const { getDistanceFrom, copy: copy$
|
|
578
|
+
const { getDistanceFrom, copy: copy$b, getAtan2 } = P$5;
|
|
579
579
|
|
|
580
580
|
class Point {
|
|
581
581
|
constructor(x, y) {
|
|
@@ -643,7 +643,7 @@ class Point {
|
|
|
643
643
|
return this;
|
|
644
644
|
}
|
|
645
645
|
}
|
|
646
|
-
const tempPoint$
|
|
646
|
+
const tempPoint$2 = new Point();
|
|
647
647
|
|
|
648
648
|
class Matrix {
|
|
649
649
|
constructor(a, b, c, d, e, f) {
|
|
@@ -801,15 +801,87 @@ const TwoPointBoundsHelper = {
|
|
|
801
801
|
};
|
|
802
802
|
const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
|
|
803
803
|
|
|
804
|
+
var Direction4;
|
|
805
|
+
(function (Direction4) {
|
|
806
|
+
Direction4[Direction4["top"] = 0] = "top";
|
|
807
|
+
Direction4[Direction4["right"] = 1] = "right";
|
|
808
|
+
Direction4[Direction4["bottom"] = 2] = "bottom";
|
|
809
|
+
Direction4[Direction4["left"] = 3] = "left";
|
|
810
|
+
})(Direction4 || (Direction4 = {}));
|
|
811
|
+
var Direction9;
|
|
812
|
+
(function (Direction9) {
|
|
813
|
+
Direction9[Direction9["topLeft"] = 0] = "topLeft";
|
|
814
|
+
Direction9[Direction9["top"] = 1] = "top";
|
|
815
|
+
Direction9[Direction9["topRight"] = 2] = "topRight";
|
|
816
|
+
Direction9[Direction9["right"] = 3] = "right";
|
|
817
|
+
Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
|
|
818
|
+
Direction9[Direction9["bottom"] = 5] = "bottom";
|
|
819
|
+
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
820
|
+
Direction9[Direction9["left"] = 7] = "left";
|
|
821
|
+
Direction9[Direction9["center"] = 8] = "center";
|
|
822
|
+
Direction9[Direction9["top-left"] = 0] = "top-left";
|
|
823
|
+
Direction9[Direction9["top-right"] = 2] = "top-right";
|
|
824
|
+
Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
|
|
825
|
+
Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
|
|
826
|
+
})(Direction9 || (Direction9 = {}));
|
|
827
|
+
|
|
828
|
+
const directionData = [
|
|
829
|
+
{ x: 0, y: 0 },
|
|
830
|
+
{ x: 0.5, y: 0 },
|
|
831
|
+
{ x: 1, y: 0 },
|
|
832
|
+
{ x: 1, y: 0.5 },
|
|
833
|
+
{ x: 1, y: 1 },
|
|
834
|
+
{ x: 0.5, y: 1 },
|
|
835
|
+
{ x: 0, y: 1 },
|
|
836
|
+
{ x: 0, y: 0.5 },
|
|
837
|
+
{ x: 0.5, y: 0.5 }
|
|
838
|
+
];
|
|
839
|
+
directionData.forEach(item => item.type = 'percent');
|
|
840
|
+
const AroundHelper = {
|
|
841
|
+
directionData,
|
|
842
|
+
tempPoint: {},
|
|
843
|
+
get: get$4,
|
|
844
|
+
toPoint(around, box, to, onlyBoxSize, content, onlyContentSize) {
|
|
845
|
+
const point = get$4(around);
|
|
846
|
+
to.x = point.x;
|
|
847
|
+
to.y = point.y;
|
|
848
|
+
if (point.type === 'percent') {
|
|
849
|
+
to.x *= box.width;
|
|
850
|
+
to.y *= box.height;
|
|
851
|
+
if (content) {
|
|
852
|
+
if (!onlyContentSize)
|
|
853
|
+
to.x -= content.x, to.y -= content.y;
|
|
854
|
+
if (point.x)
|
|
855
|
+
to.x -= (point.x === 1) ? content.width : (point.x === 0.5 ? point.x * content.width : 0);
|
|
856
|
+
if (point.y)
|
|
857
|
+
to.y -= (point.y === 1) ? content.height : (point.y === 0.5 ? point.y * content.height : 0);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (!onlyBoxSize)
|
|
861
|
+
to.x += box.x, to.y += box.y;
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
function get$4(around) {
|
|
865
|
+
return typeof around === 'string' ? directionData[Direction9[around]] : around;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
const { toPoint: toPoint$5 } = AroundHelper;
|
|
869
|
+
const AlignHelper = {
|
|
870
|
+
toPoint(align, content, box, to, onlyBoxSize, onlyContentSize) {
|
|
871
|
+
toPoint$5(align, box, to, onlyBoxSize, content, onlyContentSize);
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
|
|
804
875
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
805
876
|
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
806
877
|
const { float, fourNumber } = MathHelper;
|
|
807
878
|
const { floor, ceil: ceil$2 } = Math;
|
|
808
879
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
809
880
|
const point = {};
|
|
810
|
-
const toPoint$
|
|
881
|
+
const toPoint$4 = {};
|
|
882
|
+
const tempBounds$2 = {};
|
|
811
883
|
const BoundsHelper = {
|
|
812
|
-
tempBounds:
|
|
884
|
+
tempBounds: tempBounds$2,
|
|
813
885
|
set(t, x = 0, y = 0, width = 0, height = 0) {
|
|
814
886
|
t.x = x;
|
|
815
887
|
t.y = y;
|
|
@@ -860,7 +932,7 @@ const BoundsHelper = {
|
|
|
860
932
|
to = t;
|
|
861
933
|
}
|
|
862
934
|
else {
|
|
863
|
-
copy$
|
|
935
|
+
copy$a(to, t);
|
|
864
936
|
}
|
|
865
937
|
if (parent) {
|
|
866
938
|
to.offsetX = -(B.maxX(parent) - t.x);
|
|
@@ -872,8 +944,8 @@ const BoundsHelper = {
|
|
|
872
944
|
}
|
|
873
945
|
B.move(to, -to.offsetX, -to.offsetY);
|
|
874
946
|
},
|
|
875
|
-
scale(t, scaleX, scaleY = scaleX) {
|
|
876
|
-
PointHelper.scale(t, scaleX, scaleY);
|
|
947
|
+
scale(t, scaleX, scaleY = scaleX, onlySize) {
|
|
948
|
+
onlySize || PointHelper.scale(t, scaleX, scaleY);
|
|
877
949
|
t.width *= scaleX;
|
|
878
950
|
t.height *= scaleY;
|
|
879
951
|
},
|
|
@@ -883,9 +955,9 @@ const BoundsHelper = {
|
|
|
883
955
|
t.height *= scaleY;
|
|
884
956
|
},
|
|
885
957
|
tempToOuterOf(t, matrix) {
|
|
886
|
-
B.copy(
|
|
887
|
-
B.toOuterOf(
|
|
888
|
-
return
|
|
958
|
+
B.copy(tempBounds$2, t);
|
|
959
|
+
B.toOuterOf(tempBounds$2, matrix);
|
|
960
|
+
return tempBounds$2;
|
|
889
961
|
},
|
|
890
962
|
getOuterOf(t, matrix) {
|
|
891
963
|
t = Object.assign({}, t);
|
|
@@ -916,17 +988,17 @@ const BoundsHelper = {
|
|
|
916
988
|
else {
|
|
917
989
|
point.x = t.x;
|
|
918
990
|
point.y = t.y;
|
|
919
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
920
|
-
setPoint$2(tempPointBounds$1, toPoint$
|
|
991
|
+
toOuterPoint$2(matrix, point, toPoint$4);
|
|
992
|
+
setPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
921
993
|
point.x = t.x + t.width;
|
|
922
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
923
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
994
|
+
toOuterPoint$2(matrix, point, toPoint$4);
|
|
995
|
+
addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
924
996
|
point.y = t.y + t.height;
|
|
925
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
926
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
997
|
+
toOuterPoint$2(matrix, point, toPoint$4);
|
|
998
|
+
addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
927
999
|
point.x = t.x;
|
|
928
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
929
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
1000
|
+
toOuterPoint$2(matrix, point, toPoint$4);
|
|
1001
|
+
addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
930
1002
|
toBounds$3(tempPointBounds$1, to);
|
|
931
1003
|
}
|
|
932
1004
|
},
|
|
@@ -936,9 +1008,21 @@ const BoundsHelper = {
|
|
|
936
1008
|
B.scale(to, 1 / matrix.a, 1 / matrix.d);
|
|
937
1009
|
},
|
|
938
1010
|
getFitMatrix(t, put, baseScale = 1) {
|
|
939
|
-
const scale = Math.min(baseScale,
|
|
1011
|
+
const scale = Math.min(baseScale, B.getFitScale(t, put));
|
|
940
1012
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
941
1013
|
},
|
|
1014
|
+
getFitScale(t, put, isCoverMode) {
|
|
1015
|
+
const sw = t.width / put.width, sh = t.height / put.height;
|
|
1016
|
+
return isCoverMode ? Math.max(sw, sh) : Math.min(sw, sh);
|
|
1017
|
+
},
|
|
1018
|
+
put(t, put, align = 'center', putScale = 1, changeSize = true, to) {
|
|
1019
|
+
to || (to = put);
|
|
1020
|
+
if (typeof putScale === 'string')
|
|
1021
|
+
putScale = B.getFitScale(t, put, putScale === 'cover');
|
|
1022
|
+
tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
|
|
1023
|
+
tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
|
|
1024
|
+
AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
|
|
1025
|
+
},
|
|
942
1026
|
getSpread(t, spread, side) {
|
|
943
1027
|
const n = {};
|
|
944
1028
|
B.copyAndSpread(n, t, spread, false, side);
|
|
@@ -1006,7 +1090,7 @@ const BoundsHelper = {
|
|
|
1006
1090
|
if (first) {
|
|
1007
1091
|
first = false;
|
|
1008
1092
|
if (!addMode)
|
|
1009
|
-
copy$
|
|
1093
|
+
copy$a(t, bounds);
|
|
1010
1094
|
}
|
|
1011
1095
|
else {
|
|
1012
1096
|
add$1(t, bounds);
|
|
@@ -1087,7 +1171,7 @@ const BoundsHelper = {
|
|
|
1087
1171
|
}
|
|
1088
1172
|
};
|
|
1089
1173
|
const B = BoundsHelper;
|
|
1090
|
-
const { add: add$1, copy: copy$
|
|
1174
|
+
const { add: add$1, copy: copy$a } = B;
|
|
1091
1175
|
|
|
1092
1176
|
class Bounds {
|
|
1093
1177
|
get minX() { return BoundsHelper.minX(this); }
|
|
@@ -1112,8 +1196,8 @@ class Bounds {
|
|
|
1112
1196
|
BoundsHelper.move(this, x, y);
|
|
1113
1197
|
return this;
|
|
1114
1198
|
}
|
|
1115
|
-
scale(scaleX, scaleY) {
|
|
1116
|
-
BoundsHelper.scale(this, scaleX, scaleY);
|
|
1199
|
+
scale(scaleX, scaleY, onlySize) {
|
|
1200
|
+
BoundsHelper.scale(this, scaleX, scaleY, onlySize);
|
|
1117
1201
|
return this;
|
|
1118
1202
|
}
|
|
1119
1203
|
scaleOf(origin, scaleX, scaleY) {
|
|
@@ -1131,6 +1215,9 @@ class Bounds {
|
|
|
1131
1215
|
getFitMatrix(put, baseScale) {
|
|
1132
1216
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1133
1217
|
}
|
|
1218
|
+
put(put, align, putScale) {
|
|
1219
|
+
BoundsHelper.put(this, put, align, putScale);
|
|
1220
|
+
}
|
|
1134
1221
|
spread(fourNumber, side) {
|
|
1135
1222
|
BoundsHelper.spread(this, fourNumber, side);
|
|
1136
1223
|
return this;
|
|
@@ -1239,79 +1326,6 @@ class AutoBounds {
|
|
|
1239
1326
|
}
|
|
1240
1327
|
}
|
|
1241
1328
|
|
|
1242
|
-
var Direction4;
|
|
1243
|
-
(function (Direction4) {
|
|
1244
|
-
Direction4[Direction4["top"] = 0] = "top";
|
|
1245
|
-
Direction4[Direction4["right"] = 1] = "right";
|
|
1246
|
-
Direction4[Direction4["bottom"] = 2] = "bottom";
|
|
1247
|
-
Direction4[Direction4["left"] = 3] = "left";
|
|
1248
|
-
})(Direction4 || (Direction4 = {}));
|
|
1249
|
-
var Direction9;
|
|
1250
|
-
(function (Direction9) {
|
|
1251
|
-
Direction9[Direction9["topLeft"] = 0] = "topLeft";
|
|
1252
|
-
Direction9[Direction9["top"] = 1] = "top";
|
|
1253
|
-
Direction9[Direction9["topRight"] = 2] = "topRight";
|
|
1254
|
-
Direction9[Direction9["right"] = 3] = "right";
|
|
1255
|
-
Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
|
|
1256
|
-
Direction9[Direction9["bottom"] = 5] = "bottom";
|
|
1257
|
-
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
1258
|
-
Direction9[Direction9["left"] = 7] = "left";
|
|
1259
|
-
Direction9[Direction9["center"] = 8] = "center";
|
|
1260
|
-
Direction9[Direction9["top-left"] = 0] = "top-left";
|
|
1261
|
-
Direction9[Direction9["top-right"] = 2] = "top-right";
|
|
1262
|
-
Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
|
|
1263
|
-
Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
|
|
1264
|
-
})(Direction9 || (Direction9 = {}));
|
|
1265
|
-
|
|
1266
|
-
const directionData = [
|
|
1267
|
-
{ x: 0, y: 0 },
|
|
1268
|
-
{ x: 0.5, y: 0 },
|
|
1269
|
-
{ x: 1, y: 0 },
|
|
1270
|
-
{ x: 1, y: 0.5 },
|
|
1271
|
-
{ x: 1, y: 1 },
|
|
1272
|
-
{ x: 0.5, y: 1 },
|
|
1273
|
-
{ x: 0, y: 1 },
|
|
1274
|
-
{ x: 0, y: 0.5 },
|
|
1275
|
-
{ x: 0.5, y: 0.5 }
|
|
1276
|
-
];
|
|
1277
|
-
directionData.forEach(item => item.type = 'percent');
|
|
1278
|
-
const AroundHelper = {
|
|
1279
|
-
directionData,
|
|
1280
|
-
tempPoint: {},
|
|
1281
|
-
get: get$4,
|
|
1282
|
-
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1283
|
-
const point = get$4(around);
|
|
1284
|
-
to.x = point.x;
|
|
1285
|
-
to.y = point.y;
|
|
1286
|
-
if (point.type === 'percent') {
|
|
1287
|
-
to.x *= bounds.width;
|
|
1288
|
-
to.y *= bounds.height;
|
|
1289
|
-
if (pointBounds) {
|
|
1290
|
-
to.x -= pointBounds.x;
|
|
1291
|
-
to.y -= pointBounds.y;
|
|
1292
|
-
if (point.x)
|
|
1293
|
-
to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
|
|
1294
|
-
if (point.y)
|
|
1295
|
-
to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
if (!onlySize) {
|
|
1299
|
-
to.x += bounds.x;
|
|
1300
|
-
to.y += bounds.y;
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
};
|
|
1304
|
-
function get$4(around) {
|
|
1305
|
-
return typeof around === 'string' ? directionData[Direction9[around]] : around;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
const { toPoint: toPoint$4 } = AroundHelper;
|
|
1309
|
-
const AlignHelper = {
|
|
1310
|
-
toPoint(align, contentBounds, bounds, to, onlySize) {
|
|
1311
|
-
toPoint$4(align, bounds, to, onlySize, contentBounds);
|
|
1312
|
-
}
|
|
1313
|
-
};
|
|
1314
|
-
|
|
1315
1329
|
const StringNumberMap = {
|
|
1316
1330
|
'0': 1,
|
|
1317
1331
|
'1': 1,
|
|
@@ -1442,11 +1456,17 @@ const Plugin = {
|
|
|
1442
1456
|
return rs;
|
|
1443
1457
|
},
|
|
1444
1458
|
need(name) {
|
|
1445
|
-
console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1459
|
+
console.error('please install and import plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1446
1460
|
}
|
|
1447
1461
|
};
|
|
1448
1462
|
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
1449
1463
|
|
|
1464
|
+
const Creator = {
|
|
1465
|
+
editor(_options) {
|
|
1466
|
+
return Plugin.need('editor');
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1450
1470
|
const debug$e = Debug.get('UICreator');
|
|
1451
1471
|
const UICreator = {
|
|
1452
1472
|
list: {},
|
|
@@ -1584,6 +1604,10 @@ const DataHelper = {
|
|
|
1584
1604
|
for (let i = 0, len = list.length; i < len; i++)
|
|
1585
1605
|
map[list[i]] = true;
|
|
1586
1606
|
return map;
|
|
1607
|
+
},
|
|
1608
|
+
stintSet(data, attrName, value) {
|
|
1609
|
+
value || (value = undefined);
|
|
1610
|
+
data[attrName] !== value && (data[attrName] = value);
|
|
1587
1611
|
}
|
|
1588
1612
|
};
|
|
1589
1613
|
const { assign } = DataHelper;
|
|
@@ -2042,7 +2066,7 @@ __decorate([
|
|
|
2042
2066
|
contextMethod()
|
|
2043
2067
|
], Canvas$1.prototype, "strokeText", null);
|
|
2044
2068
|
|
|
2045
|
-
const { copy: copy$
|
|
2069
|
+
const { copy: copy$9, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
|
|
2046
2070
|
const minSize = { width: 1, height: 1, pixelRatio: 1 };
|
|
2047
2071
|
const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
|
|
2048
2072
|
class LeaferCanvasBase extends Canvas$1 {
|
|
@@ -2274,7 +2298,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2274
2298
|
const { size, pixelSnap } = this, canvas = this.manager ? this.manager.get(size) : Creator.canvas(Object.assign({}, size));
|
|
2275
2299
|
canvas.save();
|
|
2276
2300
|
if (useSameWorldTransform)
|
|
2277
|
-
copy$
|
|
2301
|
+
copy$9(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
|
|
2278
2302
|
if (useSameSmooth)
|
|
2279
2303
|
canvas.smooth = this.smooth;
|
|
2280
2304
|
canvas.pixelSnap !== pixelSnap && (canvas.pixelSnap = pixelSnap);
|
|
@@ -2385,7 +2409,7 @@ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI
|
|
|
2385
2409
|
const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
|
|
2386
2410
|
const { set, toNumberPoints } = PointHelper;
|
|
2387
2411
|
const { M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5 } = PathCommandMap;
|
|
2388
|
-
const tempPoint$
|
|
2412
|
+
const tempPoint$1 = {};
|
|
2389
2413
|
const BezierHelper = {
|
|
2390
2414
|
points(data, originPoints, curve, close) {
|
|
2391
2415
|
let points = toNumberPoints(originPoints);
|
|
@@ -2407,6 +2431,8 @@ const BezierHelper = {
|
|
|
2407
2431
|
cY = points[i + 3];
|
|
2408
2432
|
ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
|
|
2409
2433
|
cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
|
|
2434
|
+
if (!ba && !cb)
|
|
2435
|
+
continue;
|
|
2410
2436
|
d = ba + cb;
|
|
2411
2437
|
ba = (t * ba) / d;
|
|
2412
2438
|
cb = (t * cb) / d;
|
|
@@ -2576,8 +2602,8 @@ const BezierHelper = {
|
|
|
2576
2602
|
addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
|
|
2577
2603
|
addPoint$1(pointBounds, toX, toY);
|
|
2578
2604
|
for (let i = 0, len = tList.length; i < len; i++) {
|
|
2579
|
-
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$
|
|
2580
|
-
addPoint$1(pointBounds, tempPoint$
|
|
2605
|
+
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
|
|
2606
|
+
addPoint$1(pointBounds, tempPoint$1.x, tempPoint$1.y);
|
|
2581
2607
|
}
|
|
2582
2608
|
},
|
|
2583
2609
|
getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
|
|
@@ -2651,7 +2677,7 @@ const EllipseHelper = {
|
|
|
2651
2677
|
};
|
|
2652
2678
|
|
|
2653
2679
|
const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$3, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
|
|
2654
|
-
const { rect: rect$
|
|
2680
|
+
const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2655
2681
|
const { ellipticalArc } = EllipseHelper;
|
|
2656
2682
|
const debug$c = Debug.get('PathConvert');
|
|
2657
2683
|
const setEndPoint$1 = {};
|
|
@@ -2848,7 +2874,7 @@ const PathConvert = {
|
|
|
2848
2874
|
case N$3:
|
|
2849
2875
|
x = old[i + 1];
|
|
2850
2876
|
y = old[i + 2];
|
|
2851
|
-
curveMode ? rect$
|
|
2877
|
+
curveMode ? rect$3(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
|
|
2852
2878
|
i += 5;
|
|
2853
2879
|
break;
|
|
2854
2880
|
case D$3:
|
|
@@ -3024,7 +3050,7 @@ const PathCommandDataHelper = {
|
|
|
3024
3050
|
};
|
|
3025
3051
|
const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
|
|
3026
3052
|
|
|
3027
|
-
const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$
|
|
3053
|
+
const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$2, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
|
|
3028
3054
|
class PathCreator {
|
|
3029
3055
|
set path(value) { this.__path = value; }
|
|
3030
3056
|
get path() { return this.__path; }
|
|
@@ -3071,7 +3097,7 @@ class PathCreator {
|
|
|
3071
3097
|
return this;
|
|
3072
3098
|
}
|
|
3073
3099
|
rect(x, y, width, height) {
|
|
3074
|
-
rect$
|
|
3100
|
+
rect$2(this.__path, x, y, width, height);
|
|
3075
3101
|
this.paint();
|
|
3076
3102
|
return this;
|
|
3077
3103
|
}
|
|
@@ -3189,7 +3215,7 @@ const PathDrawer = {
|
|
|
3189
3215
|
|
|
3190
3216
|
const { M: M$1, L: L$2, C, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
|
|
3191
3217
|
const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
|
|
3192
|
-
const { addPointBounds, copy: copy$
|
|
3218
|
+
const { addPointBounds, copy: copy$8, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
|
|
3193
3219
|
const debug$a = Debug.get('PathBounds');
|
|
3194
3220
|
let radius, radiusX, radiusY;
|
|
3195
3221
|
const tempPointBounds = {};
|
|
@@ -3261,7 +3287,7 @@ const PathBounds = {
|
|
|
3261
3287
|
break;
|
|
3262
3288
|
case G:
|
|
3263
3289
|
ellipse$1(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], data[i + 7], data[i + 8], tempPointBounds, setEndPoint);
|
|
3264
|
-
i === 0 ? copy$
|
|
3290
|
+
i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3265
3291
|
x = setEndPoint.x;
|
|
3266
3292
|
y = setEndPoint.y;
|
|
3267
3293
|
i += 9;
|
|
@@ -3277,7 +3303,7 @@ const PathBounds = {
|
|
|
3277
3303
|
break;
|
|
3278
3304
|
case O:
|
|
3279
3305
|
arc(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], tempPointBounds, setEndPoint);
|
|
3280
|
-
i === 0 ? copy$
|
|
3306
|
+
i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3281
3307
|
x = setEndPoint.x;
|
|
3282
3308
|
y = setEndPoint.y;
|
|
3283
3309
|
i += 7;
|
|
@@ -3292,7 +3318,7 @@ const PathBounds = {
|
|
|
3292
3318
|
break;
|
|
3293
3319
|
case U:
|
|
3294
3320
|
arcTo$1(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
|
|
3295
|
-
i === 0 ? copy$
|
|
3321
|
+
i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3296
3322
|
x = setEndPoint.x;
|
|
3297
3323
|
y = setEndPoint.y;
|
|
3298
3324
|
i += 6;
|
|
@@ -3386,7 +3412,7 @@ function canvasPatch(drawer) {
|
|
|
3386
3412
|
}
|
|
3387
3413
|
|
|
3388
3414
|
const FileHelper = {
|
|
3389
|
-
|
|
3415
|
+
alphaPixelTypes: ['png', 'webp', 'svg'],
|
|
3390
3416
|
upperCaseTypeMap: {},
|
|
3391
3417
|
mineType(type) {
|
|
3392
3418
|
if (!type || type.startsWith('image'))
|
|
@@ -3413,7 +3439,7 @@ const FileHelper = {
|
|
|
3413
3439
|
}
|
|
3414
3440
|
};
|
|
3415
3441
|
const F = FileHelper;
|
|
3416
|
-
F.
|
|
3442
|
+
F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3417
3443
|
|
|
3418
3444
|
const debug$9 = Debug.get('TaskProcessor');
|
|
3419
3445
|
class TaskItem {
|
|
@@ -3730,8 +3756,8 @@ const ImageManager = {
|
|
|
3730
3756
|
list.length = 0;
|
|
3731
3757
|
}
|
|
3732
3758
|
},
|
|
3733
|
-
|
|
3734
|
-
return FileHelper.
|
|
3759
|
+
hasAlphaPixel(config) {
|
|
3760
|
+
return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
|
|
3735
3761
|
},
|
|
3736
3762
|
isFormat(format, config) {
|
|
3737
3763
|
if (config.format === format)
|
|
@@ -3769,7 +3795,7 @@ class LeaferImage {
|
|
|
3769
3795
|
this.setView(view.config ? view.view : view);
|
|
3770
3796
|
}
|
|
3771
3797
|
ImageManager.isFormat('svg', config) && (this.isSVG = true);
|
|
3772
|
-
ImageManager.
|
|
3798
|
+
ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
|
|
3773
3799
|
}
|
|
3774
3800
|
load(onSuccess, onError) {
|
|
3775
3801
|
if (!this.loading) {
|
|
@@ -4228,8 +4254,8 @@ function registerUIEvent() {
|
|
|
4228
4254
|
};
|
|
4229
4255
|
}
|
|
4230
4256
|
|
|
4231
|
-
const { copy: copy$
|
|
4232
|
-
const matrix = {}, { round } = Math;
|
|
4257
|
+
const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4258
|
+
const matrix$1 = {}, { round } = Math;
|
|
4233
4259
|
const LeafHelper = {
|
|
4234
4260
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
4235
4261
|
if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
|
|
@@ -4324,13 +4350,13 @@ const LeafHelper = {
|
|
|
4324
4350
|
transition = scaleY;
|
|
4325
4351
|
scaleY = scaleX;
|
|
4326
4352
|
}
|
|
4327
|
-
copy$
|
|
4328
|
-
scaleOfOuter$2(matrix, origin, scaleX, scaleY);
|
|
4353
|
+
copy$7(matrix$1, o);
|
|
4354
|
+
scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
|
|
4329
4355
|
if (t.origin || t.around) {
|
|
4330
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4356
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4331
4357
|
}
|
|
4332
4358
|
else {
|
|
4333
|
-
const x = t.x + matrix.e - o.e, y = t.y + matrix.f - o.f;
|
|
4359
|
+
const x = t.x + matrix$1.e - o.e, y = t.y + matrix$1.f - o.f;
|
|
4334
4360
|
if (transition && !resize)
|
|
4335
4361
|
t.animate({ x, y, scaleX: t.scaleX * scaleX, scaleY: t.scaleY * scaleY }, transition);
|
|
4336
4362
|
else
|
|
@@ -4342,32 +4368,32 @@ const LeafHelper = {
|
|
|
4342
4368
|
},
|
|
4343
4369
|
rotateOfLocal(t, origin, angle, transition) {
|
|
4344
4370
|
const o = t.__localMatrix;
|
|
4345
|
-
copy$
|
|
4346
|
-
rotateOfOuter$2(matrix, origin, angle);
|
|
4371
|
+
copy$7(matrix$1, o);
|
|
4372
|
+
rotateOfOuter$2(matrix$1, origin, angle);
|
|
4347
4373
|
if (t.origin || t.around)
|
|
4348
|
-
L.setTransform(t, matrix, false, transition);
|
|
4374
|
+
L.setTransform(t, matrix$1, false, transition);
|
|
4349
4375
|
else
|
|
4350
|
-
t.set({ x: t.x + matrix.e - o.e, y: t.y + matrix.f - o.f, rotation: MathHelper.formatRotation(t.rotation + angle) }, transition);
|
|
4376
|
+
t.set({ x: t.x + matrix$1.e - o.e, y: t.y + matrix$1.f - o.f, rotation: MathHelper.formatRotation(t.rotation + angle) }, transition);
|
|
4351
4377
|
},
|
|
4352
4378
|
skewOfWorld(t, origin, skewX, skewY, resize, transition) {
|
|
4353
4379
|
L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize, transition);
|
|
4354
4380
|
},
|
|
4355
4381
|
skewOfLocal(t, origin, skewX, skewY = 0, resize, transition) {
|
|
4356
|
-
copy$
|
|
4357
|
-
skewOfOuter(matrix, origin, skewX, skewY);
|
|
4358
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4382
|
+
copy$7(matrix$1, t.__localMatrix);
|
|
4383
|
+
skewOfOuter(matrix$1, origin, skewX, skewY);
|
|
4384
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4359
4385
|
},
|
|
4360
4386
|
transformWorld(t, transform, resize, transition) {
|
|
4361
|
-
copy$
|
|
4362
|
-
multiplyParent$2(matrix, transform);
|
|
4387
|
+
copy$7(matrix$1, t.worldTransform);
|
|
4388
|
+
multiplyParent$2(matrix$1, transform);
|
|
4363
4389
|
if (t.parent)
|
|
4364
|
-
divideParent(matrix, t.parent.worldTransform);
|
|
4365
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4390
|
+
divideParent(matrix$1, t.parent.worldTransform);
|
|
4391
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4366
4392
|
},
|
|
4367
4393
|
transform(t, transform, resize, transition) {
|
|
4368
|
-
copy$
|
|
4369
|
-
multiplyParent$2(matrix, transform);
|
|
4370
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4394
|
+
copy$7(matrix$1, t.localTransform);
|
|
4395
|
+
multiplyParent$2(matrix$1, transform);
|
|
4396
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4371
4397
|
},
|
|
4372
4398
|
setTransform(t, transform, resize, transition) {
|
|
4373
4399
|
const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin);
|
|
@@ -4401,9 +4427,9 @@ const LeafHelper = {
|
|
|
4401
4427
|
return innerOrigin;
|
|
4402
4428
|
},
|
|
4403
4429
|
getRelativeWorld(t, relative, temp) {
|
|
4404
|
-
copy$
|
|
4405
|
-
divideParent(matrix, relative.worldTransform);
|
|
4406
|
-
return temp ? matrix : Object.assign({}, matrix);
|
|
4430
|
+
copy$7(matrix$1, t.worldTransform);
|
|
4431
|
+
divideParent(matrix$1, relative.worldTransform);
|
|
4432
|
+
return temp ? matrix$1 : Object.assign({}, matrix$1);
|
|
4407
4433
|
},
|
|
4408
4434
|
drop(t, parent, index, resize) {
|
|
4409
4435
|
t.setTransform(L.getRelativeWorld(t, parent, true), resize);
|
|
@@ -4457,7 +4483,7 @@ const LeafBoundsHelper = {
|
|
|
4457
4483
|
}
|
|
4458
4484
|
};
|
|
4459
4485
|
|
|
4460
|
-
const { updateBounds: updateBounds$
|
|
4486
|
+
const { updateBounds: updateBounds$3 } = LeafHelper;
|
|
4461
4487
|
const BranchHelper = {
|
|
4462
4488
|
sort(a, b) {
|
|
4463
4489
|
return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
|
|
@@ -4519,11 +4545,11 @@ const BranchHelper = {
|
|
|
4519
4545
|
branch = branchStack[i];
|
|
4520
4546
|
children = branch.children;
|
|
4521
4547
|
for (let j = 0, len = children.length; j < len; j++) {
|
|
4522
|
-
updateBounds$
|
|
4548
|
+
updateBounds$3(children[j]);
|
|
4523
4549
|
}
|
|
4524
4550
|
if (exclude && exclude === branch)
|
|
4525
4551
|
continue;
|
|
4526
|
-
updateBounds$
|
|
4552
|
+
updateBounds$3(branch);
|
|
4527
4553
|
}
|
|
4528
4554
|
}
|
|
4529
4555
|
};
|
|
@@ -4541,8 +4567,8 @@ const WaitHelper = {
|
|
|
4541
4567
|
}
|
|
4542
4568
|
};
|
|
4543
4569
|
|
|
4544
|
-
const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
|
|
4545
|
-
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$
|
|
4570
|
+
const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2 } = LeafHelper;
|
|
4571
|
+
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$6 } = BoundsHelper;
|
|
4546
4572
|
const localContent = '_localContentBounds';
|
|
4547
4573
|
const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
|
|
4548
4574
|
class LeafLayout {
|
|
@@ -4585,7 +4611,9 @@ class LeafLayout {
|
|
|
4585
4611
|
this._localRenderBounds = local;
|
|
4586
4612
|
}
|
|
4587
4613
|
update() {
|
|
4588
|
-
const { leafer } =
|
|
4614
|
+
const { leaf } = this, { leafer } = leaf;
|
|
4615
|
+
if (leaf.isApp)
|
|
4616
|
+
return updateBounds$2(leaf);
|
|
4589
4617
|
if (leafer) {
|
|
4590
4618
|
if (leafer.ready)
|
|
4591
4619
|
leafer.watcher.changed && leafer.layouter.layout();
|
|
@@ -4593,7 +4621,7 @@ class LeafLayout {
|
|
|
4593
4621
|
leafer.start();
|
|
4594
4622
|
}
|
|
4595
4623
|
else {
|
|
4596
|
-
let root =
|
|
4624
|
+
let root = leaf;
|
|
4597
4625
|
while (root.parent && !root.parent.leafer) {
|
|
4598
4626
|
root = root.parent;
|
|
4599
4627
|
}
|
|
@@ -4700,7 +4728,7 @@ class LeafLayout {
|
|
|
4700
4728
|
}
|
|
4701
4729
|
if (!layoutBounds)
|
|
4702
4730
|
layoutBounds = MatrixHelper.getLayout(matrix);
|
|
4703
|
-
copy$
|
|
4731
|
+
copy$6(layoutBounds, bounds);
|
|
4704
4732
|
PointHelper.copy(layoutBounds, point);
|
|
4705
4733
|
if (unscale) {
|
|
4706
4734
|
const { scaleX, scaleY } = layoutBounds;
|
|
@@ -4815,7 +4843,7 @@ class LeafLayout {
|
|
|
4815
4843
|
}
|
|
4816
4844
|
childrenSortChange() {
|
|
4817
4845
|
if (!this.childrenSortChanged) {
|
|
4818
|
-
this.childrenSortChanged = true;
|
|
4846
|
+
this.childrenSortChanged = this.affectChildrenSort = true;
|
|
4819
4847
|
this.leaf.forceUpdate('surface');
|
|
4820
4848
|
}
|
|
4821
4849
|
}
|
|
@@ -4882,6 +4910,40 @@ ImageEvent.LOAD = 'image.load';
|
|
|
4882
4910
|
ImageEvent.LOADED = 'image.loaded';
|
|
4883
4911
|
ImageEvent.ERROR = 'image.error';
|
|
4884
4912
|
|
|
4913
|
+
class BoundsEvent extends Event {
|
|
4914
|
+
static checkHas(leaf, type, mode) {
|
|
4915
|
+
if (mode === 'on') {
|
|
4916
|
+
type === WORLD ? leaf.__hasWorldEvent = true : leaf.__hasLocalEvent = true;
|
|
4917
|
+
}
|
|
4918
|
+
else {
|
|
4919
|
+
leaf.__hasLocalEvent = leaf.hasEvent(RESIZE) || leaf.hasEvent(INNER) || leaf.hasEvent(LOCAL);
|
|
4920
|
+
leaf.__hasWorldEvent = leaf.hasEvent(WORLD);
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4923
|
+
static emitLocal(leaf) {
|
|
4924
|
+
if (leaf.leaferIsReady) {
|
|
4925
|
+
const { resized } = leaf.__layout;
|
|
4926
|
+
if (resized !== 'local') {
|
|
4927
|
+
leaf.emit(RESIZE, leaf);
|
|
4928
|
+
if (resized === 'inner')
|
|
4929
|
+
leaf.emit(INNER, leaf);
|
|
4930
|
+
}
|
|
4931
|
+
leaf.emit(LOCAL, leaf);
|
|
4932
|
+
}
|
|
4933
|
+
}
|
|
4934
|
+
static emitWorld(leaf) {
|
|
4935
|
+
if (leaf.leaferIsReady)
|
|
4936
|
+
leaf.emit(WORLD, this);
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
BoundsEvent.RESIZE = 'bounds.resize';
|
|
4940
|
+
BoundsEvent.INNER = 'bounds.inner';
|
|
4941
|
+
BoundsEvent.LOCAL = 'bounds.local';
|
|
4942
|
+
BoundsEvent.WORLD = 'bounds.world';
|
|
4943
|
+
const { RESIZE, INNER, LOCAL, WORLD } = BoundsEvent;
|
|
4944
|
+
const boundsEventMap = {};
|
|
4945
|
+
[RESIZE, INNER, LOCAL, WORLD].forEach(key => boundsEventMap[key] = 1);
|
|
4946
|
+
|
|
4885
4947
|
class ResizeEvent extends Event {
|
|
4886
4948
|
get bigger() {
|
|
4887
4949
|
if (!this.old)
|
|
@@ -4978,9 +5040,12 @@ class Eventer {
|
|
|
4978
5040
|
set event(map) { this.on(map); }
|
|
4979
5041
|
on(type, listener, options) {
|
|
4980
5042
|
if (!listener) {
|
|
4981
|
-
let event
|
|
4982
|
-
|
|
4983
|
-
|
|
5043
|
+
let event;
|
|
5044
|
+
if (type instanceof Array)
|
|
5045
|
+
type.forEach(item => this.on(item[0], item[1], item[2]));
|
|
5046
|
+
else
|
|
5047
|
+
for (let key in type)
|
|
5048
|
+
(event = type[key]) instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
|
|
4984
5049
|
return;
|
|
4985
5050
|
}
|
|
4986
5051
|
let capture, once;
|
|
@@ -5010,6 +5075,8 @@ class Eventer {
|
|
|
5010
5075
|
else {
|
|
5011
5076
|
map[type] = [item];
|
|
5012
5077
|
}
|
|
5078
|
+
if (boundsEventMap[type])
|
|
5079
|
+
BoundsEvent.checkHas(this, type, 'on');
|
|
5013
5080
|
}
|
|
5014
5081
|
});
|
|
5015
5082
|
}
|
|
@@ -5031,6 +5098,8 @@ class Eventer {
|
|
|
5031
5098
|
events.splice(index, 1);
|
|
5032
5099
|
if (!events.length)
|
|
5033
5100
|
delete map[type];
|
|
5101
|
+
if (boundsEventMap[type])
|
|
5102
|
+
BoundsEvent.checkHas(this, type, 'off');
|
|
5034
5103
|
}
|
|
5035
5104
|
}
|
|
5036
5105
|
});
|
|
@@ -5050,19 +5119,31 @@ class Eventer {
|
|
|
5050
5119
|
}
|
|
5051
5120
|
}
|
|
5052
5121
|
on_(type, listener, bind, options) {
|
|
5053
|
-
if (
|
|
5054
|
-
|
|
5055
|
-
|
|
5122
|
+
if (!listener)
|
|
5123
|
+
(type instanceof Array) && type.forEach(item => this.on(item[0], item[2] ? item[1] = item[1].bind(item[2]) : item[1], item[3]));
|
|
5124
|
+
else
|
|
5125
|
+
this.on(type, bind ? listener = listener.bind(bind) : listener, options);
|
|
5056
5126
|
return { type, current: this, listener, options };
|
|
5057
5127
|
}
|
|
5058
5128
|
off_(id) {
|
|
5059
5129
|
if (!id)
|
|
5060
5130
|
return;
|
|
5061
5131
|
const list = id instanceof Array ? id : [id];
|
|
5062
|
-
list.forEach(item =>
|
|
5132
|
+
list.forEach(item => {
|
|
5133
|
+
if (!item.listener)
|
|
5134
|
+
(item.type instanceof Array) && item.type.forEach(v => item.current.off(v[0], v[1], v[3]));
|
|
5135
|
+
else
|
|
5136
|
+
item.current.off(item.type, item.listener, item.options);
|
|
5137
|
+
});
|
|
5063
5138
|
list.length = 0;
|
|
5064
5139
|
}
|
|
5065
|
-
once(type, listener, capture) {
|
|
5140
|
+
once(type, listener, captureOrBind, capture) {
|
|
5141
|
+
if (!listener)
|
|
5142
|
+
return (type instanceof Array) && type.forEach(item => this.once(item[0], item[1], item[2], item[3]));
|
|
5143
|
+
if (typeof captureOrBind === 'object')
|
|
5144
|
+
listener = listener.bind(captureOrBind);
|
|
5145
|
+
else
|
|
5146
|
+
capture = captureOrBind;
|
|
5066
5147
|
this.on(type, listener, { once: true, capture });
|
|
5067
5148
|
}
|
|
5068
5149
|
emit(type, event, capture) {
|
|
@@ -5174,7 +5255,7 @@ const LeafDataProxy = {
|
|
|
5174
5255
|
};
|
|
5175
5256
|
|
|
5176
5257
|
const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
|
|
5177
|
-
const { toPoint: toPoint$3, tempPoint
|
|
5258
|
+
const { toPoint: toPoint$3, tempPoint } = AroundHelper;
|
|
5178
5259
|
const LeafMatrix = {
|
|
5179
5260
|
__updateWorldMatrix() {
|
|
5180
5261
|
multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
|
|
@@ -5183,33 +5264,39 @@ const LeafMatrix = {
|
|
|
5183
5264
|
if (this.__local) {
|
|
5184
5265
|
const layout = this.__layout, local = this.__local, data = this.__;
|
|
5185
5266
|
if (layout.affectScaleOrRotation) {
|
|
5186
|
-
if (layout.scaleChanged || layout.rotationChanged) {
|
|
5267
|
+
if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
|
|
5187
5268
|
setLayout(local, data, null, null, layout.affectRotation);
|
|
5188
|
-
layout.scaleChanged = layout.rotationChanged =
|
|
5269
|
+
layout.scaleChanged = layout.rotationChanged = undefined;
|
|
5189
5270
|
}
|
|
5190
5271
|
}
|
|
5191
5272
|
local.e = data.x + data.offsetX;
|
|
5192
5273
|
local.f = data.y + data.offsetY;
|
|
5193
5274
|
if (data.around || data.origin) {
|
|
5194
|
-
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint
|
|
5195
|
-
translateInner(local, -tempPoint
|
|
5275
|
+
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint);
|
|
5276
|
+
translateInner(local, -tempPoint.x, -tempPoint.y, !data.around);
|
|
5196
5277
|
}
|
|
5197
5278
|
}
|
|
5198
|
-
this.__layout.matrixChanged =
|
|
5279
|
+
this.__layout.matrixChanged = undefined;
|
|
5199
5280
|
}
|
|
5200
5281
|
};
|
|
5201
5282
|
|
|
5202
5283
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5203
5284
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5204
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$
|
|
5285
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
|
|
5205
5286
|
const { toBounds: toBounds$1 } = PathBounds;
|
|
5206
5287
|
const LeafBounds = {
|
|
5207
5288
|
__updateWorldBounds() {
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5289
|
+
const layout = this.__layout;
|
|
5290
|
+
toOuterOf$1(layout.renderBounds, this.__world, this.__world);
|
|
5291
|
+
if (layout.resized) {
|
|
5292
|
+
if (layout.resized === 'inner')
|
|
5293
|
+
this.__onUpdateSize();
|
|
5294
|
+
if (this.__hasLocalEvent)
|
|
5295
|
+
BoundsEvent.emitLocal(this);
|
|
5296
|
+
layout.resized = undefined;
|
|
5212
5297
|
}
|
|
5298
|
+
if (this.__hasWorldEvent)
|
|
5299
|
+
BoundsEvent.emitWorld(this);
|
|
5213
5300
|
},
|
|
5214
5301
|
__updateLocalBounds() {
|
|
5215
5302
|
const layout = this.__layout;
|
|
@@ -5218,12 +5305,12 @@ const LeafBounds = {
|
|
|
5218
5305
|
this.__updatePath();
|
|
5219
5306
|
this.__updateRenderPath();
|
|
5220
5307
|
this.__updateBoxBounds();
|
|
5221
|
-
layout.resized =
|
|
5308
|
+
layout.resized = 'inner';
|
|
5222
5309
|
}
|
|
5223
5310
|
if (layout.localBoxChanged) {
|
|
5224
5311
|
if (this.__local)
|
|
5225
5312
|
this.__updateLocalBoxBounds();
|
|
5226
|
-
layout.localBoxChanged =
|
|
5313
|
+
layout.localBoxChanged = undefined;
|
|
5227
5314
|
if (layout.strokeSpread)
|
|
5228
5315
|
layout.strokeChanged = true;
|
|
5229
5316
|
if (layout.renderSpread)
|
|
@@ -5231,7 +5318,7 @@ const LeafBounds = {
|
|
|
5231
5318
|
if (this.parent)
|
|
5232
5319
|
this.parent.__layout.boxChange();
|
|
5233
5320
|
}
|
|
5234
|
-
layout.boxChanged =
|
|
5321
|
+
layout.boxChanged = undefined;
|
|
5235
5322
|
if (layout.strokeChanged) {
|
|
5236
5323
|
layout.strokeSpread = this.__updateStrokeSpread();
|
|
5237
5324
|
if (layout.strokeSpread) {
|
|
@@ -5243,12 +5330,12 @@ const LeafBounds = {
|
|
|
5243
5330
|
else {
|
|
5244
5331
|
layout.spreadStrokeCancel();
|
|
5245
5332
|
}
|
|
5246
|
-
layout.strokeChanged =
|
|
5333
|
+
layout.strokeChanged = undefined;
|
|
5247
5334
|
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
|
|
5248
5335
|
layout.renderChanged = true;
|
|
5249
5336
|
if (this.parent)
|
|
5250
5337
|
this.parent.__layout.strokeChange();
|
|
5251
|
-
layout.resized =
|
|
5338
|
+
layout.resized = 'inner';
|
|
5252
5339
|
}
|
|
5253
5340
|
if (layout.renderChanged) {
|
|
5254
5341
|
layout.renderSpread = this.__updateRenderSpread();
|
|
@@ -5261,11 +5348,12 @@ const LeafBounds = {
|
|
|
5261
5348
|
else {
|
|
5262
5349
|
layout.spreadRenderCancel();
|
|
5263
5350
|
}
|
|
5264
|
-
layout.renderChanged =
|
|
5351
|
+
layout.renderChanged = undefined;
|
|
5265
5352
|
if (this.parent)
|
|
5266
5353
|
this.parent.__layout.renderChange();
|
|
5267
5354
|
}
|
|
5268
|
-
layout.
|
|
5355
|
+
layout.resized || (layout.resized = 'local');
|
|
5356
|
+
layout.boundsChanged = undefined;
|
|
5269
5357
|
},
|
|
5270
5358
|
__updateLocalBoxBounds() {
|
|
5271
5359
|
if (this.__hasMotionPath)
|
|
@@ -5325,7 +5413,7 @@ const LeafBounds = {
|
|
|
5325
5413
|
},
|
|
5326
5414
|
__updateRenderBounds() {
|
|
5327
5415
|
const layout = this.__layout;
|
|
5328
|
-
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$
|
|
5416
|
+
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5329
5417
|
}
|
|
5330
5418
|
};
|
|
5331
5419
|
|
|
@@ -5430,7 +5518,7 @@ const BranchRender = {
|
|
|
5430
5518
|
const { LEAF, create } = IncrementId;
|
|
5431
5519
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5432
5520
|
const { toOuterOf } = BoundsHelper;
|
|
5433
|
-
const { copy: copy$
|
|
5521
|
+
const { copy: copy$4, move } = PointHelper;
|
|
5434
5522
|
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5435
5523
|
let Leaf = class Leaf {
|
|
5436
5524
|
get tag() { return this.__tag; }
|
|
@@ -5643,7 +5731,7 @@ let Leaf = class Leaf {
|
|
|
5643
5731
|
}
|
|
5644
5732
|
else {
|
|
5645
5733
|
if (to)
|
|
5646
|
-
copy$
|
|
5734
|
+
copy$4(to, world);
|
|
5647
5735
|
}
|
|
5648
5736
|
}
|
|
5649
5737
|
localToWorld(local, to, distance, relative) {
|
|
@@ -5652,7 +5740,7 @@ let Leaf = class Leaf {
|
|
|
5652
5740
|
}
|
|
5653
5741
|
else {
|
|
5654
5742
|
if (to)
|
|
5655
|
-
copy$
|
|
5743
|
+
copy$4(to, local);
|
|
5656
5744
|
}
|
|
5657
5745
|
}
|
|
5658
5746
|
worldToInner(world, to, distance, relative) {
|
|
@@ -5805,7 +5893,7 @@ let Leaf = class Leaf {
|
|
|
5805
5893
|
off(_type, _listener, _options) { }
|
|
5806
5894
|
on_(_type, _listener, _bind, _options) { return undefined; }
|
|
5807
5895
|
off_(_id) { }
|
|
5808
|
-
once(_type, _listener, _capture) { }
|
|
5896
|
+
once(_type, _listener, _captureOrBind, _capture) { }
|
|
5809
5897
|
emit(_type, _event, _capture) { }
|
|
5810
5898
|
emitEvent(_event, _capture) { }
|
|
5811
5899
|
hasEvent(_type, _capture) { return false; }
|
|
@@ -6142,7 +6230,7 @@ class LeafLevelList {
|
|
|
6142
6230
|
}
|
|
6143
6231
|
}
|
|
6144
6232
|
|
|
6145
|
-
const version = "1.6.
|
|
6233
|
+
const version = "1.6.3";
|
|
6146
6234
|
|
|
6147
6235
|
const debug$4 = Debug.get('LeaferCanvas');
|
|
6148
6236
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6482,17 +6570,15 @@ class Watcher {
|
|
|
6482
6570
|
this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
|
|
6483
6571
|
this.__updatedList = new LeafList();
|
|
6484
6572
|
this.totalTimes++;
|
|
6485
|
-
this.changed = false;
|
|
6486
|
-
this.hasVisible = false;
|
|
6487
|
-
this.hasRemove = false;
|
|
6488
|
-
this.hasAdd = false;
|
|
6573
|
+
this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
|
|
6489
6574
|
}
|
|
6490
6575
|
__listenEvents() {
|
|
6491
|
-
const { target } = this;
|
|
6492
6576
|
this.__eventIds = [
|
|
6493
|
-
target.on_(
|
|
6494
|
-
|
|
6495
|
-
|
|
6577
|
+
this.target.on_([
|
|
6578
|
+
[PropertyEvent.CHANGE, this.__onAttrChange, this],
|
|
6579
|
+
[[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
|
|
6580
|
+
[WatchEvent.REQUEST, this.__onRquestData, this]
|
|
6581
|
+
])
|
|
6496
6582
|
];
|
|
6497
6583
|
}
|
|
6498
6584
|
__removeListenEvents() {
|
|
@@ -6502,8 +6588,7 @@ class Watcher {
|
|
|
6502
6588
|
if (this.target) {
|
|
6503
6589
|
this.stop();
|
|
6504
6590
|
this.__removeListenEvents();
|
|
6505
|
-
this.target = null;
|
|
6506
|
-
this.__updatedList = null;
|
|
6591
|
+
this.target = this.__updatedList = null;
|
|
6507
6592
|
}
|
|
6508
6593
|
}
|
|
6509
6594
|
}
|
|
@@ -6608,7 +6693,7 @@ class Layouter {
|
|
|
6608
6693
|
this.disabled = true;
|
|
6609
6694
|
}
|
|
6610
6695
|
layout() {
|
|
6611
|
-
if (!this.running)
|
|
6696
|
+
if (this.layouting || !this.running)
|
|
6612
6697
|
return;
|
|
6613
6698
|
const { target } = this;
|
|
6614
6699
|
this.times = 0;
|
|
@@ -6691,12 +6776,10 @@ class Layouter {
|
|
|
6691
6776
|
}
|
|
6692
6777
|
static fullLayout(target) {
|
|
6693
6778
|
updateAllMatrix(target, true);
|
|
6694
|
-
if (target.isBranch)
|
|
6779
|
+
if (target.isBranch)
|
|
6695
6780
|
BranchHelper.updateBounds(target);
|
|
6696
|
-
|
|
6697
|
-
else {
|
|
6781
|
+
else
|
|
6698
6782
|
LeafHelper.updateBounds(target);
|
|
6699
|
-
}
|
|
6700
6783
|
updateAllChange(target);
|
|
6701
6784
|
}
|
|
6702
6785
|
addExtra(leaf) {
|
|
@@ -6719,11 +6802,12 @@ class Layouter {
|
|
|
6719
6802
|
this.__updatedList = event.data.updatedList;
|
|
6720
6803
|
}
|
|
6721
6804
|
__listenEvents() {
|
|
6722
|
-
const { target } = this;
|
|
6723
6805
|
this.__eventIds = [
|
|
6724
|
-
target.on_(
|
|
6725
|
-
|
|
6726
|
-
|
|
6806
|
+
this.target.on_([
|
|
6807
|
+
[LayoutEvent.REQUEST, this.layout, this],
|
|
6808
|
+
[LayoutEvent.AGAIN, this.layoutAgain, this],
|
|
6809
|
+
[WatchEvent.DATA, this.__onReceiveWatchData, this]
|
|
6810
|
+
])
|
|
6727
6811
|
];
|
|
6728
6812
|
}
|
|
6729
6813
|
__removeListenEvents() {
|
|
@@ -6954,12 +7038,13 @@ class Renderer {
|
|
|
6954
7038
|
this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
|
|
6955
7039
|
}
|
|
6956
7040
|
__listenEvents() {
|
|
6957
|
-
const { target } = this;
|
|
6958
7041
|
this.__eventIds = [
|
|
6959
|
-
target.on_(
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
7042
|
+
this.target.on_([
|
|
7043
|
+
[RenderEvent.REQUEST, this.update, this],
|
|
7044
|
+
[LayoutEvent.END, this.__onLayoutEnd, this],
|
|
7045
|
+
[RenderEvent.AGAIN, this.renderAgain, this],
|
|
7046
|
+
[ResizeEvent.RESIZE, this.__onResize, this]
|
|
7047
|
+
])
|
|
6963
7048
|
];
|
|
6964
7049
|
}
|
|
6965
7050
|
__removeListenEvents() {
|
|
@@ -7018,8 +7103,32 @@ function zoomLayerType() {
|
|
|
7018
7103
|
};
|
|
7019
7104
|
}
|
|
7020
7105
|
|
|
7106
|
+
function hasTransparent$3(color) {
|
|
7107
|
+
if (!color || color.length === 7 || color.length === 4)
|
|
7108
|
+
return false;
|
|
7109
|
+
if (color === 'transparent')
|
|
7110
|
+
return true;
|
|
7111
|
+
const first = color[0];
|
|
7112
|
+
if (first === '#') {
|
|
7113
|
+
switch (color.length) {
|
|
7114
|
+
case 5: return color[4] !== 'f' && color[4] !== 'F';
|
|
7115
|
+
case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
|
|
7116
|
+
}
|
|
7117
|
+
}
|
|
7118
|
+
else if (first === 'r' || first === 'h') {
|
|
7119
|
+
if (color[3] === 'a') {
|
|
7120
|
+
const i = color.lastIndexOf(',');
|
|
7121
|
+
if (i > -1)
|
|
7122
|
+
return parseFloat(color.slice(i + 1)) < 1;
|
|
7123
|
+
}
|
|
7124
|
+
}
|
|
7125
|
+
return false;
|
|
7126
|
+
}
|
|
7127
|
+
|
|
7021
7128
|
const TextConvert = {};
|
|
7022
|
-
const ColorConvert = {
|
|
7129
|
+
const ColorConvert = {
|
|
7130
|
+
hasTransparent: hasTransparent$3
|
|
7131
|
+
};
|
|
7023
7132
|
const UnitConvert = {
|
|
7024
7133
|
number(value, percentRefer) {
|
|
7025
7134
|
return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
|
|
@@ -7045,6 +7154,7 @@ const Transition = {
|
|
|
7045
7154
|
};
|
|
7046
7155
|
|
|
7047
7156
|
const { parse, objectToCanvasData } = PathConvert;
|
|
7157
|
+
const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
|
|
7048
7158
|
const emptyPaint = {};
|
|
7049
7159
|
const debug$1 = Debug.get('UIData');
|
|
7050
7160
|
class UIData extends LeafData {
|
|
@@ -7103,38 +7213,22 @@ class UIData extends LeafData {
|
|
|
7103
7213
|
if (this.__naturalWidth)
|
|
7104
7214
|
this.__removeNaturalSize();
|
|
7105
7215
|
if (typeof value === 'string' || !value) {
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
PaintImage.recycleImage('fill', this);
|
|
7109
|
-
this.__isFills = false;
|
|
7110
|
-
this.__pixelFill && (this.__pixelFill = false);
|
|
7111
|
-
}
|
|
7216
|
+
stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
|
|
7217
|
+
this.__isFills && this.__removePaint('fill', true);
|
|
7112
7218
|
this._fill = value;
|
|
7113
7219
|
}
|
|
7114
7220
|
else if (typeof value === 'object') {
|
|
7115
|
-
this.
|
|
7116
|
-
const layout = this.__leaf.__layout;
|
|
7117
|
-
layout.boxChanged || layout.boxChange();
|
|
7118
|
-
this.__isFills = true;
|
|
7119
|
-
this._fill || (this._fill = emptyPaint);
|
|
7221
|
+
this.__setPaint('fill', value);
|
|
7120
7222
|
}
|
|
7121
7223
|
}
|
|
7122
7224
|
setStroke(value) {
|
|
7123
7225
|
if (typeof value === 'string' || !value) {
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
PaintImage.recycleImage('stroke', this);
|
|
7127
|
-
this.__isStrokes = false;
|
|
7128
|
-
this.__pixelStroke && (this.__pixelStroke = false);
|
|
7129
|
-
}
|
|
7226
|
+
stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
|
|
7227
|
+
this.__isStrokes && this.__removePaint('stroke', true);
|
|
7130
7228
|
this._stroke = value;
|
|
7131
7229
|
}
|
|
7132
7230
|
else if (typeof value === 'object') {
|
|
7133
|
-
this.
|
|
7134
|
-
const layout = this.__leaf.__layout;
|
|
7135
|
-
layout.boxChanged || layout.boxChange();
|
|
7136
|
-
this.__isStrokes = true;
|
|
7137
|
-
this._stroke || (this._stroke = emptyPaint);
|
|
7231
|
+
this.__setPaint('stroke', value);
|
|
7138
7232
|
}
|
|
7139
7233
|
}
|
|
7140
7234
|
setPath(value) {
|
|
@@ -7164,7 +7258,34 @@ class UIData extends LeafData {
|
|
|
7164
7258
|
Paint.compute('fill', this.__leaf);
|
|
7165
7259
|
if (stroke)
|
|
7166
7260
|
Paint.compute('stroke', this.__leaf);
|
|
7167
|
-
this.__needComputePaint =
|
|
7261
|
+
this.__needComputePaint = undefined;
|
|
7262
|
+
}
|
|
7263
|
+
__setPaint(attrName, value) {
|
|
7264
|
+
this.__setInput(attrName, value);
|
|
7265
|
+
const layout = this.__leaf.__layout;
|
|
7266
|
+
layout.boxChanged || layout.boxChange();
|
|
7267
|
+
if (value instanceof Array && !value.length) {
|
|
7268
|
+
this.__removePaint(attrName);
|
|
7269
|
+
}
|
|
7270
|
+
else {
|
|
7271
|
+
if (attrName === 'fill')
|
|
7272
|
+
this.__isFills = true, this._fill || (this._fill = emptyPaint);
|
|
7273
|
+
else
|
|
7274
|
+
this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
|
|
7275
|
+
}
|
|
7276
|
+
}
|
|
7277
|
+
__removePaint(attrName, removeInput) {
|
|
7278
|
+
if (removeInput)
|
|
7279
|
+
this.__removeInput(attrName);
|
|
7280
|
+
PaintImage.recycleImage(attrName, this);
|
|
7281
|
+
if (attrName === 'fill') {
|
|
7282
|
+
stintSet$2(this, '__isAlphaPixelFill', undefined);
|
|
7283
|
+
this._fill = this.__isFills = undefined;
|
|
7284
|
+
}
|
|
7285
|
+
else {
|
|
7286
|
+
stintSet$2(this, '__isAlphaPixelStroke', undefined);
|
|
7287
|
+
this._stroke = this.__isStrokes = undefined;
|
|
7288
|
+
}
|
|
7168
7289
|
}
|
|
7169
7290
|
}
|
|
7170
7291
|
function setArray(data, key, value) {
|
|
@@ -7172,10 +7293,10 @@ function setArray(data, key, value) {
|
|
|
7172
7293
|
if (value instanceof Array) {
|
|
7173
7294
|
if (value.some((item) => item.visible === false))
|
|
7174
7295
|
value = value.filter((item) => item.visible !== false);
|
|
7175
|
-
value.length || (value =
|
|
7296
|
+
value.length || (value = undefined);
|
|
7176
7297
|
}
|
|
7177
7298
|
else
|
|
7178
|
-
value = value && value.visible !== false ? [value] :
|
|
7299
|
+
value = value && value.visible !== false ? [value] : undefined;
|
|
7179
7300
|
data['_' + key] = value;
|
|
7180
7301
|
}
|
|
7181
7302
|
|
|
@@ -7278,8 +7399,6 @@ class ImageData extends RectData {
|
|
|
7278
7399
|
this._url = value;
|
|
7279
7400
|
}
|
|
7280
7401
|
__setImageFill(value) {
|
|
7281
|
-
if (this.__leaf.image)
|
|
7282
|
-
this.__leaf.image = null;
|
|
7283
7402
|
this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
|
|
7284
7403
|
}
|
|
7285
7404
|
__getData() {
|
|
@@ -7345,21 +7464,19 @@ const UIBounds = {
|
|
|
7345
7464
|
}
|
|
7346
7465
|
};
|
|
7347
7466
|
|
|
7467
|
+
const { stintSet: stintSet$1 } = DataHelper;
|
|
7348
7468
|
const UIRender = {
|
|
7349
7469
|
__updateChange() {
|
|
7350
|
-
const data = this.__
|
|
7470
|
+
const data = this.__;
|
|
7351
7471
|
if (data.__useEffect) {
|
|
7352
|
-
const { shadow,
|
|
7353
|
-
data.
|
|
7472
|
+
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7473
|
+
stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
|
|
7474
|
+
data.__useEffect = !!(shadow || otherEffect);
|
|
7354
7475
|
}
|
|
7355
|
-
|
|
7356
|
-
|
|
7476
|
+
stintSet$1(this.__world, 'half', data.__hasHalf);
|
|
7477
|
+
stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7357
7478
|
data.__checkSingle();
|
|
7358
|
-
|
|
7359
|
-
if (complex)
|
|
7360
|
-
data.__complex = true;
|
|
7361
|
-
else
|
|
7362
|
-
data.__complex && (data.__complex = false);
|
|
7479
|
+
stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7363
7480
|
},
|
|
7364
7481
|
__drawFast(canvas, options) {
|
|
7365
7482
|
drawFast(this, canvas, options);
|
|
@@ -7369,21 +7486,23 @@ const UIRender = {
|
|
|
7369
7486
|
if (data.__complex) {
|
|
7370
7487
|
if (data.__needComputePaint)
|
|
7371
7488
|
data.__computePaint();
|
|
7372
|
-
const { fill, stroke, __drawAfterFill } = data;
|
|
7489
|
+
const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
|
|
7373
7490
|
this.__drawRenderPath(canvas);
|
|
7374
|
-
if (data.__useEffect) {
|
|
7491
|
+
if (data.__useEffect && !__isFastShadow) {
|
|
7375
7492
|
const shape = Paint.shape(this, canvas, options);
|
|
7376
7493
|
this.__nowWorld = this.__getNowWorld(options);
|
|
7377
7494
|
const { shadow, innerShadow, filter } = data;
|
|
7378
7495
|
if (shadow)
|
|
7379
7496
|
Effect.shadow(this, canvas, shape);
|
|
7497
|
+
if (__fillAfterStroke)
|
|
7498
|
+
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7380
7499
|
if (fill)
|
|
7381
7500
|
data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7382
7501
|
if (__drawAfterFill)
|
|
7383
7502
|
this.__drawAfterFill(canvas, options);
|
|
7384
7503
|
if (innerShadow)
|
|
7385
7504
|
Effect.innerShadow(this, canvas, shape);
|
|
7386
|
-
if (stroke)
|
|
7505
|
+
if (stroke && !__fillAfterStroke)
|
|
7387
7506
|
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7388
7507
|
if (filter)
|
|
7389
7508
|
Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
@@ -7392,21 +7511,27 @@ const UIRender = {
|
|
|
7392
7511
|
shape.canvas.recycle();
|
|
7393
7512
|
}
|
|
7394
7513
|
else {
|
|
7514
|
+
if (__fillAfterStroke)
|
|
7515
|
+
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7516
|
+
if (__isFastShadow) {
|
|
7517
|
+
const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
|
|
7518
|
+
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
7519
|
+
}
|
|
7395
7520
|
if (fill)
|
|
7396
7521
|
data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7522
|
+
if (__isFastShadow)
|
|
7523
|
+
canvas.restore();
|
|
7397
7524
|
if (__drawAfterFill)
|
|
7398
7525
|
this.__drawAfterFill(canvas, options);
|
|
7399
|
-
if (stroke)
|
|
7526
|
+
if (stroke && !__fillAfterStroke)
|
|
7400
7527
|
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7401
7528
|
}
|
|
7402
7529
|
}
|
|
7403
7530
|
else {
|
|
7404
|
-
if (data.__pathInputed)
|
|
7531
|
+
if (data.__pathInputed)
|
|
7405
7532
|
drawFast(this, canvas, options);
|
|
7406
|
-
|
|
7407
|
-
else {
|
|
7533
|
+
else
|
|
7408
7534
|
this.__drawFast(canvas, options);
|
|
7409
|
-
}
|
|
7410
7535
|
}
|
|
7411
7536
|
},
|
|
7412
7537
|
__renderShape(canvas, options, ignoreFill, ignoreStroke) {
|
|
@@ -7415,11 +7540,11 @@ const UIRender = {
|
|
|
7415
7540
|
const { fill, stroke } = this.__;
|
|
7416
7541
|
this.__drawRenderPath(canvas);
|
|
7417
7542
|
if (fill && !ignoreFill)
|
|
7418
|
-
this.__.
|
|
7543
|
+
this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
7419
7544
|
if (this.__.__isCanvas)
|
|
7420
7545
|
this.__drawAfterFill(canvas, options);
|
|
7421
7546
|
if (stroke && !ignoreStroke)
|
|
7422
|
-
this.__.
|
|
7547
|
+
this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7423
7548
|
}
|
|
7424
7549
|
},
|
|
7425
7550
|
__drawAfterFill(canvas, options) {
|
|
@@ -7434,13 +7559,15 @@ const UIRender = {
|
|
|
7434
7559
|
}
|
|
7435
7560
|
};
|
|
7436
7561
|
function drawFast(ui, canvas, options) {
|
|
7437
|
-
const { fill, stroke, __drawAfterFill } = ui.__;
|
|
7562
|
+
const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
|
|
7438
7563
|
ui.__drawRenderPath(canvas);
|
|
7564
|
+
if (__fillAfterStroke)
|
|
7565
|
+
Paint.stroke(stroke, ui, canvas);
|
|
7439
7566
|
if (fill)
|
|
7440
7567
|
Paint.fill(fill, ui, canvas);
|
|
7441
7568
|
if (__drawAfterFill)
|
|
7442
7569
|
ui.__drawAfterFill(canvas, options);
|
|
7443
|
-
if (stroke)
|
|
7570
|
+
if (stroke && !__fillAfterStroke)
|
|
7444
7571
|
Paint.stroke(stroke, ui, canvas);
|
|
7445
7572
|
}
|
|
7446
7573
|
|
|
@@ -7812,6 +7939,9 @@ __decorate([
|
|
|
7812
7939
|
__decorate([
|
|
7813
7940
|
surfaceType()
|
|
7814
7941
|
], UI.prototype, "placeholderColor", void 0);
|
|
7942
|
+
__decorate([
|
|
7943
|
+
dataType(100)
|
|
7944
|
+
], UI.prototype, "placeholderDelay", void 0);
|
|
7815
7945
|
__decorate([
|
|
7816
7946
|
dataType({})
|
|
7817
7947
|
], UI.prototype, "data", void 0);
|
|
@@ -8213,15 +8343,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8213
8343
|
}
|
|
8214
8344
|
__listenEvents() {
|
|
8215
8345
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
8216
|
-
this.once(
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8346
|
+
this.once([
|
|
8347
|
+
[LeaferEvent.START, () => Run.end(runId)],
|
|
8348
|
+
[LayoutEvent.START, this.updateLazyBounds, this],
|
|
8349
|
+
[RenderEvent.START, this.__onCreated, this],
|
|
8350
|
+
[RenderEvent.END, this.__onViewReady, this]
|
|
8351
|
+
]);
|
|
8352
|
+
this.__eventIds.push(this.on_([
|
|
8353
|
+
[WatchEvent.DATA, this.__onWatchData, this],
|
|
8354
|
+
[LayoutEvent.END, this.__onLayoutEnd, this],
|
|
8355
|
+
[RenderEvent.NEXT, this.__onNextRender, this]
|
|
8356
|
+
]));
|
|
8221
8357
|
}
|
|
8222
8358
|
__removeListenEvents() {
|
|
8223
8359
|
this.off_(this.__eventIds);
|
|
8224
|
-
this.__eventIds.length = 0;
|
|
8225
8360
|
}
|
|
8226
8361
|
destroy(sync) {
|
|
8227
8362
|
const doDestory = () => {
|
|
@@ -8281,8 +8416,8 @@ Rect = __decorate([
|
|
|
8281
8416
|
registerUI()
|
|
8282
8417
|
], Rect);
|
|
8283
8418
|
|
|
8284
|
-
const { copy: copy$
|
|
8285
|
-
const rect = Rect.prototype, group = Group.prototype;
|
|
8419
|
+
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8420
|
+
const rect$1 = Rect.prototype, group = Group.prototype;
|
|
8286
8421
|
const childrenRenderBounds = {};
|
|
8287
8422
|
let Box = class Box extends Group {
|
|
8288
8423
|
get __tag() { return 'Box'; }
|
|
@@ -8327,15 +8462,15 @@ let Box = class Box extends Group {
|
|
|
8327
8462
|
const { renderBounds } = this.__layout;
|
|
8328
8463
|
if (this.children.length) {
|
|
8329
8464
|
super.__updateRenderBounds();
|
|
8330
|
-
copy$
|
|
8465
|
+
copy$3(childrenRenderBounds, renderBounds);
|
|
8331
8466
|
this.__updateRectRenderBounds();
|
|
8332
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds)
|
|
8467
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds);
|
|
8333
8468
|
if (isOverflow && this.__.overflow !== 'hide')
|
|
8334
8469
|
add(renderBounds, childrenRenderBounds);
|
|
8335
8470
|
}
|
|
8336
8471
|
else
|
|
8337
8472
|
this.__updateRectRenderBounds();
|
|
8338
|
-
|
|
8473
|
+
DataHelper.stintSet(this, 'isOverflow', isOverflow);
|
|
8339
8474
|
}
|
|
8340
8475
|
__updateRectRenderBounds() { }
|
|
8341
8476
|
__updateRectChange() { }
|
|
@@ -8379,25 +8514,25 @@ __decorate([
|
|
|
8379
8514
|
affectRenderBoundsType('show')
|
|
8380
8515
|
], Box.prototype, "overflow", void 0);
|
|
8381
8516
|
__decorate([
|
|
8382
|
-
rewrite(rect.__updateStrokeSpread)
|
|
8517
|
+
rewrite(rect$1.__updateStrokeSpread)
|
|
8383
8518
|
], Box.prototype, "__updateStrokeSpread", null);
|
|
8384
8519
|
__decorate([
|
|
8385
|
-
rewrite(rect.__updateRenderSpread)
|
|
8520
|
+
rewrite(rect$1.__updateRenderSpread)
|
|
8386
8521
|
], Box.prototype, "__updateRectRenderSpread", null);
|
|
8387
8522
|
__decorate([
|
|
8388
|
-
rewrite(rect.__updateBoxBounds)
|
|
8523
|
+
rewrite(rect$1.__updateBoxBounds)
|
|
8389
8524
|
], Box.prototype, "__updateRectBoxBounds", null);
|
|
8390
8525
|
__decorate([
|
|
8391
|
-
rewrite(rect.__updateStrokeBounds)
|
|
8526
|
+
rewrite(rect$1.__updateStrokeBounds)
|
|
8392
8527
|
], Box.prototype, "__updateStrokeBounds", null);
|
|
8393
8528
|
__decorate([
|
|
8394
|
-
rewrite(rect.__updateRenderBounds)
|
|
8529
|
+
rewrite(rect$1.__updateRenderBounds)
|
|
8395
8530
|
], Box.prototype, "__updateRectRenderBounds", null);
|
|
8396
8531
|
__decorate([
|
|
8397
|
-
rewrite(rect.__updateChange)
|
|
8532
|
+
rewrite(rect$1.__updateChange)
|
|
8398
8533
|
], Box.prototype, "__updateRectChange", null);
|
|
8399
8534
|
__decorate([
|
|
8400
|
-
rewrite(rect.__render)
|
|
8535
|
+
rewrite(rect$1.__render)
|
|
8401
8536
|
], Box.prototype, "__renderRect", null);
|
|
8402
8537
|
__decorate([
|
|
8403
8538
|
rewrite(group.__render)
|
|
@@ -8639,18 +8774,10 @@ Star = __decorate([
|
|
|
8639
8774
|
|
|
8640
8775
|
let Image$1 = class Image extends Rect {
|
|
8641
8776
|
get __tag() { return 'Image'; }
|
|
8642
|
-
get ready() {
|
|
8777
|
+
get ready() { const { image } = this; return image && image.ready; }
|
|
8778
|
+
get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
|
|
8643
8779
|
constructor(data) {
|
|
8644
8780
|
super(data);
|
|
8645
|
-
this.on_(ImageEvent.LOADED, this.__onLoaded, this);
|
|
8646
|
-
}
|
|
8647
|
-
__onLoaded(e) {
|
|
8648
|
-
if (e.attrName === 'fill' && e.attrValue.url === this.url)
|
|
8649
|
-
this.image = e.image;
|
|
8650
|
-
}
|
|
8651
|
-
destroy() {
|
|
8652
|
-
this.image = null;
|
|
8653
|
-
super.destroy();
|
|
8654
8781
|
}
|
|
8655
8782
|
};
|
|
8656
8783
|
__decorate([
|
|
@@ -8666,11 +8793,11 @@ const MyImage = Image$1;
|
|
|
8666
8793
|
|
|
8667
8794
|
let Canvas = class Canvas extends Rect {
|
|
8668
8795
|
get __tag() { return 'Canvas'; }
|
|
8796
|
+
get context() { return this.canvas.context; }
|
|
8669
8797
|
get ready() { return !this.url; }
|
|
8670
8798
|
constructor(data) {
|
|
8671
8799
|
super(data);
|
|
8672
8800
|
this.canvas = Creator.canvas(this.__);
|
|
8673
|
-
this.context = this.canvas.context;
|
|
8674
8801
|
if (data && data.url)
|
|
8675
8802
|
this.drawImage(data.url);
|
|
8676
8803
|
}
|
|
@@ -8714,7 +8841,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8714
8841
|
destroy() {
|
|
8715
8842
|
if (this.canvas) {
|
|
8716
8843
|
this.canvas.destroy();
|
|
8717
|
-
this.canvas =
|
|
8844
|
+
this.canvas = null;
|
|
8718
8845
|
}
|
|
8719
8846
|
super.destroy();
|
|
8720
8847
|
}
|
|
@@ -8790,12 +8917,11 @@ let Text = class Text extends UI {
|
|
|
8790
8917
|
super.__updateBoxBounds();
|
|
8791
8918
|
if (italic)
|
|
8792
8919
|
b.width += fontSize * 0.16;
|
|
8793
|
-
|
|
8794
|
-
if (isOverflow)
|
|
8920
|
+
DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
|
|
8921
|
+
if (this.isOverflow)
|
|
8795
8922
|
setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
|
|
8796
8923
|
else
|
|
8797
8924
|
data.__textBoxBounds = b;
|
|
8798
|
-
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8799
8925
|
}
|
|
8800
8926
|
__onUpdateSize() {
|
|
8801
8927
|
if (this.__box)
|
|
@@ -9040,32 +9166,557 @@ function fillPathOrText(ui, canvas) {
|
|
|
9040
9166
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
9041
9167
|
}
|
|
9042
9168
|
|
|
9169
|
+
let App = class App extends Leafer {
|
|
9170
|
+
get __tag() { return 'App'; }
|
|
9171
|
+
get isApp() { return true; }
|
|
9172
|
+
constructor(userConfig, data) {
|
|
9173
|
+
super(userConfig, data);
|
|
9174
|
+
}
|
|
9175
|
+
init(userConfig, parentApp) {
|
|
9176
|
+
super.init(userConfig, parentApp);
|
|
9177
|
+
if (userConfig) {
|
|
9178
|
+
const { ground, tree, sky, editor } = userConfig;
|
|
9179
|
+
if (ground)
|
|
9180
|
+
this.ground = this.addLeafer(ground);
|
|
9181
|
+
if (tree || editor)
|
|
9182
|
+
this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
|
|
9183
|
+
if (sky || editor)
|
|
9184
|
+
this.sky = this.addLeafer(sky);
|
|
9185
|
+
if (editor)
|
|
9186
|
+
Creator.editor(editor, this);
|
|
9187
|
+
}
|
|
9188
|
+
}
|
|
9189
|
+
__setApp() {
|
|
9190
|
+
const { canvas } = this;
|
|
9191
|
+
const { realCanvas, view } = this.config;
|
|
9192
|
+
if (realCanvas || view === this.canvas.view || !canvas.parentView)
|
|
9193
|
+
this.realCanvas = true;
|
|
9194
|
+
else
|
|
9195
|
+
canvas.unrealCanvas();
|
|
9196
|
+
this.leafer = this;
|
|
9197
|
+
this.watcher.disable();
|
|
9198
|
+
this.layouter.disable();
|
|
9199
|
+
}
|
|
9200
|
+
__updateLocalBounds() {
|
|
9201
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9202
|
+
super.__updateLocalBounds();
|
|
9203
|
+
}
|
|
9204
|
+
start() {
|
|
9205
|
+
super.start();
|
|
9206
|
+
this.forEach(leafer => leafer.start());
|
|
9207
|
+
}
|
|
9208
|
+
stop() {
|
|
9209
|
+
this.forEach(leafer => leafer.stop());
|
|
9210
|
+
super.stop();
|
|
9211
|
+
}
|
|
9212
|
+
unlockLayout() {
|
|
9213
|
+
super.unlockLayout();
|
|
9214
|
+
this.forEach(leafer => leafer.unlockLayout());
|
|
9215
|
+
}
|
|
9216
|
+
lockLayout() {
|
|
9217
|
+
super.lockLayout();
|
|
9218
|
+
this.forEach(leafer => leafer.lockLayout());
|
|
9219
|
+
}
|
|
9220
|
+
forceRender(bounds, sync) {
|
|
9221
|
+
this.forEach(leafer => leafer.forceRender(bounds, sync));
|
|
9222
|
+
}
|
|
9223
|
+
addLeafer(merge) {
|
|
9224
|
+
const leafer = new Leafer(merge);
|
|
9225
|
+
this.add(leafer);
|
|
9226
|
+
return leafer;
|
|
9227
|
+
}
|
|
9228
|
+
add(leafer, index) {
|
|
9229
|
+
if (!leafer.view) {
|
|
9230
|
+
if (this.realCanvas && !this.canvas.bounds) {
|
|
9231
|
+
setTimeout(() => this.add(leafer, index), 10);
|
|
9232
|
+
return;
|
|
9233
|
+
}
|
|
9234
|
+
leafer.init(this.__getChildConfig(leafer.userConfig), this);
|
|
9235
|
+
}
|
|
9236
|
+
super.add(leafer, index);
|
|
9237
|
+
if (index !== undefined)
|
|
9238
|
+
leafer.canvas.childIndex = index;
|
|
9239
|
+
this.__listenChildEvents(leafer);
|
|
9240
|
+
}
|
|
9241
|
+
forEach(fn) {
|
|
9242
|
+
this.children.forEach(fn);
|
|
9243
|
+
}
|
|
9244
|
+
__onCreated() {
|
|
9245
|
+
this.created = this.children.every(child => child.created);
|
|
9246
|
+
}
|
|
9247
|
+
__onReady() {
|
|
9248
|
+
if (this.children.every(child => child.ready))
|
|
9249
|
+
super.__onReady();
|
|
9250
|
+
}
|
|
9251
|
+
__onViewReady() {
|
|
9252
|
+
if (this.children.every(child => child.viewReady))
|
|
9253
|
+
super.__onViewReady();
|
|
9254
|
+
}
|
|
9255
|
+
__onChildRenderEnd(e) {
|
|
9256
|
+
this.renderer.addBlock(e.renderBounds);
|
|
9257
|
+
if (this.viewReady)
|
|
9258
|
+
this.renderer.update();
|
|
9259
|
+
}
|
|
9260
|
+
__render(canvas, options) {
|
|
9261
|
+
if (canvas.context)
|
|
9262
|
+
this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
|
|
9263
|
+
}
|
|
9264
|
+
__onResize(event) {
|
|
9265
|
+
this.forEach(leafer => leafer.resize(event));
|
|
9266
|
+
super.__onResize(event);
|
|
9267
|
+
}
|
|
9268
|
+
updateLayout() {
|
|
9269
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9270
|
+
}
|
|
9271
|
+
__getChildConfig(userConfig) {
|
|
9272
|
+
const config = Object.assign({}, this.config);
|
|
9273
|
+
config.hittable = config.realCanvas = undefined;
|
|
9274
|
+
if (userConfig)
|
|
9275
|
+
DataHelper.assign(config, userConfig);
|
|
9276
|
+
if (this.autoLayout)
|
|
9277
|
+
DataHelper.copyAttrs(config, this, canvasSizeAttrs);
|
|
9278
|
+
config.view = this.realCanvas ? undefined : this.view;
|
|
9279
|
+
config.fill = undefined;
|
|
9280
|
+
return config;
|
|
9281
|
+
}
|
|
9282
|
+
__listenChildEvents(leafer) {
|
|
9283
|
+
leafer.once([
|
|
9284
|
+
[LayoutEvent.END, this.__onReady, this],
|
|
9285
|
+
[RenderEvent.START, this.__onCreated, this],
|
|
9286
|
+
[RenderEvent.END, this.__onViewReady, this]
|
|
9287
|
+
]);
|
|
9288
|
+
if (this.realCanvas)
|
|
9289
|
+
this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
|
|
9290
|
+
}
|
|
9291
|
+
};
|
|
9292
|
+
App = __decorate([
|
|
9293
|
+
registerUI()
|
|
9294
|
+
], App);
|
|
9295
|
+
|
|
9296
|
+
const downKeyMap = {};
|
|
9297
|
+
const Keyboard = {
|
|
9298
|
+
isHoldSpaceKey() {
|
|
9299
|
+
return Keyboard.isHold('Space');
|
|
9300
|
+
},
|
|
9301
|
+
isHold(code) {
|
|
9302
|
+
return downKeyMap[code];
|
|
9303
|
+
},
|
|
9304
|
+
setDownCode(code) {
|
|
9305
|
+
if (!downKeyMap[code])
|
|
9306
|
+
downKeyMap[code] = true;
|
|
9307
|
+
},
|
|
9308
|
+
setUpCode(code) {
|
|
9309
|
+
downKeyMap[code] = false;
|
|
9310
|
+
}
|
|
9311
|
+
};
|
|
9312
|
+
|
|
9313
|
+
const PointerButton = {
|
|
9314
|
+
LEFT: 1,
|
|
9315
|
+
RIGHT: 2,
|
|
9316
|
+
MIDDLE: 4,
|
|
9317
|
+
defaultLeft(event) { if (!event.buttons)
|
|
9318
|
+
event.buttons = 1; },
|
|
9319
|
+
left(event) { return event.buttons === 1; },
|
|
9320
|
+
right(event) { return event.buttons === 2; },
|
|
9321
|
+
middle(event) { return event.buttons === 4; }
|
|
9322
|
+
};
|
|
9323
|
+
|
|
9324
|
+
class UIEvent extends Event {
|
|
9325
|
+
get spaceKey() { return Keyboard.isHoldSpaceKey(); }
|
|
9326
|
+
get left() { return PointerButton.left(this); }
|
|
9327
|
+
get right() { return PointerButton.right(this); }
|
|
9328
|
+
get middle() { return PointerButton.middle(this); }
|
|
9329
|
+
constructor(params) {
|
|
9330
|
+
super(params.type);
|
|
9331
|
+
this.bubbles = true;
|
|
9332
|
+
Object.assign(this, params);
|
|
9333
|
+
}
|
|
9334
|
+
getBoxPoint(relative) {
|
|
9335
|
+
return (relative || this.current).getBoxPoint(this);
|
|
9336
|
+
}
|
|
9337
|
+
getInnerPoint(relative) {
|
|
9338
|
+
return (relative || this.current).getInnerPoint(this);
|
|
9339
|
+
}
|
|
9340
|
+
getLocalPoint(relative) {
|
|
9341
|
+
return (relative || this.current).getLocalPoint(this);
|
|
9342
|
+
}
|
|
9343
|
+
getPagePoint() {
|
|
9344
|
+
return this.current.getPagePoint(this);
|
|
9345
|
+
}
|
|
9346
|
+
getInner(relative) { return this.getInnerPoint(relative); }
|
|
9347
|
+
getLocal(relative) { return this.getLocalPoint(relative); }
|
|
9348
|
+
getPage() { return this.getPagePoint(); }
|
|
9349
|
+
static changeName(oldName, newName) {
|
|
9350
|
+
EventCreator.changeName(oldName, newName);
|
|
9351
|
+
}
|
|
9352
|
+
}
|
|
9353
|
+
|
|
9354
|
+
let PointerEvent$1 = class PointerEvent extends UIEvent {
|
|
9355
|
+
};
|
|
9356
|
+
PointerEvent$1.POINTER = 'pointer';
|
|
9357
|
+
PointerEvent$1.BEFORE_DOWN = 'pointer.before_down';
|
|
9358
|
+
PointerEvent$1.BEFORE_MOVE = 'pointer.before_move';
|
|
9359
|
+
PointerEvent$1.BEFORE_UP = 'pointer.before_up';
|
|
9360
|
+
PointerEvent$1.DOWN = 'pointer.down';
|
|
9361
|
+
PointerEvent$1.MOVE = 'pointer.move';
|
|
9362
|
+
PointerEvent$1.UP = 'pointer.up';
|
|
9363
|
+
PointerEvent$1.OVER = 'pointer.over';
|
|
9364
|
+
PointerEvent$1.OUT = 'pointer.out';
|
|
9365
|
+
PointerEvent$1.ENTER = 'pointer.enter';
|
|
9366
|
+
PointerEvent$1.LEAVE = 'pointer.leave';
|
|
9367
|
+
PointerEvent$1.TAP = 'tap';
|
|
9368
|
+
PointerEvent$1.DOUBLE_TAP = 'double_tap';
|
|
9369
|
+
PointerEvent$1.CLICK = 'click';
|
|
9370
|
+
PointerEvent$1.DOUBLE_CLICK = 'double_click';
|
|
9371
|
+
PointerEvent$1.LONG_PRESS = 'long_press';
|
|
9372
|
+
PointerEvent$1.LONG_TAP = 'long_tap';
|
|
9373
|
+
PointerEvent$1.MENU = 'pointer.menu';
|
|
9374
|
+
PointerEvent$1.MENU_TAP = 'pointer.menu_tap';
|
|
9375
|
+
PointerEvent$1 = __decorate([
|
|
9376
|
+
registerUIEvent()
|
|
9377
|
+
], PointerEvent$1);
|
|
9378
|
+
|
|
9379
|
+
const tempMove = {};
|
|
9380
|
+
let DragEvent$1 = class DragEvent extends PointerEvent$1 {
|
|
9381
|
+
static setList(data) {
|
|
9382
|
+
this.list = data instanceof LeafList ? data : new LeafList(data);
|
|
9383
|
+
}
|
|
9384
|
+
static setData(data) {
|
|
9385
|
+
this.data = data;
|
|
9386
|
+
}
|
|
9387
|
+
static getValidMove(leaf, start, total) {
|
|
9388
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9389
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9390
|
+
if (dragBounds)
|
|
9391
|
+
this.getMoveInDragBounds(leaf.__localBoxBounds, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9392
|
+
if (draggable === 'x')
|
|
9393
|
+
move.y = 0;
|
|
9394
|
+
if (draggable === 'y')
|
|
9395
|
+
move.x = 0;
|
|
9396
|
+
return move;
|
|
9397
|
+
}
|
|
9398
|
+
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9399
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9400
|
+
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9401
|
+
if (!change)
|
|
9402
|
+
move = Object.assign({}, move);
|
|
9403
|
+
if (BoundsHelper.includes(childBox, dragBounds)) {
|
|
9404
|
+
if (x > dragBounds.x)
|
|
9405
|
+
move.x += dragBounds.x - x;
|
|
9406
|
+
else if (right < boundsRight)
|
|
9407
|
+
move.x += boundsRight - right;
|
|
9408
|
+
if (y > dragBounds.y)
|
|
9409
|
+
move.y += dragBounds.y - y;
|
|
9410
|
+
else if (bottom < boundsBottom)
|
|
9411
|
+
move.y += boundsBottom - bottom;
|
|
9412
|
+
}
|
|
9413
|
+
else {
|
|
9414
|
+
if (x < dragBounds.x)
|
|
9415
|
+
move.x += dragBounds.x - x;
|
|
9416
|
+
else if (right > boundsRight)
|
|
9417
|
+
move.x += boundsRight - right;
|
|
9418
|
+
if (y < dragBounds.y)
|
|
9419
|
+
move.y += dragBounds.y - y;
|
|
9420
|
+
else if (bottom > boundsBottom)
|
|
9421
|
+
move.y += boundsBottom - bottom;
|
|
9422
|
+
}
|
|
9423
|
+
return move;
|
|
9424
|
+
}
|
|
9425
|
+
getPageMove(total) {
|
|
9426
|
+
this.assignMove(total);
|
|
9427
|
+
return this.current.getPagePoint(tempMove, null, true);
|
|
9428
|
+
}
|
|
9429
|
+
getInnerMove(relative, total) {
|
|
9430
|
+
if (!relative)
|
|
9431
|
+
relative = this.current;
|
|
9432
|
+
this.assignMove(total);
|
|
9433
|
+
return relative.getInnerPoint(tempMove, null, true);
|
|
9434
|
+
}
|
|
9435
|
+
getLocalMove(relative, total) {
|
|
9436
|
+
if (!relative)
|
|
9437
|
+
relative = this.current;
|
|
9438
|
+
this.assignMove(total);
|
|
9439
|
+
return relative.getLocalPoint(tempMove, null, true);
|
|
9440
|
+
}
|
|
9441
|
+
getPageTotal() {
|
|
9442
|
+
return this.getPageMove(true);
|
|
9443
|
+
}
|
|
9444
|
+
getInnerTotal(relative) {
|
|
9445
|
+
return this.getInnerMove(relative, true);
|
|
9446
|
+
}
|
|
9447
|
+
getLocalTotal(relative) {
|
|
9448
|
+
return this.getLocalMove(relative, true);
|
|
9449
|
+
}
|
|
9450
|
+
getPageBounds() {
|
|
9451
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9452
|
+
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9453
|
+
BoundsHelper.unsign(bounds);
|
|
9454
|
+
return bounds;
|
|
9455
|
+
}
|
|
9456
|
+
assignMove(total) {
|
|
9457
|
+
tempMove.x = total ? this.totalX : this.moveX;
|
|
9458
|
+
tempMove.y = total ? this.totalY : this.moveY;
|
|
9459
|
+
}
|
|
9460
|
+
};
|
|
9461
|
+
DragEvent$1.BEFORE_DRAG = 'drag.before_drag';
|
|
9462
|
+
DragEvent$1.START = 'drag.start';
|
|
9463
|
+
DragEvent$1.DRAG = 'drag';
|
|
9464
|
+
DragEvent$1.END = 'drag.end';
|
|
9465
|
+
DragEvent$1.OVER = 'drag.over';
|
|
9466
|
+
DragEvent$1.OUT = 'drag.out';
|
|
9467
|
+
DragEvent$1.ENTER = 'drag.enter';
|
|
9468
|
+
DragEvent$1.LEAVE = 'drag.leave';
|
|
9469
|
+
DragEvent$1 = __decorate([
|
|
9470
|
+
registerUIEvent()
|
|
9471
|
+
], DragEvent$1);
|
|
9472
|
+
|
|
9473
|
+
let DropEvent = class DropEvent extends PointerEvent$1 {
|
|
9474
|
+
static setList(data) {
|
|
9475
|
+
DragEvent$1.setList(data);
|
|
9476
|
+
}
|
|
9477
|
+
static setData(data) {
|
|
9478
|
+
DragEvent$1.setData(data);
|
|
9479
|
+
}
|
|
9480
|
+
};
|
|
9481
|
+
DropEvent.DROP = 'drop';
|
|
9482
|
+
DropEvent = __decorate([
|
|
9483
|
+
registerUIEvent()
|
|
9484
|
+
], DropEvent);
|
|
9485
|
+
|
|
9486
|
+
let MoveEvent = class MoveEvent extends DragEvent$1 {
|
|
9487
|
+
};
|
|
9488
|
+
MoveEvent.BEFORE_MOVE = 'move.before_move';
|
|
9489
|
+
MoveEvent.START = 'move.start';
|
|
9490
|
+
MoveEvent.MOVE = 'move';
|
|
9491
|
+
MoveEvent.END = 'move.end';
|
|
9492
|
+
MoveEvent = __decorate([
|
|
9493
|
+
registerUIEvent()
|
|
9494
|
+
], MoveEvent);
|
|
9495
|
+
|
|
9496
|
+
let RotateEvent = class RotateEvent extends PointerEvent$1 {
|
|
9497
|
+
};
|
|
9498
|
+
RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
|
|
9499
|
+
RotateEvent.START = 'rotate.start';
|
|
9500
|
+
RotateEvent.ROTATE = 'rotate';
|
|
9501
|
+
RotateEvent.END = 'rotate.end';
|
|
9502
|
+
RotateEvent = __decorate([
|
|
9503
|
+
registerUIEvent()
|
|
9504
|
+
], RotateEvent);
|
|
9505
|
+
|
|
9506
|
+
let SwipeEvent = class SwipeEvent extends DragEvent$1 {
|
|
9507
|
+
};
|
|
9508
|
+
SwipeEvent.SWIPE = 'swipe';
|
|
9509
|
+
SwipeEvent.LEFT = 'swipe.left';
|
|
9510
|
+
SwipeEvent.RIGHT = 'swipe.right';
|
|
9511
|
+
SwipeEvent.UP = 'swipe.up';
|
|
9512
|
+
SwipeEvent.DOWN = 'swipe.down';
|
|
9513
|
+
SwipeEvent = __decorate([
|
|
9514
|
+
registerUIEvent()
|
|
9515
|
+
], SwipeEvent);
|
|
9516
|
+
|
|
9517
|
+
let ZoomEvent = class ZoomEvent extends PointerEvent$1 {
|
|
9518
|
+
};
|
|
9519
|
+
ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
|
|
9520
|
+
ZoomEvent.START = 'zoom.start';
|
|
9521
|
+
ZoomEvent.ZOOM = 'zoom';
|
|
9522
|
+
ZoomEvent.END = 'zoom.end';
|
|
9523
|
+
ZoomEvent = __decorate([
|
|
9524
|
+
registerUIEvent()
|
|
9525
|
+
], ZoomEvent);
|
|
9526
|
+
|
|
9527
|
+
let KeyEvent = class KeyEvent extends UIEvent {
|
|
9528
|
+
};
|
|
9529
|
+
KeyEvent.DOWN = 'key.down';
|
|
9530
|
+
KeyEvent.HOLD = 'key.hold';
|
|
9531
|
+
KeyEvent.UP = 'key.up';
|
|
9532
|
+
KeyEvent = __decorate([
|
|
9533
|
+
registerUIEvent()
|
|
9534
|
+
], KeyEvent);
|
|
9535
|
+
|
|
9536
|
+
new LeafList();
|
|
9537
|
+
|
|
9538
|
+
Debug.get('emit');
|
|
9539
|
+
|
|
9540
|
+
const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
|
|
9541
|
+
const inner = {};
|
|
9542
|
+
const leaf = Leaf.prototype;
|
|
9543
|
+
leaf.__hitWorld = function (point) {
|
|
9544
|
+
const data = this.__;
|
|
9545
|
+
if (!data.hitSelf)
|
|
9546
|
+
return false;
|
|
9547
|
+
const world = this.__world, layout = this.__layout;
|
|
9548
|
+
const isSmall = world.width < 10 && world.height < 10;
|
|
9549
|
+
if (data.hitRadius) {
|
|
9550
|
+
copy$2(inner, point), point = inner;
|
|
9551
|
+
setRadius(point, data.hitRadius);
|
|
9552
|
+
}
|
|
9553
|
+
toInnerRadiusPointOf(point, world, inner);
|
|
9554
|
+
if (data.hitBox || isSmall) {
|
|
9555
|
+
if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
|
|
9556
|
+
return true;
|
|
9557
|
+
if (isSmall)
|
|
9558
|
+
return false;
|
|
9559
|
+
}
|
|
9560
|
+
if (layout.hitCanvasChanged || !this.__hitCanvas) {
|
|
9561
|
+
this.__updateHitCanvas();
|
|
9562
|
+
if (!layout.boundsChanged)
|
|
9563
|
+
layout.hitCanvasChanged = false;
|
|
9564
|
+
}
|
|
9565
|
+
return this.__hit(inner);
|
|
9566
|
+
};
|
|
9567
|
+
leaf.__hitFill = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, this.__.windingRule); };
|
|
9568
|
+
leaf.__hitStroke = function (inner, strokeWidth) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth); };
|
|
9569
|
+
leaf.__hitPixel = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitPixel(inner, this.__layout.renderBounds, this.__hitCanvas.hitScale); };
|
|
9570
|
+
leaf.__drawHitPath = function (canvas) { if (canvas)
|
|
9571
|
+
this.__drawRenderPath(canvas); };
|
|
9572
|
+
|
|
9573
|
+
const matrix = new Matrix();
|
|
9574
|
+
const ui$1 = UI.prototype;
|
|
9575
|
+
ui$1.__updateHitCanvas = function () {
|
|
9576
|
+
if (this.__box)
|
|
9577
|
+
this.__box.__updateHitCanvas();
|
|
9578
|
+
const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
|
|
9579
|
+
const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
9580
|
+
const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
|
|
9581
|
+
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
9582
|
+
if (!this.__hitCanvas)
|
|
9583
|
+
this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
|
|
9584
|
+
const h = this.__hitCanvas;
|
|
9585
|
+
if (isHitPixel) {
|
|
9586
|
+
const { renderBounds } = this.__layout;
|
|
9587
|
+
const size = Platform.image.hitCanvasSize;
|
|
9588
|
+
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
|
|
9589
|
+
const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
|
|
9590
|
+
h.resize({ width, height, pixelRatio: 1 });
|
|
9591
|
+
h.clear();
|
|
9592
|
+
ImageManager.patternLocked = true;
|
|
9593
|
+
this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y) }, !isHitPixelFill, !isHitPixelStroke);
|
|
9594
|
+
ImageManager.patternLocked = false;
|
|
9595
|
+
h.resetTransform();
|
|
9596
|
+
data.__isHitPixel = true;
|
|
9597
|
+
}
|
|
9598
|
+
else {
|
|
9599
|
+
data.__isHitPixel && (data.__isHitPixel = false);
|
|
9600
|
+
}
|
|
9601
|
+
this.__drawHitPath(h);
|
|
9602
|
+
h.setStrokeOptions(data);
|
|
9603
|
+
};
|
|
9604
|
+
ui$1.__hit = function (inner) {
|
|
9605
|
+
if (this.__box && this.__box.__hit(inner))
|
|
9606
|
+
return true;
|
|
9607
|
+
const data = this.__;
|
|
9608
|
+
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
9609
|
+
return true;
|
|
9610
|
+
const { hitFill } = data;
|
|
9611
|
+
const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
|
|
9612
|
+
if (needHitFillPath && this.__hitFill(inner))
|
|
9613
|
+
return true;
|
|
9614
|
+
const { hitStroke, __strokeWidth } = data;
|
|
9615
|
+
const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
|
|
9616
|
+
if (!needHitFillPath && !needHitStrokePath)
|
|
9617
|
+
return false;
|
|
9618
|
+
const radiusWidth = inner.radiusX * 2;
|
|
9619
|
+
let hitWidth = radiusWidth;
|
|
9620
|
+
if (needHitStrokePath) {
|
|
9621
|
+
switch (data.strokeAlign) {
|
|
9622
|
+
case 'inside':
|
|
9623
|
+
hitWidth += __strokeWidth * 2;
|
|
9624
|
+
if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
|
|
9625
|
+
return true;
|
|
9626
|
+
hitWidth = radiusWidth;
|
|
9627
|
+
break;
|
|
9628
|
+
case 'center':
|
|
9629
|
+
hitWidth += __strokeWidth;
|
|
9630
|
+
break;
|
|
9631
|
+
case 'outside':
|
|
9632
|
+
hitWidth += __strokeWidth * 2;
|
|
9633
|
+
if (!needHitFillPath) {
|
|
9634
|
+
if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
|
|
9635
|
+
return true;
|
|
9636
|
+
hitWidth = radiusWidth;
|
|
9637
|
+
}
|
|
9638
|
+
break;
|
|
9639
|
+
}
|
|
9640
|
+
}
|
|
9641
|
+
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
9642
|
+
};
|
|
9643
|
+
|
|
9644
|
+
const ui = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
|
|
9645
|
+
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
9646
|
+
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
9647
|
+
ui.__updateHitCanvas.call(this);
|
|
9648
|
+
else if (this.__hitCanvas)
|
|
9649
|
+
this.__hitCanvas = null;
|
|
9650
|
+
};
|
|
9651
|
+
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
9652
|
+
return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
9653
|
+
};
|
|
9654
|
+
|
|
9655
|
+
Text.prototype.__drawHitPath = function (canvas) {
|
|
9656
|
+
const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
|
|
9657
|
+
canvas.beginPath();
|
|
9658
|
+
if (__letterSpacing < 0)
|
|
9659
|
+
this.__drawPathByBox(canvas);
|
|
9660
|
+
else
|
|
9661
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
9662
|
+
};
|
|
9663
|
+
|
|
9664
|
+
function getSelector(ui) {
|
|
9665
|
+
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
9666
|
+
}
|
|
9667
|
+
Group.prototype.pick = function (hitPoint, options) {
|
|
9668
|
+
options || (options = emptyData);
|
|
9669
|
+
this.updateLayout();
|
|
9670
|
+
return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
9671
|
+
};
|
|
9672
|
+
|
|
9673
|
+
const canvas = LeaferCanvasBase.prototype;
|
|
9674
|
+
canvas.hitFill = function (point, fillRule) {
|
|
9675
|
+
return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
|
|
9676
|
+
};
|
|
9677
|
+
canvas.hitStroke = function (point, strokeWidth) {
|
|
9678
|
+
this.strokeWidth = strokeWidth;
|
|
9679
|
+
return this.context.isPointInStroke(point.x, point.y);
|
|
9680
|
+
};
|
|
9681
|
+
canvas.hitPixel = function (radiusPoint, offset, scale = 1) {
|
|
9682
|
+
let { x, y, radiusX, radiusY } = radiusPoint;
|
|
9683
|
+
if (offset)
|
|
9684
|
+
x -= offset.x, y -= offset.y;
|
|
9685
|
+
tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
|
|
9686
|
+
const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
|
|
9687
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
9688
|
+
if (data[i + 3] > 0)
|
|
9689
|
+
return true;
|
|
9690
|
+
}
|
|
9691
|
+
return data[3] > 0;
|
|
9692
|
+
};
|
|
9693
|
+
|
|
9043
9694
|
function strokeText(stroke, ui, canvas) {
|
|
9044
|
-
|
|
9045
|
-
const isStrokes = typeof stroke !== 'string';
|
|
9046
|
-
switch (strokeAlign) {
|
|
9695
|
+
switch (ui.__.strokeAlign) {
|
|
9047
9696
|
case 'center':
|
|
9048
|
-
|
|
9049
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
9697
|
+
drawCenter$1(stroke, 1, ui, canvas);
|
|
9050
9698
|
break;
|
|
9051
9699
|
case 'inside':
|
|
9052
|
-
|
|
9700
|
+
drawAlign(stroke, 'inside', ui, canvas);
|
|
9053
9701
|
break;
|
|
9054
9702
|
case 'outside':
|
|
9055
|
-
|
|
9703
|
+
ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
|
|
9056
9704
|
break;
|
|
9057
9705
|
}
|
|
9058
9706
|
}
|
|
9059
|
-
function
|
|
9060
|
-
const
|
|
9707
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
9708
|
+
const data = ui.__;
|
|
9709
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
|
|
9710
|
+
data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
9711
|
+
}
|
|
9712
|
+
function drawAlign(stroke, align, ui, canvas) {
|
|
9061
9713
|
const out = canvas.getSameCanvas(true, true);
|
|
9062
|
-
out.
|
|
9063
|
-
|
|
9064
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
|
|
9714
|
+
out.font = ui.__.__font;
|
|
9715
|
+
drawCenter$1(stroke, 2, ui, out);
|
|
9065
9716
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
9066
9717
|
fillText(ui, out);
|
|
9067
9718
|
out.blendMode = 'normal';
|
|
9068
|
-
if (ui.__worldFlipped)
|
|
9719
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
9069
9720
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9070
9721
|
else
|
|
9071
9722
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
@@ -9107,90 +9758,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
|
9107
9758
|
}
|
|
9108
9759
|
|
|
9109
9760
|
function stroke(stroke, ui, canvas) {
|
|
9110
|
-
const
|
|
9111
|
-
|
|
9112
|
-
if (!__strokeWidth)
|
|
9761
|
+
const data = ui.__;
|
|
9762
|
+
if (!data.__strokeWidth)
|
|
9113
9763
|
return;
|
|
9114
|
-
if (__font) {
|
|
9764
|
+
if (data.__font) {
|
|
9115
9765
|
strokeText(stroke, ui, canvas);
|
|
9116
9766
|
}
|
|
9117
9767
|
else {
|
|
9118
|
-
switch (strokeAlign) {
|
|
9768
|
+
switch (data.strokeAlign) {
|
|
9119
9769
|
case 'center':
|
|
9120
|
-
|
|
9121
|
-
canvas.stroke();
|
|
9122
|
-
if (options.__useArrow)
|
|
9123
|
-
strokeArrow(ui, canvas);
|
|
9770
|
+
drawCenter(stroke, 1, ui, canvas);
|
|
9124
9771
|
break;
|
|
9125
9772
|
case 'inside':
|
|
9126
|
-
canvas
|
|
9127
|
-
canvas.setStroke(stroke, __strokeWidth * 2, options);
|
|
9128
|
-
options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
|
|
9129
|
-
canvas.stroke();
|
|
9130
|
-
canvas.restore();
|
|
9773
|
+
drawInside(stroke, ui, canvas);
|
|
9131
9774
|
break;
|
|
9132
9775
|
case 'outside':
|
|
9133
|
-
|
|
9134
|
-
out.setStroke(stroke, __strokeWidth * 2, options);
|
|
9135
|
-
ui.__drawRenderPath(out);
|
|
9136
|
-
out.stroke();
|
|
9137
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
9138
|
-
out.clearWorld(ui.__layout.renderBounds);
|
|
9139
|
-
if (ui.__worldFlipped)
|
|
9140
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9141
|
-
else
|
|
9142
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
9143
|
-
out.recycle(ui.__nowWorld);
|
|
9776
|
+
drawOutside(stroke, ui, canvas);
|
|
9144
9777
|
break;
|
|
9145
9778
|
}
|
|
9146
9779
|
}
|
|
9147
9780
|
}
|
|
9148
9781
|
function strokes(strokes, ui, canvas) {
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9782
|
+
stroke(strokes, ui, canvas);
|
|
9783
|
+
}
|
|
9784
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
9785
|
+
const data = ui.__;
|
|
9786
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9787
|
+
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
9788
|
+
if (data.__useArrow)
|
|
9789
|
+
Paint.strokeArrow(stroke, ui, canvas);
|
|
9790
|
+
}
|
|
9791
|
+
function drawInside(stroke, ui, canvas) {
|
|
9792
|
+
const data = ui.__;
|
|
9793
|
+
canvas.save();
|
|
9794
|
+
data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
|
|
9795
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
9796
|
+
canvas.restore();
|
|
9797
|
+
}
|
|
9798
|
+
function drawOutside(stroke, ui, canvas) {
|
|
9799
|
+
const data = ui.__;
|
|
9800
|
+
if (data.__fillAfterStroke) {
|
|
9801
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
9155
9802
|
}
|
|
9156
9803
|
else {
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
drawStrokesStyle(strokes, false, ui, canvas);
|
|
9169
|
-
canvas.restore();
|
|
9170
|
-
break;
|
|
9171
|
-
case 'outside':
|
|
9172
|
-
const { renderBounds } = ui.__layout;
|
|
9173
|
-
const out = canvas.getSameCanvas(true, true);
|
|
9174
|
-
ui.__drawRenderPath(out);
|
|
9175
|
-
out.setStroke(undefined, __strokeWidth * 2, options);
|
|
9176
|
-
drawStrokesStyle(strokes, false, ui, out);
|
|
9177
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
9178
|
-
out.clearWorld(renderBounds);
|
|
9179
|
-
if (ui.__worldFlipped)
|
|
9180
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9181
|
-
else
|
|
9182
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
9183
|
-
out.recycle(ui.__nowWorld);
|
|
9184
|
-
break;
|
|
9185
|
-
}
|
|
9186
|
-
}
|
|
9187
|
-
}
|
|
9188
|
-
function strokeArrow(ui, canvas) {
|
|
9189
|
-
if (ui.__.dashPattern) {
|
|
9190
|
-
canvas.beginPath();
|
|
9191
|
-
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
9192
|
-
canvas.dashPattern = null;
|
|
9193
|
-
canvas.stroke();
|
|
9804
|
+
const { renderBounds } = ui.__layout;
|
|
9805
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9806
|
+
ui.__drawRenderPath(out);
|
|
9807
|
+
drawCenter(stroke, 2, ui, out);
|
|
9808
|
+
data.windingRule ? out.clip(data.windingRule) : out.clip();
|
|
9809
|
+
out.clearWorld(renderBounds);
|
|
9810
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
9811
|
+
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9812
|
+
else
|
|
9813
|
+
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
9814
|
+
out.recycle(ui.__nowWorld);
|
|
9194
9815
|
}
|
|
9195
9816
|
}
|
|
9196
9817
|
|
|
@@ -9237,9 +9858,10 @@ function shape(ui, current, options) {
|
|
|
9237
9858
|
}
|
|
9238
9859
|
|
|
9239
9860
|
let recycleMap;
|
|
9861
|
+
const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
|
|
9240
9862
|
function compute(attrName, ui) {
|
|
9241
9863
|
const data = ui.__, leafPaints = [];
|
|
9242
|
-
let paints = data.__input[attrName],
|
|
9864
|
+
let paints = data.__input[attrName], isAlphaPixel, isTransparent;
|
|
9243
9865
|
if (!(paints instanceof Array))
|
|
9244
9866
|
paints = [paints];
|
|
9245
9867
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
@@ -9249,29 +9871,55 @@ function compute(attrName, ui) {
|
|
|
9249
9871
|
leafPaints.push(item);
|
|
9250
9872
|
}
|
|
9251
9873
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
9252
|
-
if (leafPaints.length
|
|
9253
|
-
|
|
9254
|
-
|
|
9874
|
+
if (leafPaints.length) {
|
|
9875
|
+
if (leafPaints.every(item => item.isTransparent)) {
|
|
9876
|
+
if (leafPaints.some(item => item.image))
|
|
9877
|
+
isAlphaPixel = true;
|
|
9878
|
+
isTransparent = true;
|
|
9879
|
+
}
|
|
9880
|
+
}
|
|
9881
|
+
if (attrName === 'fill') {
|
|
9882
|
+
stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
|
|
9883
|
+
stintSet(data, '__isTransparentFill', isTransparent);
|
|
9884
|
+
}
|
|
9885
|
+
else {
|
|
9886
|
+
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
9887
|
+
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
9888
|
+
}
|
|
9255
9889
|
}
|
|
9256
9890
|
function getLeafPaint(attrName, paint, ui) {
|
|
9257
9891
|
if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
|
|
9258
9892
|
return undefined;
|
|
9893
|
+
let data;
|
|
9259
9894
|
const { boxBounds } = ui.__layout;
|
|
9260
9895
|
switch (paint.type) {
|
|
9261
|
-
case 'solid':
|
|
9262
|
-
let { type, blendMode, color, opacity } = paint;
|
|
9263
|
-
return { type, blendMode, style: ColorConvert.string(color, opacity) };
|
|
9264
9896
|
case 'image':
|
|
9265
|
-
|
|
9897
|
+
data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
9898
|
+
break;
|
|
9266
9899
|
case 'linear':
|
|
9267
|
-
|
|
9900
|
+
data = PaintGradient.linearGradient(paint, boxBounds);
|
|
9901
|
+
break;
|
|
9268
9902
|
case 'radial':
|
|
9269
|
-
|
|
9903
|
+
data = PaintGradient.radialGradient(paint, boxBounds);
|
|
9904
|
+
break;
|
|
9270
9905
|
case 'angular':
|
|
9271
|
-
|
|
9906
|
+
data = PaintGradient.conicGradient(paint, boxBounds);
|
|
9907
|
+
break;
|
|
9908
|
+
case 'solid':
|
|
9909
|
+
const { type, blendMode, color, opacity } = paint;
|
|
9910
|
+
data = { type, blendMode, style: ColorConvert.string(color, opacity) };
|
|
9911
|
+
break;
|
|
9272
9912
|
default:
|
|
9273
|
-
|
|
9913
|
+
if (paint.r !== undefined)
|
|
9914
|
+
data = { type: 'solid', style: ColorConvert.string(paint) };
|
|
9915
|
+
}
|
|
9916
|
+
if (data) {
|
|
9917
|
+
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
9918
|
+
data.isTransparent = true;
|
|
9919
|
+
if (paint.blendMode)
|
|
9920
|
+
data.blendMode = paint.blendMode;
|
|
9274
9921
|
}
|
|
9922
|
+
return data;
|
|
9275
9923
|
}
|
|
9276
9924
|
|
|
9277
9925
|
const PaintModule = {
|
|
@@ -9337,12 +9985,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
9337
9985
|
|
|
9338
9986
|
const { get: get$2, translate } = MatrixHelper;
|
|
9339
9987
|
const tempBox = new Bounds();
|
|
9340
|
-
const tempPoint = {};
|
|
9341
9988
|
const tempScaleData = {};
|
|
9989
|
+
const tempImage = {};
|
|
9342
9990
|
function createData(leafPaint, image, paint, box) {
|
|
9343
|
-
const {
|
|
9344
|
-
if (blendMode)
|
|
9345
|
-
leafPaint.blendMode = blendMode;
|
|
9991
|
+
const { changeful, sync } = paint;
|
|
9346
9992
|
if (changeful)
|
|
9347
9993
|
leafPaint.changeful = changeful;
|
|
9348
9994
|
if (sync)
|
|
@@ -9350,38 +9996,38 @@ function createData(leafPaint, image, paint, box) {
|
|
|
9350
9996
|
leafPaint.data = getPatternData(paint, box, image);
|
|
9351
9997
|
}
|
|
9352
9998
|
function getPatternData(paint, box, image) {
|
|
9353
|
-
let { width, height } = image;
|
|
9354
9999
|
if (paint.padding)
|
|
9355
10000
|
box = tempBox.set(box).shrink(paint.padding);
|
|
9356
10001
|
if (paint.mode === 'strench')
|
|
9357
10002
|
paint.mode = 'stretch';
|
|
10003
|
+
let { width, height } = image;
|
|
9358
10004
|
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
9359
10005
|
const sameBox = box.width === width && box.height === height;
|
|
9360
10006
|
const data = { mode };
|
|
9361
10007
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
9362
|
-
|
|
9363
|
-
let
|
|
10008
|
+
BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
|
|
10009
|
+
let scaleX, scaleY;
|
|
9364
10010
|
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
9365
10011
|
if (!sameBox || rotation) {
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
10012
|
+
scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
|
|
10013
|
+
BoundsHelper.put(box, image, align, scaleX, false, tempImage);
|
|
10014
|
+
BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
9369
10015
|
}
|
|
9370
10016
|
}
|
|
9371
|
-
else
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
10017
|
+
else {
|
|
10018
|
+
if (scale || size) {
|
|
10019
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
10020
|
+
scaleX = tempScaleData.scaleX;
|
|
10021
|
+
scaleY = tempScaleData.scaleY;
|
|
10022
|
+
}
|
|
10023
|
+
if (align) {
|
|
10024
|
+
if (scaleX)
|
|
10025
|
+
BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
10026
|
+
AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
|
|
10027
|
+
}
|
|
9382
10028
|
}
|
|
9383
10029
|
if (offset)
|
|
9384
|
-
|
|
10030
|
+
PointHelper.move(tempImage, offset);
|
|
9385
10031
|
switch (mode) {
|
|
9386
10032
|
case 'stretch':
|
|
9387
10033
|
if (!sameBox)
|
|
@@ -9389,12 +10035,12 @@ function getPatternData(paint, box, image) {
|
|
|
9389
10035
|
break;
|
|
9390
10036
|
case 'normal':
|
|
9391
10037
|
case 'clip':
|
|
9392
|
-
if (x || y || scaleX || rotation)
|
|
9393
|
-
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
10038
|
+
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
10039
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9394
10040
|
break;
|
|
9395
10041
|
case 'repeat':
|
|
9396
10042
|
if (!sameBox || scaleX || rotation)
|
|
9397
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
|
|
10043
|
+
repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
|
|
9398
10044
|
if (!repeat)
|
|
9399
10045
|
data.repeat = 'repeat';
|
|
9400
10046
|
break;
|
|
@@ -9402,7 +10048,7 @@ function getPatternData(paint, box, image) {
|
|
|
9402
10048
|
case 'cover':
|
|
9403
10049
|
default:
|
|
9404
10050
|
if (scaleX)
|
|
9405
|
-
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
10051
|
+
fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9406
10052
|
}
|
|
9407
10053
|
if (!data.transform) {
|
|
9408
10054
|
if (box.x || box.y) {
|
|
@@ -9435,6 +10081,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
9435
10081
|
}
|
|
9436
10082
|
else {
|
|
9437
10083
|
leafPaint = { type: paint.type, image };
|
|
10084
|
+
if (image.hasAlphaPixel)
|
|
10085
|
+
leafPaint.isTransparent = true;
|
|
9438
10086
|
cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
|
|
9439
10087
|
}
|
|
9440
10088
|
if (firstUse || image.loading)
|
|
@@ -9459,7 +10107,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
9459
10107
|
ignoreRender(ui, false);
|
|
9460
10108
|
if (!ui.destroyed) {
|
|
9461
10109
|
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9462
|
-
if (image.
|
|
10110
|
+
if (image.hasAlphaPixel)
|
|
9463
10111
|
ui.__layout.hitCanvasChanged = true;
|
|
9464
10112
|
ui.forceUpdate('surface');
|
|
9465
10113
|
}
|
|
@@ -9471,13 +10119,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
9471
10119
|
onLoadError(ui, event, error);
|
|
9472
10120
|
leafPaint.loadId = null;
|
|
9473
10121
|
});
|
|
9474
|
-
if (ui.placeholderColor)
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
10122
|
+
if (ui.placeholderColor) {
|
|
10123
|
+
if (!ui.placeholderDelay)
|
|
10124
|
+
image.isPlacehold = true;
|
|
10125
|
+
else
|
|
10126
|
+
setTimeout(() => {
|
|
10127
|
+
if (!image.ready) {
|
|
10128
|
+
image.isPlacehold = true;
|
|
10129
|
+
ui.forceUpdate('surface');
|
|
10130
|
+
}
|
|
10131
|
+
}, ui.placeholderDelay);
|
|
10132
|
+
}
|
|
9481
10133
|
}
|
|
9482
10134
|
return leafPaint;
|
|
9483
10135
|
}
|
|
@@ -9683,32 +10335,33 @@ const PaintImageModule = {
|
|
|
9683
10335
|
repeatMode
|
|
9684
10336
|
};
|
|
9685
10337
|
|
|
9686
|
-
const { toPoint: toPoint$2 } = AroundHelper;
|
|
10338
|
+
const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
|
|
9687
10339
|
const realFrom$2 = {};
|
|
9688
10340
|
const realTo$2 = {};
|
|
9689
10341
|
function linearGradient(paint, box) {
|
|
9690
|
-
let { from, to, type,
|
|
10342
|
+
let { from, to, type, opacity } = paint;
|
|
9691
10343
|
toPoint$2(from || 'top', box, realFrom$2);
|
|
9692
10344
|
toPoint$2(to || 'bottom', box, realTo$2);
|
|
9693
10345
|
const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
|
|
9694
|
-
applyStops(style, paint.stops, opacity);
|
|
9695
10346
|
const data = { type, style };
|
|
9696
|
-
|
|
9697
|
-
data.blendMode = blendMode;
|
|
10347
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9698
10348
|
return data;
|
|
9699
10349
|
}
|
|
9700
|
-
function applyStops(gradient, stops, opacity) {
|
|
10350
|
+
function applyStops(data, gradient, stops, opacity) {
|
|
9701
10351
|
if (stops) {
|
|
9702
|
-
let stop;
|
|
10352
|
+
let stop, color, offset, isTransparent;
|
|
9703
10353
|
for (let i = 0, len = stops.length; i < len; i++) {
|
|
9704
10354
|
stop = stops[i];
|
|
9705
|
-
if (typeof stop === 'string')
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
10355
|
+
if (typeof stop === 'string')
|
|
10356
|
+
offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
|
|
10357
|
+
else
|
|
10358
|
+
offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
|
|
10359
|
+
gradient.addColorStop(offset, color);
|
|
10360
|
+
if (!isTransparent && hasTransparent(color))
|
|
10361
|
+
isTransparent = true;
|
|
9711
10362
|
}
|
|
10363
|
+
if (isTransparent)
|
|
10364
|
+
data.isTransparent = true;
|
|
9712
10365
|
}
|
|
9713
10366
|
}
|
|
9714
10367
|
|
|
@@ -9718,17 +10371,15 @@ const { toPoint: toPoint$1 } = AroundHelper;
|
|
|
9718
10371
|
const realFrom$1 = {};
|
|
9719
10372
|
const realTo$1 = {};
|
|
9720
10373
|
function radialGradient(paint, box) {
|
|
9721
|
-
let { from, to, type, opacity,
|
|
10374
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
9722
10375
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
9723
10376
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
9724
10377
|
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
9725
|
-
applyStops(style, paint.stops, opacity);
|
|
9726
10378
|
const data = { type, style };
|
|
10379
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9727
10380
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
9728
10381
|
if (transform)
|
|
9729
10382
|
data.transform = transform;
|
|
9730
|
-
if (blendMode)
|
|
9731
|
-
data.blendMode = blendMode;
|
|
9732
10383
|
return data;
|
|
9733
10384
|
}
|
|
9734
10385
|
function getTransform(box, from, to, stretch, rotate90) {
|
|
@@ -9754,17 +10405,15 @@ const { toPoint } = AroundHelper;
|
|
|
9754
10405
|
const realFrom = {};
|
|
9755
10406
|
const realTo = {};
|
|
9756
10407
|
function conicGradient(paint, box) {
|
|
9757
|
-
let { from, to, type, opacity,
|
|
10408
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
9758
10409
|
toPoint(from || 'center', box, realFrom);
|
|
9759
10410
|
toPoint(to || 'bottom', box, realTo);
|
|
9760
10411
|
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
9761
|
-
applyStops(style, paint.stops, opacity);
|
|
9762
10412
|
const data = { type, style };
|
|
10413
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9763
10414
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
9764
10415
|
if (transform)
|
|
9765
10416
|
data.transform = transform;
|
|
9766
|
-
if (blendMode)
|
|
9767
|
-
data.blendMode = blendMode;
|
|
9768
10417
|
return data;
|
|
9769
10418
|
}
|
|
9770
10419
|
|
|
@@ -10097,6 +10746,8 @@ function createRows(drawData, content, style) {
|
|
|
10097
10746
|
lastCharType = null;
|
|
10098
10747
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
10099
10748
|
word = { data: [] }, row = { words: [] };
|
|
10749
|
+
if (__letterSpacing)
|
|
10750
|
+
content = [...content];
|
|
10100
10751
|
for (let i = 0, len = content.length; i < len; i++) {
|
|
10101
10752
|
char = content[i];
|
|
10102
10753
|
if (char === '\n') {
|
|
@@ -10510,4 +11161,4 @@ Object.assign(Effect, EffectModule);
|
|
|
10510
11161
|
|
|
10511
11162
|
useCanvas();
|
|
10512
11163
|
|
|
10513
|
-
export { AlignHelper, 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, Eventer, Export, FileHelper, Filter, 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, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$
|
|
11164
|
+
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, 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, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$2 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|