@leafer-draw/worker 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/worker.cjs +172 -172
- package/dist/worker.esm.js +175 -175
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +1101 -449
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +1100 -449
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/worker.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$d = 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$b = 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$9 = 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$8 = 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
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6148
6236
|
get allowBackgroundColor() { return true; }
|
|
@@ -6301,17 +6389,15 @@ class Watcher {
|
|
|
6301
6389
|
this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
|
|
6302
6390
|
this.__updatedList = new LeafList();
|
|
6303
6391
|
this.totalTimes++;
|
|
6304
|
-
this.changed = false;
|
|
6305
|
-
this.hasVisible = false;
|
|
6306
|
-
this.hasRemove = false;
|
|
6307
|
-
this.hasAdd = false;
|
|
6392
|
+
this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
|
|
6308
6393
|
}
|
|
6309
6394
|
__listenEvents() {
|
|
6310
|
-
const { target } = this;
|
|
6311
6395
|
this.__eventIds = [
|
|
6312
|
-
target.on_(
|
|
6313
|
-
|
|
6314
|
-
|
|
6396
|
+
this.target.on_([
|
|
6397
|
+
[PropertyEvent.CHANGE, this.__onAttrChange, this],
|
|
6398
|
+
[[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
|
|
6399
|
+
[WatchEvent.REQUEST, this.__onRquestData, this]
|
|
6400
|
+
])
|
|
6315
6401
|
];
|
|
6316
6402
|
}
|
|
6317
6403
|
__removeListenEvents() {
|
|
@@ -6321,8 +6407,7 @@ class Watcher {
|
|
|
6321
6407
|
if (this.target) {
|
|
6322
6408
|
this.stop();
|
|
6323
6409
|
this.__removeListenEvents();
|
|
6324
|
-
this.target = null;
|
|
6325
|
-
this.__updatedList = null;
|
|
6410
|
+
this.target = this.__updatedList = null;
|
|
6326
6411
|
}
|
|
6327
6412
|
}
|
|
6328
6413
|
}
|
|
@@ -6427,7 +6512,7 @@ class Layouter {
|
|
|
6427
6512
|
this.disabled = true;
|
|
6428
6513
|
}
|
|
6429
6514
|
layout() {
|
|
6430
|
-
if (!this.running)
|
|
6515
|
+
if (this.layouting || !this.running)
|
|
6431
6516
|
return;
|
|
6432
6517
|
const { target } = this;
|
|
6433
6518
|
this.times = 0;
|
|
@@ -6510,12 +6595,10 @@ class Layouter {
|
|
|
6510
6595
|
}
|
|
6511
6596
|
static fullLayout(target) {
|
|
6512
6597
|
updateAllMatrix(target, true);
|
|
6513
|
-
if (target.isBranch)
|
|
6598
|
+
if (target.isBranch)
|
|
6514
6599
|
BranchHelper.updateBounds(target);
|
|
6515
|
-
|
|
6516
|
-
else {
|
|
6600
|
+
else
|
|
6517
6601
|
LeafHelper.updateBounds(target);
|
|
6518
|
-
}
|
|
6519
6602
|
updateAllChange(target);
|
|
6520
6603
|
}
|
|
6521
6604
|
addExtra(leaf) {
|
|
@@ -6538,11 +6621,12 @@ class Layouter {
|
|
|
6538
6621
|
this.__updatedList = event.data.updatedList;
|
|
6539
6622
|
}
|
|
6540
6623
|
__listenEvents() {
|
|
6541
|
-
const { target } = this;
|
|
6542
6624
|
this.__eventIds = [
|
|
6543
|
-
target.on_(
|
|
6544
|
-
|
|
6545
|
-
|
|
6625
|
+
this.target.on_([
|
|
6626
|
+
[LayoutEvent.REQUEST, this.layout, this],
|
|
6627
|
+
[LayoutEvent.AGAIN, this.layoutAgain, this],
|
|
6628
|
+
[WatchEvent.DATA, this.__onReceiveWatchData, this]
|
|
6629
|
+
])
|
|
6546
6630
|
];
|
|
6547
6631
|
}
|
|
6548
6632
|
__removeListenEvents() {
|
|
@@ -6773,12 +6857,13 @@ class Renderer {
|
|
|
6773
6857
|
this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
|
|
6774
6858
|
}
|
|
6775
6859
|
__listenEvents() {
|
|
6776
|
-
const { target } = this;
|
|
6777
6860
|
this.__eventIds = [
|
|
6778
|
-
target.on_(
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6861
|
+
this.target.on_([
|
|
6862
|
+
[RenderEvent.REQUEST, this.update, this],
|
|
6863
|
+
[LayoutEvent.END, this.__onLayoutEnd, this],
|
|
6864
|
+
[RenderEvent.AGAIN, this.renderAgain, this],
|
|
6865
|
+
[ResizeEvent.RESIZE, this.__onResize, this]
|
|
6866
|
+
])
|
|
6782
6867
|
];
|
|
6783
6868
|
}
|
|
6784
6869
|
__removeListenEvents() {
|
|
@@ -6837,8 +6922,32 @@ function zoomLayerType() {
|
|
|
6837
6922
|
};
|
|
6838
6923
|
}
|
|
6839
6924
|
|
|
6925
|
+
function hasTransparent$3(color) {
|
|
6926
|
+
if (!color || color.length === 7 || color.length === 4)
|
|
6927
|
+
return false;
|
|
6928
|
+
if (color === 'transparent')
|
|
6929
|
+
return true;
|
|
6930
|
+
const first = color[0];
|
|
6931
|
+
if (first === '#') {
|
|
6932
|
+
switch (color.length) {
|
|
6933
|
+
case 5: return color[4] !== 'f' && color[4] !== 'F';
|
|
6934
|
+
case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
|
|
6935
|
+
}
|
|
6936
|
+
}
|
|
6937
|
+
else if (first === 'r' || first === 'h') {
|
|
6938
|
+
if (color[3] === 'a') {
|
|
6939
|
+
const i = color.lastIndexOf(',');
|
|
6940
|
+
if (i > -1)
|
|
6941
|
+
return parseFloat(color.slice(i + 1)) < 1;
|
|
6942
|
+
}
|
|
6943
|
+
}
|
|
6944
|
+
return false;
|
|
6945
|
+
}
|
|
6946
|
+
|
|
6840
6947
|
const TextConvert = {};
|
|
6841
|
-
const ColorConvert = {
|
|
6948
|
+
const ColorConvert = {
|
|
6949
|
+
hasTransparent: hasTransparent$3
|
|
6950
|
+
};
|
|
6842
6951
|
const UnitConvert = {
|
|
6843
6952
|
number(value, percentRefer) {
|
|
6844
6953
|
return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
|
|
@@ -6864,6 +6973,7 @@ const Transition = {
|
|
|
6864
6973
|
};
|
|
6865
6974
|
|
|
6866
6975
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6976
|
+
const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
|
|
6867
6977
|
const emptyPaint = {};
|
|
6868
6978
|
const debug$1 = Debug.get('UIData');
|
|
6869
6979
|
class UIData extends LeafData {
|
|
@@ -6922,38 +7032,22 @@ class UIData extends LeafData {
|
|
|
6922
7032
|
if (this.__naturalWidth)
|
|
6923
7033
|
this.__removeNaturalSize();
|
|
6924
7034
|
if (typeof value === 'string' || !value) {
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
PaintImage.recycleImage('fill', this);
|
|
6928
|
-
this.__isFills = false;
|
|
6929
|
-
this.__pixelFill && (this.__pixelFill = false);
|
|
6930
|
-
}
|
|
7035
|
+
stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
|
|
7036
|
+
this.__isFills && this.__removePaint('fill', true);
|
|
6931
7037
|
this._fill = value;
|
|
6932
7038
|
}
|
|
6933
7039
|
else if (typeof value === 'object') {
|
|
6934
|
-
this.
|
|
6935
|
-
const layout = this.__leaf.__layout;
|
|
6936
|
-
layout.boxChanged || layout.boxChange();
|
|
6937
|
-
this.__isFills = true;
|
|
6938
|
-
this._fill || (this._fill = emptyPaint);
|
|
7040
|
+
this.__setPaint('fill', value);
|
|
6939
7041
|
}
|
|
6940
7042
|
}
|
|
6941
7043
|
setStroke(value) {
|
|
6942
7044
|
if (typeof value === 'string' || !value) {
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
PaintImage.recycleImage('stroke', this);
|
|
6946
|
-
this.__isStrokes = false;
|
|
6947
|
-
this.__pixelStroke && (this.__pixelStroke = false);
|
|
6948
|
-
}
|
|
7045
|
+
stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
|
|
7046
|
+
this.__isStrokes && this.__removePaint('stroke', true);
|
|
6949
7047
|
this._stroke = value;
|
|
6950
7048
|
}
|
|
6951
7049
|
else if (typeof value === 'object') {
|
|
6952
|
-
this.
|
|
6953
|
-
const layout = this.__leaf.__layout;
|
|
6954
|
-
layout.boxChanged || layout.boxChange();
|
|
6955
|
-
this.__isStrokes = true;
|
|
6956
|
-
this._stroke || (this._stroke = emptyPaint);
|
|
7050
|
+
this.__setPaint('stroke', value);
|
|
6957
7051
|
}
|
|
6958
7052
|
}
|
|
6959
7053
|
setPath(value) {
|
|
@@ -6983,7 +7077,34 @@ class UIData extends LeafData {
|
|
|
6983
7077
|
Paint.compute('fill', this.__leaf);
|
|
6984
7078
|
if (stroke)
|
|
6985
7079
|
Paint.compute('stroke', this.__leaf);
|
|
6986
|
-
this.__needComputePaint =
|
|
7080
|
+
this.__needComputePaint = undefined;
|
|
7081
|
+
}
|
|
7082
|
+
__setPaint(attrName, value) {
|
|
7083
|
+
this.__setInput(attrName, value);
|
|
7084
|
+
const layout = this.__leaf.__layout;
|
|
7085
|
+
layout.boxChanged || layout.boxChange();
|
|
7086
|
+
if (value instanceof Array && !value.length) {
|
|
7087
|
+
this.__removePaint(attrName);
|
|
7088
|
+
}
|
|
7089
|
+
else {
|
|
7090
|
+
if (attrName === 'fill')
|
|
7091
|
+
this.__isFills = true, this._fill || (this._fill = emptyPaint);
|
|
7092
|
+
else
|
|
7093
|
+
this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
|
|
7094
|
+
}
|
|
7095
|
+
}
|
|
7096
|
+
__removePaint(attrName, removeInput) {
|
|
7097
|
+
if (removeInput)
|
|
7098
|
+
this.__removeInput(attrName);
|
|
7099
|
+
PaintImage.recycleImage(attrName, this);
|
|
7100
|
+
if (attrName === 'fill') {
|
|
7101
|
+
stintSet$2(this, '__isAlphaPixelFill', undefined);
|
|
7102
|
+
this._fill = this.__isFills = undefined;
|
|
7103
|
+
}
|
|
7104
|
+
else {
|
|
7105
|
+
stintSet$2(this, '__isAlphaPixelStroke', undefined);
|
|
7106
|
+
this._stroke = this.__isStrokes = undefined;
|
|
7107
|
+
}
|
|
6987
7108
|
}
|
|
6988
7109
|
}
|
|
6989
7110
|
function setArray(data, key, value) {
|
|
@@ -6991,10 +7112,10 @@ function setArray(data, key, value) {
|
|
|
6991
7112
|
if (value instanceof Array) {
|
|
6992
7113
|
if (value.some((item) => item.visible === false))
|
|
6993
7114
|
value = value.filter((item) => item.visible !== false);
|
|
6994
|
-
value.length || (value =
|
|
7115
|
+
value.length || (value = undefined);
|
|
6995
7116
|
}
|
|
6996
7117
|
else
|
|
6997
|
-
value = value && value.visible !== false ? [value] :
|
|
7118
|
+
value = value && value.visible !== false ? [value] : undefined;
|
|
6998
7119
|
data['_' + key] = value;
|
|
6999
7120
|
}
|
|
7000
7121
|
|
|
@@ -7097,8 +7218,6 @@ class ImageData extends RectData {
|
|
|
7097
7218
|
this._url = value;
|
|
7098
7219
|
}
|
|
7099
7220
|
__setImageFill(value) {
|
|
7100
|
-
if (this.__leaf.image)
|
|
7101
|
-
this.__leaf.image = null;
|
|
7102
7221
|
this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
|
|
7103
7222
|
}
|
|
7104
7223
|
__getData() {
|
|
@@ -7164,21 +7283,19 @@ const UIBounds = {
|
|
|
7164
7283
|
}
|
|
7165
7284
|
};
|
|
7166
7285
|
|
|
7286
|
+
const { stintSet: stintSet$1 } = DataHelper;
|
|
7167
7287
|
const UIRender = {
|
|
7168
7288
|
__updateChange() {
|
|
7169
|
-
const data = this.__
|
|
7289
|
+
const data = this.__;
|
|
7170
7290
|
if (data.__useEffect) {
|
|
7171
|
-
const { shadow,
|
|
7172
|
-
data.
|
|
7291
|
+
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7292
|
+
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')));
|
|
7293
|
+
data.__useEffect = !!(shadow || otherEffect);
|
|
7173
7294
|
}
|
|
7174
|
-
|
|
7175
|
-
|
|
7295
|
+
stintSet$1(this.__world, 'half', data.__hasHalf);
|
|
7296
|
+
stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7176
7297
|
data.__checkSingle();
|
|
7177
|
-
|
|
7178
|
-
if (complex)
|
|
7179
|
-
data.__complex = true;
|
|
7180
|
-
else
|
|
7181
|
-
data.__complex && (data.__complex = false);
|
|
7298
|
+
stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7182
7299
|
},
|
|
7183
7300
|
__drawFast(canvas, options) {
|
|
7184
7301
|
drawFast(this, canvas, options);
|
|
@@ -7188,21 +7305,23 @@ const UIRender = {
|
|
|
7188
7305
|
if (data.__complex) {
|
|
7189
7306
|
if (data.__needComputePaint)
|
|
7190
7307
|
data.__computePaint();
|
|
7191
|
-
const { fill, stroke, __drawAfterFill } = data;
|
|
7308
|
+
const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
|
|
7192
7309
|
this.__drawRenderPath(canvas);
|
|
7193
|
-
if (data.__useEffect) {
|
|
7310
|
+
if (data.__useEffect && !__isFastShadow) {
|
|
7194
7311
|
const shape = Paint.shape(this, canvas, options);
|
|
7195
7312
|
this.__nowWorld = this.__getNowWorld(options);
|
|
7196
7313
|
const { shadow, innerShadow, filter } = data;
|
|
7197
7314
|
if (shadow)
|
|
7198
7315
|
Effect.shadow(this, canvas, shape);
|
|
7316
|
+
if (__fillAfterStroke)
|
|
7317
|
+
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7199
7318
|
if (fill)
|
|
7200
7319
|
data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7201
7320
|
if (__drawAfterFill)
|
|
7202
7321
|
this.__drawAfterFill(canvas, options);
|
|
7203
7322
|
if (innerShadow)
|
|
7204
7323
|
Effect.innerShadow(this, canvas, shape);
|
|
7205
|
-
if (stroke)
|
|
7324
|
+
if (stroke && !__fillAfterStroke)
|
|
7206
7325
|
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7207
7326
|
if (filter)
|
|
7208
7327
|
Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
@@ -7211,21 +7330,27 @@ const UIRender = {
|
|
|
7211
7330
|
shape.canvas.recycle();
|
|
7212
7331
|
}
|
|
7213
7332
|
else {
|
|
7333
|
+
if (__fillAfterStroke)
|
|
7334
|
+
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7335
|
+
if (__isFastShadow) {
|
|
7336
|
+
const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
|
|
7337
|
+
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
7338
|
+
}
|
|
7214
7339
|
if (fill)
|
|
7215
7340
|
data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7341
|
+
if (__isFastShadow)
|
|
7342
|
+
canvas.restore();
|
|
7216
7343
|
if (__drawAfterFill)
|
|
7217
7344
|
this.__drawAfterFill(canvas, options);
|
|
7218
|
-
if (stroke)
|
|
7345
|
+
if (stroke && !__fillAfterStroke)
|
|
7219
7346
|
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7220
7347
|
}
|
|
7221
7348
|
}
|
|
7222
7349
|
else {
|
|
7223
|
-
if (data.__pathInputed)
|
|
7350
|
+
if (data.__pathInputed)
|
|
7224
7351
|
drawFast(this, canvas, options);
|
|
7225
|
-
|
|
7226
|
-
else {
|
|
7352
|
+
else
|
|
7227
7353
|
this.__drawFast(canvas, options);
|
|
7228
|
-
}
|
|
7229
7354
|
}
|
|
7230
7355
|
},
|
|
7231
7356
|
__renderShape(canvas, options, ignoreFill, ignoreStroke) {
|
|
@@ -7234,11 +7359,11 @@ const UIRender = {
|
|
|
7234
7359
|
const { fill, stroke } = this.__;
|
|
7235
7360
|
this.__drawRenderPath(canvas);
|
|
7236
7361
|
if (fill && !ignoreFill)
|
|
7237
|
-
this.__.
|
|
7362
|
+
this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
7238
7363
|
if (this.__.__isCanvas)
|
|
7239
7364
|
this.__drawAfterFill(canvas, options);
|
|
7240
7365
|
if (stroke && !ignoreStroke)
|
|
7241
|
-
this.__.
|
|
7366
|
+
this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7242
7367
|
}
|
|
7243
7368
|
},
|
|
7244
7369
|
__drawAfterFill(canvas, options) {
|
|
@@ -7253,13 +7378,15 @@ const UIRender = {
|
|
|
7253
7378
|
}
|
|
7254
7379
|
};
|
|
7255
7380
|
function drawFast(ui, canvas, options) {
|
|
7256
|
-
const { fill, stroke, __drawAfterFill } = ui.__;
|
|
7381
|
+
const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
|
|
7257
7382
|
ui.__drawRenderPath(canvas);
|
|
7383
|
+
if (__fillAfterStroke)
|
|
7384
|
+
Paint.stroke(stroke, ui, canvas);
|
|
7258
7385
|
if (fill)
|
|
7259
7386
|
Paint.fill(fill, ui, canvas);
|
|
7260
7387
|
if (__drawAfterFill)
|
|
7261
7388
|
ui.__drawAfterFill(canvas, options);
|
|
7262
|
-
if (stroke)
|
|
7389
|
+
if (stroke && !__fillAfterStroke)
|
|
7263
7390
|
Paint.stroke(stroke, ui, canvas);
|
|
7264
7391
|
}
|
|
7265
7392
|
|
|
@@ -7631,6 +7758,9 @@ __decorate([
|
|
|
7631
7758
|
__decorate([
|
|
7632
7759
|
surfaceType()
|
|
7633
7760
|
], UI.prototype, "placeholderColor", void 0);
|
|
7761
|
+
__decorate([
|
|
7762
|
+
dataType(100)
|
|
7763
|
+
], UI.prototype, "placeholderDelay", void 0);
|
|
7634
7764
|
__decorate([
|
|
7635
7765
|
dataType({})
|
|
7636
7766
|
], UI.prototype, "data", void 0);
|
|
@@ -8032,15 +8162,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8032
8162
|
}
|
|
8033
8163
|
__listenEvents() {
|
|
8034
8164
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
8035
|
-
this.once(
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8165
|
+
this.once([
|
|
8166
|
+
[LeaferEvent.START, () => Run.end(runId)],
|
|
8167
|
+
[LayoutEvent.START, this.updateLazyBounds, this],
|
|
8168
|
+
[RenderEvent.START, this.__onCreated, this],
|
|
8169
|
+
[RenderEvent.END, this.__onViewReady, this]
|
|
8170
|
+
]);
|
|
8171
|
+
this.__eventIds.push(this.on_([
|
|
8172
|
+
[WatchEvent.DATA, this.__onWatchData, this],
|
|
8173
|
+
[LayoutEvent.END, this.__onLayoutEnd, this],
|
|
8174
|
+
[RenderEvent.NEXT, this.__onNextRender, this]
|
|
8175
|
+
]));
|
|
8040
8176
|
}
|
|
8041
8177
|
__removeListenEvents() {
|
|
8042
8178
|
this.off_(this.__eventIds);
|
|
8043
|
-
this.__eventIds.length = 0;
|
|
8044
8179
|
}
|
|
8045
8180
|
destroy(sync) {
|
|
8046
8181
|
const doDestory = () => {
|
|
@@ -8100,8 +8235,8 @@ Rect = __decorate([
|
|
|
8100
8235
|
registerUI()
|
|
8101
8236
|
], Rect);
|
|
8102
8237
|
|
|
8103
|
-
const { copy: copy$
|
|
8104
|
-
const rect = Rect.prototype, group = Group.prototype;
|
|
8238
|
+
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8239
|
+
const rect$1 = Rect.prototype, group = Group.prototype;
|
|
8105
8240
|
const childrenRenderBounds = {};
|
|
8106
8241
|
let Box = class Box extends Group {
|
|
8107
8242
|
get __tag() { return 'Box'; }
|
|
@@ -8146,15 +8281,15 @@ let Box = class Box extends Group {
|
|
|
8146
8281
|
const { renderBounds } = this.__layout;
|
|
8147
8282
|
if (this.children.length) {
|
|
8148
8283
|
super.__updateRenderBounds();
|
|
8149
|
-
copy$
|
|
8284
|
+
copy$3(childrenRenderBounds, renderBounds);
|
|
8150
8285
|
this.__updateRectRenderBounds();
|
|
8151
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds)
|
|
8286
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds);
|
|
8152
8287
|
if (isOverflow && this.__.overflow !== 'hide')
|
|
8153
8288
|
add(renderBounds, childrenRenderBounds);
|
|
8154
8289
|
}
|
|
8155
8290
|
else
|
|
8156
8291
|
this.__updateRectRenderBounds();
|
|
8157
|
-
|
|
8292
|
+
DataHelper.stintSet(this, 'isOverflow', isOverflow);
|
|
8158
8293
|
}
|
|
8159
8294
|
__updateRectRenderBounds() { }
|
|
8160
8295
|
__updateRectChange() { }
|
|
@@ -8198,25 +8333,25 @@ __decorate([
|
|
|
8198
8333
|
affectRenderBoundsType('show')
|
|
8199
8334
|
], Box.prototype, "overflow", void 0);
|
|
8200
8335
|
__decorate([
|
|
8201
|
-
rewrite(rect.__updateStrokeSpread)
|
|
8336
|
+
rewrite(rect$1.__updateStrokeSpread)
|
|
8202
8337
|
], Box.prototype, "__updateStrokeSpread", null);
|
|
8203
8338
|
__decorate([
|
|
8204
|
-
rewrite(rect.__updateRenderSpread)
|
|
8339
|
+
rewrite(rect$1.__updateRenderSpread)
|
|
8205
8340
|
], Box.prototype, "__updateRectRenderSpread", null);
|
|
8206
8341
|
__decorate([
|
|
8207
|
-
rewrite(rect.__updateBoxBounds)
|
|
8342
|
+
rewrite(rect$1.__updateBoxBounds)
|
|
8208
8343
|
], Box.prototype, "__updateRectBoxBounds", null);
|
|
8209
8344
|
__decorate([
|
|
8210
|
-
rewrite(rect.__updateStrokeBounds)
|
|
8345
|
+
rewrite(rect$1.__updateStrokeBounds)
|
|
8211
8346
|
], Box.prototype, "__updateStrokeBounds", null);
|
|
8212
8347
|
__decorate([
|
|
8213
|
-
rewrite(rect.__updateRenderBounds)
|
|
8348
|
+
rewrite(rect$1.__updateRenderBounds)
|
|
8214
8349
|
], Box.prototype, "__updateRectRenderBounds", null);
|
|
8215
8350
|
__decorate([
|
|
8216
|
-
rewrite(rect.__updateChange)
|
|
8351
|
+
rewrite(rect$1.__updateChange)
|
|
8217
8352
|
], Box.prototype, "__updateRectChange", null);
|
|
8218
8353
|
__decorate([
|
|
8219
|
-
rewrite(rect.__render)
|
|
8354
|
+
rewrite(rect$1.__render)
|
|
8220
8355
|
], Box.prototype, "__renderRect", null);
|
|
8221
8356
|
__decorate([
|
|
8222
8357
|
rewrite(group.__render)
|
|
@@ -8458,18 +8593,10 @@ Star = __decorate([
|
|
|
8458
8593
|
|
|
8459
8594
|
let Image = class Image extends Rect {
|
|
8460
8595
|
get __tag() { return 'Image'; }
|
|
8461
|
-
get ready() {
|
|
8596
|
+
get ready() { const { image } = this; return image && image.ready; }
|
|
8597
|
+
get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
|
|
8462
8598
|
constructor(data) {
|
|
8463
8599
|
super(data);
|
|
8464
|
-
this.on_(ImageEvent.LOADED, this.__onLoaded, this);
|
|
8465
|
-
}
|
|
8466
|
-
__onLoaded(e) {
|
|
8467
|
-
if (e.attrName === 'fill' && e.attrValue.url === this.url)
|
|
8468
|
-
this.image = e.image;
|
|
8469
|
-
}
|
|
8470
|
-
destroy() {
|
|
8471
|
-
this.image = null;
|
|
8472
|
-
super.destroy();
|
|
8473
8600
|
}
|
|
8474
8601
|
};
|
|
8475
8602
|
__decorate([
|
|
@@ -8485,11 +8612,11 @@ const MyImage = Image;
|
|
|
8485
8612
|
|
|
8486
8613
|
let Canvas = class Canvas extends Rect {
|
|
8487
8614
|
get __tag() { return 'Canvas'; }
|
|
8615
|
+
get context() { return this.canvas.context; }
|
|
8488
8616
|
get ready() { return !this.url; }
|
|
8489
8617
|
constructor(data) {
|
|
8490
8618
|
super(data);
|
|
8491
8619
|
this.canvas = Creator.canvas(this.__);
|
|
8492
|
-
this.context = this.canvas.context;
|
|
8493
8620
|
if (data && data.url)
|
|
8494
8621
|
this.drawImage(data.url);
|
|
8495
8622
|
}
|
|
@@ -8533,7 +8660,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8533
8660
|
destroy() {
|
|
8534
8661
|
if (this.canvas) {
|
|
8535
8662
|
this.canvas.destroy();
|
|
8536
|
-
this.canvas =
|
|
8663
|
+
this.canvas = null;
|
|
8537
8664
|
}
|
|
8538
8665
|
super.destroy();
|
|
8539
8666
|
}
|
|
@@ -8609,12 +8736,11 @@ let Text = class Text extends UI {
|
|
|
8609
8736
|
super.__updateBoxBounds();
|
|
8610
8737
|
if (italic)
|
|
8611
8738
|
b.width += fontSize * 0.16;
|
|
8612
|
-
|
|
8613
|
-
if (isOverflow)
|
|
8739
|
+
DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
|
|
8740
|
+
if (this.isOverflow)
|
|
8614
8741
|
setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
|
|
8615
8742
|
else
|
|
8616
8743
|
data.__textBoxBounds = b;
|
|
8617
|
-
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8618
8744
|
}
|
|
8619
8745
|
__onUpdateSize() {
|
|
8620
8746
|
if (this.__box)
|
|
@@ -8859,32 +8985,557 @@ function fillPathOrText(ui, canvas) {
|
|
|
8859
8985
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
8860
8986
|
}
|
|
8861
8987
|
|
|
8988
|
+
let App = class App extends Leafer {
|
|
8989
|
+
get __tag() { return 'App'; }
|
|
8990
|
+
get isApp() { return true; }
|
|
8991
|
+
constructor(userConfig, data) {
|
|
8992
|
+
super(userConfig, data);
|
|
8993
|
+
}
|
|
8994
|
+
init(userConfig, parentApp) {
|
|
8995
|
+
super.init(userConfig, parentApp);
|
|
8996
|
+
if (userConfig) {
|
|
8997
|
+
const { ground, tree, sky, editor } = userConfig;
|
|
8998
|
+
if (ground)
|
|
8999
|
+
this.ground = this.addLeafer(ground);
|
|
9000
|
+
if (tree || editor)
|
|
9001
|
+
this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
|
|
9002
|
+
if (sky || editor)
|
|
9003
|
+
this.sky = this.addLeafer(sky);
|
|
9004
|
+
if (editor)
|
|
9005
|
+
Creator.editor(editor, this);
|
|
9006
|
+
}
|
|
9007
|
+
}
|
|
9008
|
+
__setApp() {
|
|
9009
|
+
const { canvas } = this;
|
|
9010
|
+
const { realCanvas, view } = this.config;
|
|
9011
|
+
if (realCanvas || view === this.canvas.view || !canvas.parentView)
|
|
9012
|
+
this.realCanvas = true;
|
|
9013
|
+
else
|
|
9014
|
+
canvas.unrealCanvas();
|
|
9015
|
+
this.leafer = this;
|
|
9016
|
+
this.watcher.disable();
|
|
9017
|
+
this.layouter.disable();
|
|
9018
|
+
}
|
|
9019
|
+
__updateLocalBounds() {
|
|
9020
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9021
|
+
super.__updateLocalBounds();
|
|
9022
|
+
}
|
|
9023
|
+
start() {
|
|
9024
|
+
super.start();
|
|
9025
|
+
this.forEach(leafer => leafer.start());
|
|
9026
|
+
}
|
|
9027
|
+
stop() {
|
|
9028
|
+
this.forEach(leafer => leafer.stop());
|
|
9029
|
+
super.stop();
|
|
9030
|
+
}
|
|
9031
|
+
unlockLayout() {
|
|
9032
|
+
super.unlockLayout();
|
|
9033
|
+
this.forEach(leafer => leafer.unlockLayout());
|
|
9034
|
+
}
|
|
9035
|
+
lockLayout() {
|
|
9036
|
+
super.lockLayout();
|
|
9037
|
+
this.forEach(leafer => leafer.lockLayout());
|
|
9038
|
+
}
|
|
9039
|
+
forceRender(bounds, sync) {
|
|
9040
|
+
this.forEach(leafer => leafer.forceRender(bounds, sync));
|
|
9041
|
+
}
|
|
9042
|
+
addLeafer(merge) {
|
|
9043
|
+
const leafer = new Leafer(merge);
|
|
9044
|
+
this.add(leafer);
|
|
9045
|
+
return leafer;
|
|
9046
|
+
}
|
|
9047
|
+
add(leafer, index) {
|
|
9048
|
+
if (!leafer.view) {
|
|
9049
|
+
if (this.realCanvas && !this.canvas.bounds) {
|
|
9050
|
+
setTimeout(() => this.add(leafer, index), 10);
|
|
9051
|
+
return;
|
|
9052
|
+
}
|
|
9053
|
+
leafer.init(this.__getChildConfig(leafer.userConfig), this);
|
|
9054
|
+
}
|
|
9055
|
+
super.add(leafer, index);
|
|
9056
|
+
if (index !== undefined)
|
|
9057
|
+
leafer.canvas.childIndex = index;
|
|
9058
|
+
this.__listenChildEvents(leafer);
|
|
9059
|
+
}
|
|
9060
|
+
forEach(fn) {
|
|
9061
|
+
this.children.forEach(fn);
|
|
9062
|
+
}
|
|
9063
|
+
__onCreated() {
|
|
9064
|
+
this.created = this.children.every(child => child.created);
|
|
9065
|
+
}
|
|
9066
|
+
__onReady() {
|
|
9067
|
+
if (this.children.every(child => child.ready))
|
|
9068
|
+
super.__onReady();
|
|
9069
|
+
}
|
|
9070
|
+
__onViewReady() {
|
|
9071
|
+
if (this.children.every(child => child.viewReady))
|
|
9072
|
+
super.__onViewReady();
|
|
9073
|
+
}
|
|
9074
|
+
__onChildRenderEnd(e) {
|
|
9075
|
+
this.renderer.addBlock(e.renderBounds);
|
|
9076
|
+
if (this.viewReady)
|
|
9077
|
+
this.renderer.update();
|
|
9078
|
+
}
|
|
9079
|
+
__render(canvas, options) {
|
|
9080
|
+
if (canvas.context)
|
|
9081
|
+
this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
|
|
9082
|
+
}
|
|
9083
|
+
__onResize(event) {
|
|
9084
|
+
this.forEach(leafer => leafer.resize(event));
|
|
9085
|
+
super.__onResize(event);
|
|
9086
|
+
}
|
|
9087
|
+
updateLayout() {
|
|
9088
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9089
|
+
}
|
|
9090
|
+
__getChildConfig(userConfig) {
|
|
9091
|
+
const config = Object.assign({}, this.config);
|
|
9092
|
+
config.hittable = config.realCanvas = undefined;
|
|
9093
|
+
if (userConfig)
|
|
9094
|
+
DataHelper.assign(config, userConfig);
|
|
9095
|
+
if (this.autoLayout)
|
|
9096
|
+
DataHelper.copyAttrs(config, this, canvasSizeAttrs);
|
|
9097
|
+
config.view = this.realCanvas ? undefined : this.view;
|
|
9098
|
+
config.fill = undefined;
|
|
9099
|
+
return config;
|
|
9100
|
+
}
|
|
9101
|
+
__listenChildEvents(leafer) {
|
|
9102
|
+
leafer.once([
|
|
9103
|
+
[LayoutEvent.END, this.__onReady, this],
|
|
9104
|
+
[RenderEvent.START, this.__onCreated, this],
|
|
9105
|
+
[RenderEvent.END, this.__onViewReady, this]
|
|
9106
|
+
]);
|
|
9107
|
+
if (this.realCanvas)
|
|
9108
|
+
this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
|
|
9109
|
+
}
|
|
9110
|
+
};
|
|
9111
|
+
App = __decorate([
|
|
9112
|
+
registerUI()
|
|
9113
|
+
], App);
|
|
9114
|
+
|
|
9115
|
+
const downKeyMap = {};
|
|
9116
|
+
const Keyboard = {
|
|
9117
|
+
isHoldSpaceKey() {
|
|
9118
|
+
return Keyboard.isHold('Space');
|
|
9119
|
+
},
|
|
9120
|
+
isHold(code) {
|
|
9121
|
+
return downKeyMap[code];
|
|
9122
|
+
},
|
|
9123
|
+
setDownCode(code) {
|
|
9124
|
+
if (!downKeyMap[code])
|
|
9125
|
+
downKeyMap[code] = true;
|
|
9126
|
+
},
|
|
9127
|
+
setUpCode(code) {
|
|
9128
|
+
downKeyMap[code] = false;
|
|
9129
|
+
}
|
|
9130
|
+
};
|
|
9131
|
+
|
|
9132
|
+
const PointerButton = {
|
|
9133
|
+
LEFT: 1,
|
|
9134
|
+
RIGHT: 2,
|
|
9135
|
+
MIDDLE: 4,
|
|
9136
|
+
defaultLeft(event) { if (!event.buttons)
|
|
9137
|
+
event.buttons = 1; },
|
|
9138
|
+
left(event) { return event.buttons === 1; },
|
|
9139
|
+
right(event) { return event.buttons === 2; },
|
|
9140
|
+
middle(event) { return event.buttons === 4; }
|
|
9141
|
+
};
|
|
9142
|
+
|
|
9143
|
+
class UIEvent extends Event {
|
|
9144
|
+
get spaceKey() { return Keyboard.isHoldSpaceKey(); }
|
|
9145
|
+
get left() { return PointerButton.left(this); }
|
|
9146
|
+
get right() { return PointerButton.right(this); }
|
|
9147
|
+
get middle() { return PointerButton.middle(this); }
|
|
9148
|
+
constructor(params) {
|
|
9149
|
+
super(params.type);
|
|
9150
|
+
this.bubbles = true;
|
|
9151
|
+
Object.assign(this, params);
|
|
9152
|
+
}
|
|
9153
|
+
getBoxPoint(relative) {
|
|
9154
|
+
return (relative || this.current).getBoxPoint(this);
|
|
9155
|
+
}
|
|
9156
|
+
getInnerPoint(relative) {
|
|
9157
|
+
return (relative || this.current).getInnerPoint(this);
|
|
9158
|
+
}
|
|
9159
|
+
getLocalPoint(relative) {
|
|
9160
|
+
return (relative || this.current).getLocalPoint(this);
|
|
9161
|
+
}
|
|
9162
|
+
getPagePoint() {
|
|
9163
|
+
return this.current.getPagePoint(this);
|
|
9164
|
+
}
|
|
9165
|
+
getInner(relative) { return this.getInnerPoint(relative); }
|
|
9166
|
+
getLocal(relative) { return this.getLocalPoint(relative); }
|
|
9167
|
+
getPage() { return this.getPagePoint(); }
|
|
9168
|
+
static changeName(oldName, newName) {
|
|
9169
|
+
EventCreator.changeName(oldName, newName);
|
|
9170
|
+
}
|
|
9171
|
+
}
|
|
9172
|
+
|
|
9173
|
+
let PointerEvent = class PointerEvent extends UIEvent {
|
|
9174
|
+
};
|
|
9175
|
+
PointerEvent.POINTER = 'pointer';
|
|
9176
|
+
PointerEvent.BEFORE_DOWN = 'pointer.before_down';
|
|
9177
|
+
PointerEvent.BEFORE_MOVE = 'pointer.before_move';
|
|
9178
|
+
PointerEvent.BEFORE_UP = 'pointer.before_up';
|
|
9179
|
+
PointerEvent.DOWN = 'pointer.down';
|
|
9180
|
+
PointerEvent.MOVE = 'pointer.move';
|
|
9181
|
+
PointerEvent.UP = 'pointer.up';
|
|
9182
|
+
PointerEvent.OVER = 'pointer.over';
|
|
9183
|
+
PointerEvent.OUT = 'pointer.out';
|
|
9184
|
+
PointerEvent.ENTER = 'pointer.enter';
|
|
9185
|
+
PointerEvent.LEAVE = 'pointer.leave';
|
|
9186
|
+
PointerEvent.TAP = 'tap';
|
|
9187
|
+
PointerEvent.DOUBLE_TAP = 'double_tap';
|
|
9188
|
+
PointerEvent.CLICK = 'click';
|
|
9189
|
+
PointerEvent.DOUBLE_CLICK = 'double_click';
|
|
9190
|
+
PointerEvent.LONG_PRESS = 'long_press';
|
|
9191
|
+
PointerEvent.LONG_TAP = 'long_tap';
|
|
9192
|
+
PointerEvent.MENU = 'pointer.menu';
|
|
9193
|
+
PointerEvent.MENU_TAP = 'pointer.menu_tap';
|
|
9194
|
+
PointerEvent = __decorate([
|
|
9195
|
+
registerUIEvent()
|
|
9196
|
+
], PointerEvent);
|
|
9197
|
+
|
|
9198
|
+
const tempMove = {};
|
|
9199
|
+
let DragEvent = class DragEvent extends PointerEvent {
|
|
9200
|
+
static setList(data) {
|
|
9201
|
+
this.list = data instanceof LeafList ? data : new LeafList(data);
|
|
9202
|
+
}
|
|
9203
|
+
static setData(data) {
|
|
9204
|
+
this.data = data;
|
|
9205
|
+
}
|
|
9206
|
+
static getValidMove(leaf, start, total) {
|
|
9207
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9208
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9209
|
+
if (dragBounds)
|
|
9210
|
+
this.getMoveInDragBounds(leaf.__localBoxBounds, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9211
|
+
if (draggable === 'x')
|
|
9212
|
+
move.y = 0;
|
|
9213
|
+
if (draggable === 'y')
|
|
9214
|
+
move.x = 0;
|
|
9215
|
+
return move;
|
|
9216
|
+
}
|
|
9217
|
+
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9218
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9219
|
+
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9220
|
+
if (!change)
|
|
9221
|
+
move = Object.assign({}, move);
|
|
9222
|
+
if (BoundsHelper.includes(childBox, dragBounds)) {
|
|
9223
|
+
if (x > dragBounds.x)
|
|
9224
|
+
move.x += dragBounds.x - x;
|
|
9225
|
+
else if (right < boundsRight)
|
|
9226
|
+
move.x += boundsRight - right;
|
|
9227
|
+
if (y > dragBounds.y)
|
|
9228
|
+
move.y += dragBounds.y - y;
|
|
9229
|
+
else if (bottom < boundsBottom)
|
|
9230
|
+
move.y += boundsBottom - bottom;
|
|
9231
|
+
}
|
|
9232
|
+
else {
|
|
9233
|
+
if (x < dragBounds.x)
|
|
9234
|
+
move.x += dragBounds.x - x;
|
|
9235
|
+
else if (right > boundsRight)
|
|
9236
|
+
move.x += boundsRight - right;
|
|
9237
|
+
if (y < dragBounds.y)
|
|
9238
|
+
move.y += dragBounds.y - y;
|
|
9239
|
+
else if (bottom > boundsBottom)
|
|
9240
|
+
move.y += boundsBottom - bottom;
|
|
9241
|
+
}
|
|
9242
|
+
return move;
|
|
9243
|
+
}
|
|
9244
|
+
getPageMove(total) {
|
|
9245
|
+
this.assignMove(total);
|
|
9246
|
+
return this.current.getPagePoint(tempMove, null, true);
|
|
9247
|
+
}
|
|
9248
|
+
getInnerMove(relative, total) {
|
|
9249
|
+
if (!relative)
|
|
9250
|
+
relative = this.current;
|
|
9251
|
+
this.assignMove(total);
|
|
9252
|
+
return relative.getInnerPoint(tempMove, null, true);
|
|
9253
|
+
}
|
|
9254
|
+
getLocalMove(relative, total) {
|
|
9255
|
+
if (!relative)
|
|
9256
|
+
relative = this.current;
|
|
9257
|
+
this.assignMove(total);
|
|
9258
|
+
return relative.getLocalPoint(tempMove, null, true);
|
|
9259
|
+
}
|
|
9260
|
+
getPageTotal() {
|
|
9261
|
+
return this.getPageMove(true);
|
|
9262
|
+
}
|
|
9263
|
+
getInnerTotal(relative) {
|
|
9264
|
+
return this.getInnerMove(relative, true);
|
|
9265
|
+
}
|
|
9266
|
+
getLocalTotal(relative) {
|
|
9267
|
+
return this.getLocalMove(relative, true);
|
|
9268
|
+
}
|
|
9269
|
+
getPageBounds() {
|
|
9270
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9271
|
+
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9272
|
+
BoundsHelper.unsign(bounds);
|
|
9273
|
+
return bounds;
|
|
9274
|
+
}
|
|
9275
|
+
assignMove(total) {
|
|
9276
|
+
tempMove.x = total ? this.totalX : this.moveX;
|
|
9277
|
+
tempMove.y = total ? this.totalY : this.moveY;
|
|
9278
|
+
}
|
|
9279
|
+
};
|
|
9280
|
+
DragEvent.BEFORE_DRAG = 'drag.before_drag';
|
|
9281
|
+
DragEvent.START = 'drag.start';
|
|
9282
|
+
DragEvent.DRAG = 'drag';
|
|
9283
|
+
DragEvent.END = 'drag.end';
|
|
9284
|
+
DragEvent.OVER = 'drag.over';
|
|
9285
|
+
DragEvent.OUT = 'drag.out';
|
|
9286
|
+
DragEvent.ENTER = 'drag.enter';
|
|
9287
|
+
DragEvent.LEAVE = 'drag.leave';
|
|
9288
|
+
DragEvent = __decorate([
|
|
9289
|
+
registerUIEvent()
|
|
9290
|
+
], DragEvent);
|
|
9291
|
+
|
|
9292
|
+
let DropEvent = class DropEvent extends PointerEvent {
|
|
9293
|
+
static setList(data) {
|
|
9294
|
+
DragEvent.setList(data);
|
|
9295
|
+
}
|
|
9296
|
+
static setData(data) {
|
|
9297
|
+
DragEvent.setData(data);
|
|
9298
|
+
}
|
|
9299
|
+
};
|
|
9300
|
+
DropEvent.DROP = 'drop';
|
|
9301
|
+
DropEvent = __decorate([
|
|
9302
|
+
registerUIEvent()
|
|
9303
|
+
], DropEvent);
|
|
9304
|
+
|
|
9305
|
+
let MoveEvent = class MoveEvent extends DragEvent {
|
|
9306
|
+
};
|
|
9307
|
+
MoveEvent.BEFORE_MOVE = 'move.before_move';
|
|
9308
|
+
MoveEvent.START = 'move.start';
|
|
9309
|
+
MoveEvent.MOVE = 'move';
|
|
9310
|
+
MoveEvent.END = 'move.end';
|
|
9311
|
+
MoveEvent = __decorate([
|
|
9312
|
+
registerUIEvent()
|
|
9313
|
+
], MoveEvent);
|
|
9314
|
+
|
|
9315
|
+
let RotateEvent = class RotateEvent extends PointerEvent {
|
|
9316
|
+
};
|
|
9317
|
+
RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
|
|
9318
|
+
RotateEvent.START = 'rotate.start';
|
|
9319
|
+
RotateEvent.ROTATE = 'rotate';
|
|
9320
|
+
RotateEvent.END = 'rotate.end';
|
|
9321
|
+
RotateEvent = __decorate([
|
|
9322
|
+
registerUIEvent()
|
|
9323
|
+
], RotateEvent);
|
|
9324
|
+
|
|
9325
|
+
let SwipeEvent = class SwipeEvent extends DragEvent {
|
|
9326
|
+
};
|
|
9327
|
+
SwipeEvent.SWIPE = 'swipe';
|
|
9328
|
+
SwipeEvent.LEFT = 'swipe.left';
|
|
9329
|
+
SwipeEvent.RIGHT = 'swipe.right';
|
|
9330
|
+
SwipeEvent.UP = 'swipe.up';
|
|
9331
|
+
SwipeEvent.DOWN = 'swipe.down';
|
|
9332
|
+
SwipeEvent = __decorate([
|
|
9333
|
+
registerUIEvent()
|
|
9334
|
+
], SwipeEvent);
|
|
9335
|
+
|
|
9336
|
+
let ZoomEvent = class ZoomEvent extends PointerEvent {
|
|
9337
|
+
};
|
|
9338
|
+
ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
|
|
9339
|
+
ZoomEvent.START = 'zoom.start';
|
|
9340
|
+
ZoomEvent.ZOOM = 'zoom';
|
|
9341
|
+
ZoomEvent.END = 'zoom.end';
|
|
9342
|
+
ZoomEvent = __decorate([
|
|
9343
|
+
registerUIEvent()
|
|
9344
|
+
], ZoomEvent);
|
|
9345
|
+
|
|
9346
|
+
let KeyEvent = class KeyEvent extends UIEvent {
|
|
9347
|
+
};
|
|
9348
|
+
KeyEvent.DOWN = 'key.down';
|
|
9349
|
+
KeyEvent.HOLD = 'key.hold';
|
|
9350
|
+
KeyEvent.UP = 'key.up';
|
|
9351
|
+
KeyEvent = __decorate([
|
|
9352
|
+
registerUIEvent()
|
|
9353
|
+
], KeyEvent);
|
|
9354
|
+
|
|
9355
|
+
new LeafList();
|
|
9356
|
+
|
|
9357
|
+
Debug.get('emit');
|
|
9358
|
+
|
|
9359
|
+
const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
|
|
9360
|
+
const inner = {};
|
|
9361
|
+
const leaf = Leaf.prototype;
|
|
9362
|
+
leaf.__hitWorld = function (point) {
|
|
9363
|
+
const data = this.__;
|
|
9364
|
+
if (!data.hitSelf)
|
|
9365
|
+
return false;
|
|
9366
|
+
const world = this.__world, layout = this.__layout;
|
|
9367
|
+
const isSmall = world.width < 10 && world.height < 10;
|
|
9368
|
+
if (data.hitRadius) {
|
|
9369
|
+
copy$2(inner, point), point = inner;
|
|
9370
|
+
setRadius(point, data.hitRadius);
|
|
9371
|
+
}
|
|
9372
|
+
toInnerRadiusPointOf(point, world, inner);
|
|
9373
|
+
if (data.hitBox || isSmall) {
|
|
9374
|
+
if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
|
|
9375
|
+
return true;
|
|
9376
|
+
if (isSmall)
|
|
9377
|
+
return false;
|
|
9378
|
+
}
|
|
9379
|
+
if (layout.hitCanvasChanged || !this.__hitCanvas) {
|
|
9380
|
+
this.__updateHitCanvas();
|
|
9381
|
+
if (!layout.boundsChanged)
|
|
9382
|
+
layout.hitCanvasChanged = false;
|
|
9383
|
+
}
|
|
9384
|
+
return this.__hit(inner);
|
|
9385
|
+
};
|
|
9386
|
+
leaf.__hitFill = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, this.__.windingRule); };
|
|
9387
|
+
leaf.__hitStroke = function (inner, strokeWidth) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth); };
|
|
9388
|
+
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); };
|
|
9389
|
+
leaf.__drawHitPath = function (canvas) { if (canvas)
|
|
9390
|
+
this.__drawRenderPath(canvas); };
|
|
9391
|
+
|
|
9392
|
+
const matrix = new Matrix();
|
|
9393
|
+
const ui$1 = UI.prototype;
|
|
9394
|
+
ui$1.__updateHitCanvas = function () {
|
|
9395
|
+
if (this.__box)
|
|
9396
|
+
this.__box.__updateHitCanvas();
|
|
9397
|
+
const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
|
|
9398
|
+
const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
9399
|
+
const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
|
|
9400
|
+
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
9401
|
+
if (!this.__hitCanvas)
|
|
9402
|
+
this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
|
|
9403
|
+
const h = this.__hitCanvas;
|
|
9404
|
+
if (isHitPixel) {
|
|
9405
|
+
const { renderBounds } = this.__layout;
|
|
9406
|
+
const size = Platform.image.hitCanvasSize;
|
|
9407
|
+
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
|
|
9408
|
+
const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
|
|
9409
|
+
h.resize({ width, height, pixelRatio: 1 });
|
|
9410
|
+
h.clear();
|
|
9411
|
+
ImageManager.patternLocked = true;
|
|
9412
|
+
this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y) }, !isHitPixelFill, !isHitPixelStroke);
|
|
9413
|
+
ImageManager.patternLocked = false;
|
|
9414
|
+
h.resetTransform();
|
|
9415
|
+
data.__isHitPixel = true;
|
|
9416
|
+
}
|
|
9417
|
+
else {
|
|
9418
|
+
data.__isHitPixel && (data.__isHitPixel = false);
|
|
9419
|
+
}
|
|
9420
|
+
this.__drawHitPath(h);
|
|
9421
|
+
h.setStrokeOptions(data);
|
|
9422
|
+
};
|
|
9423
|
+
ui$1.__hit = function (inner) {
|
|
9424
|
+
if (this.__box && this.__box.__hit(inner))
|
|
9425
|
+
return true;
|
|
9426
|
+
const data = this.__;
|
|
9427
|
+
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
9428
|
+
return true;
|
|
9429
|
+
const { hitFill } = data;
|
|
9430
|
+
const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
|
|
9431
|
+
if (needHitFillPath && this.__hitFill(inner))
|
|
9432
|
+
return true;
|
|
9433
|
+
const { hitStroke, __strokeWidth } = data;
|
|
9434
|
+
const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
|
|
9435
|
+
if (!needHitFillPath && !needHitStrokePath)
|
|
9436
|
+
return false;
|
|
9437
|
+
const radiusWidth = inner.radiusX * 2;
|
|
9438
|
+
let hitWidth = radiusWidth;
|
|
9439
|
+
if (needHitStrokePath) {
|
|
9440
|
+
switch (data.strokeAlign) {
|
|
9441
|
+
case 'inside':
|
|
9442
|
+
hitWidth += __strokeWidth * 2;
|
|
9443
|
+
if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
|
|
9444
|
+
return true;
|
|
9445
|
+
hitWidth = radiusWidth;
|
|
9446
|
+
break;
|
|
9447
|
+
case 'center':
|
|
9448
|
+
hitWidth += __strokeWidth;
|
|
9449
|
+
break;
|
|
9450
|
+
case 'outside':
|
|
9451
|
+
hitWidth += __strokeWidth * 2;
|
|
9452
|
+
if (!needHitFillPath) {
|
|
9453
|
+
if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
|
|
9454
|
+
return true;
|
|
9455
|
+
hitWidth = radiusWidth;
|
|
9456
|
+
}
|
|
9457
|
+
break;
|
|
9458
|
+
}
|
|
9459
|
+
}
|
|
9460
|
+
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
9461
|
+
};
|
|
9462
|
+
|
|
9463
|
+
const ui = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
|
|
9464
|
+
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
9465
|
+
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
9466
|
+
ui.__updateHitCanvas.call(this);
|
|
9467
|
+
else if (this.__hitCanvas)
|
|
9468
|
+
this.__hitCanvas = null;
|
|
9469
|
+
};
|
|
9470
|
+
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
9471
|
+
return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
9472
|
+
};
|
|
9473
|
+
|
|
9474
|
+
Text.prototype.__drawHitPath = function (canvas) {
|
|
9475
|
+
const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
|
|
9476
|
+
canvas.beginPath();
|
|
9477
|
+
if (__letterSpacing < 0)
|
|
9478
|
+
this.__drawPathByBox(canvas);
|
|
9479
|
+
else
|
|
9480
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
9481
|
+
};
|
|
9482
|
+
|
|
9483
|
+
function getSelector(ui) {
|
|
9484
|
+
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
9485
|
+
}
|
|
9486
|
+
Group.prototype.pick = function (hitPoint, options) {
|
|
9487
|
+
options || (options = emptyData);
|
|
9488
|
+
this.updateLayout();
|
|
9489
|
+
return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
9490
|
+
};
|
|
9491
|
+
|
|
9492
|
+
const canvas = LeaferCanvasBase.prototype;
|
|
9493
|
+
canvas.hitFill = function (point, fillRule) {
|
|
9494
|
+
return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
|
|
9495
|
+
};
|
|
9496
|
+
canvas.hitStroke = function (point, strokeWidth) {
|
|
9497
|
+
this.strokeWidth = strokeWidth;
|
|
9498
|
+
return this.context.isPointInStroke(point.x, point.y);
|
|
9499
|
+
};
|
|
9500
|
+
canvas.hitPixel = function (radiusPoint, offset, scale = 1) {
|
|
9501
|
+
let { x, y, radiusX, radiusY } = radiusPoint;
|
|
9502
|
+
if (offset)
|
|
9503
|
+
x -= offset.x, y -= offset.y;
|
|
9504
|
+
tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
|
|
9505
|
+
const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
|
|
9506
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
9507
|
+
if (data[i + 3] > 0)
|
|
9508
|
+
return true;
|
|
9509
|
+
}
|
|
9510
|
+
return data[3] > 0;
|
|
9511
|
+
};
|
|
9512
|
+
|
|
8862
9513
|
function strokeText(stroke, ui, canvas) {
|
|
8863
|
-
|
|
8864
|
-
const isStrokes = typeof stroke !== 'string';
|
|
8865
|
-
switch (strokeAlign) {
|
|
9514
|
+
switch (ui.__.strokeAlign) {
|
|
8866
9515
|
case 'center':
|
|
8867
|
-
|
|
8868
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
9516
|
+
drawCenter$1(stroke, 1, ui, canvas);
|
|
8869
9517
|
break;
|
|
8870
9518
|
case 'inside':
|
|
8871
|
-
|
|
9519
|
+
drawAlign(stroke, 'inside', ui, canvas);
|
|
8872
9520
|
break;
|
|
8873
9521
|
case 'outside':
|
|
8874
|
-
|
|
9522
|
+
ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
|
|
8875
9523
|
break;
|
|
8876
9524
|
}
|
|
8877
9525
|
}
|
|
8878
|
-
function
|
|
8879
|
-
const
|
|
9526
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
9527
|
+
const data = ui.__;
|
|
9528
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
|
|
9529
|
+
data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
9530
|
+
}
|
|
9531
|
+
function drawAlign(stroke, align, ui, canvas) {
|
|
8880
9532
|
const out = canvas.getSameCanvas(true, true);
|
|
8881
|
-
out.
|
|
8882
|
-
|
|
8883
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
|
|
9533
|
+
out.font = ui.__.__font;
|
|
9534
|
+
drawCenter$1(stroke, 2, ui, out);
|
|
8884
9535
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
8885
9536
|
fillText(ui, out);
|
|
8886
9537
|
out.blendMode = 'normal';
|
|
8887
|
-
if (ui.__worldFlipped)
|
|
9538
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
8888
9539
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
8889
9540
|
else
|
|
8890
9541
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
@@ -8926,90 +9577,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
|
8926
9577
|
}
|
|
8927
9578
|
|
|
8928
9579
|
function stroke(stroke, ui, canvas) {
|
|
8929
|
-
const
|
|
8930
|
-
|
|
8931
|
-
if (!__strokeWidth)
|
|
9580
|
+
const data = ui.__;
|
|
9581
|
+
if (!data.__strokeWidth)
|
|
8932
9582
|
return;
|
|
8933
|
-
if (__font) {
|
|
9583
|
+
if (data.__font) {
|
|
8934
9584
|
strokeText(stroke, ui, canvas);
|
|
8935
9585
|
}
|
|
8936
9586
|
else {
|
|
8937
|
-
switch (strokeAlign) {
|
|
9587
|
+
switch (data.strokeAlign) {
|
|
8938
9588
|
case 'center':
|
|
8939
|
-
|
|
8940
|
-
canvas.stroke();
|
|
8941
|
-
if (options.__useArrow)
|
|
8942
|
-
strokeArrow(ui, canvas);
|
|
9589
|
+
drawCenter(stroke, 1, ui, canvas);
|
|
8943
9590
|
break;
|
|
8944
9591
|
case 'inside':
|
|
8945
|
-
canvas
|
|
8946
|
-
canvas.setStroke(stroke, __strokeWidth * 2, options);
|
|
8947
|
-
options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
|
|
8948
|
-
canvas.stroke();
|
|
8949
|
-
canvas.restore();
|
|
9592
|
+
drawInside(stroke, ui, canvas);
|
|
8950
9593
|
break;
|
|
8951
9594
|
case 'outside':
|
|
8952
|
-
|
|
8953
|
-
out.setStroke(stroke, __strokeWidth * 2, options);
|
|
8954
|
-
ui.__drawRenderPath(out);
|
|
8955
|
-
out.stroke();
|
|
8956
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
8957
|
-
out.clearWorld(ui.__layout.renderBounds);
|
|
8958
|
-
if (ui.__worldFlipped)
|
|
8959
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
8960
|
-
else
|
|
8961
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
8962
|
-
out.recycle(ui.__nowWorld);
|
|
9595
|
+
drawOutside(stroke, ui, canvas);
|
|
8963
9596
|
break;
|
|
8964
9597
|
}
|
|
8965
9598
|
}
|
|
8966
9599
|
}
|
|
8967
9600
|
function strokes(strokes, ui, canvas) {
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
9601
|
+
stroke(strokes, ui, canvas);
|
|
9602
|
+
}
|
|
9603
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
9604
|
+
const data = ui.__;
|
|
9605
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9606
|
+
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
9607
|
+
if (data.__useArrow)
|
|
9608
|
+
Paint.strokeArrow(stroke, ui, canvas);
|
|
9609
|
+
}
|
|
9610
|
+
function drawInside(stroke, ui, canvas) {
|
|
9611
|
+
const data = ui.__;
|
|
9612
|
+
canvas.save();
|
|
9613
|
+
data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
|
|
9614
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
9615
|
+
canvas.restore();
|
|
9616
|
+
}
|
|
9617
|
+
function drawOutside(stroke, ui, canvas) {
|
|
9618
|
+
const data = ui.__;
|
|
9619
|
+
if (data.__fillAfterStroke) {
|
|
9620
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
8974
9621
|
}
|
|
8975
9622
|
else {
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
drawStrokesStyle(strokes, false, ui, canvas);
|
|
8988
|
-
canvas.restore();
|
|
8989
|
-
break;
|
|
8990
|
-
case 'outside':
|
|
8991
|
-
const { renderBounds } = ui.__layout;
|
|
8992
|
-
const out = canvas.getSameCanvas(true, true);
|
|
8993
|
-
ui.__drawRenderPath(out);
|
|
8994
|
-
out.setStroke(undefined, __strokeWidth * 2, options);
|
|
8995
|
-
drawStrokesStyle(strokes, false, ui, out);
|
|
8996
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
8997
|
-
out.clearWorld(renderBounds);
|
|
8998
|
-
if (ui.__worldFlipped)
|
|
8999
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9000
|
-
else
|
|
9001
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
9002
|
-
out.recycle(ui.__nowWorld);
|
|
9003
|
-
break;
|
|
9004
|
-
}
|
|
9005
|
-
}
|
|
9006
|
-
}
|
|
9007
|
-
function strokeArrow(ui, canvas) {
|
|
9008
|
-
if (ui.__.dashPattern) {
|
|
9009
|
-
canvas.beginPath();
|
|
9010
|
-
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
9011
|
-
canvas.dashPattern = null;
|
|
9012
|
-
canvas.stroke();
|
|
9623
|
+
const { renderBounds } = ui.__layout;
|
|
9624
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9625
|
+
ui.__drawRenderPath(out);
|
|
9626
|
+
drawCenter(stroke, 2, ui, out);
|
|
9627
|
+
data.windingRule ? out.clip(data.windingRule) : out.clip();
|
|
9628
|
+
out.clearWorld(renderBounds);
|
|
9629
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
9630
|
+
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9631
|
+
else
|
|
9632
|
+
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
9633
|
+
out.recycle(ui.__nowWorld);
|
|
9013
9634
|
}
|
|
9014
9635
|
}
|
|
9015
9636
|
|
|
@@ -9056,9 +9677,10 @@ function shape(ui, current, options) {
|
|
|
9056
9677
|
}
|
|
9057
9678
|
|
|
9058
9679
|
let recycleMap;
|
|
9680
|
+
const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
|
|
9059
9681
|
function compute(attrName, ui) {
|
|
9060
9682
|
const data = ui.__, leafPaints = [];
|
|
9061
|
-
let paints = data.__input[attrName],
|
|
9683
|
+
let paints = data.__input[attrName], isAlphaPixel, isTransparent;
|
|
9062
9684
|
if (!(paints instanceof Array))
|
|
9063
9685
|
paints = [paints];
|
|
9064
9686
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
@@ -9068,29 +9690,55 @@ function compute(attrName, ui) {
|
|
|
9068
9690
|
leafPaints.push(item);
|
|
9069
9691
|
}
|
|
9070
9692
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
9071
|
-
if (leafPaints.length
|
|
9072
|
-
|
|
9073
|
-
|
|
9693
|
+
if (leafPaints.length) {
|
|
9694
|
+
if (leafPaints.every(item => item.isTransparent)) {
|
|
9695
|
+
if (leafPaints.some(item => item.image))
|
|
9696
|
+
isAlphaPixel = true;
|
|
9697
|
+
isTransparent = true;
|
|
9698
|
+
}
|
|
9699
|
+
}
|
|
9700
|
+
if (attrName === 'fill') {
|
|
9701
|
+
stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
|
|
9702
|
+
stintSet(data, '__isTransparentFill', isTransparent);
|
|
9703
|
+
}
|
|
9704
|
+
else {
|
|
9705
|
+
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
9706
|
+
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
9707
|
+
}
|
|
9074
9708
|
}
|
|
9075
9709
|
function getLeafPaint(attrName, paint, ui) {
|
|
9076
9710
|
if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
|
|
9077
9711
|
return undefined;
|
|
9712
|
+
let data;
|
|
9078
9713
|
const { boxBounds } = ui.__layout;
|
|
9079
9714
|
switch (paint.type) {
|
|
9080
|
-
case 'solid':
|
|
9081
|
-
let { type, blendMode, color, opacity } = paint;
|
|
9082
|
-
return { type, blendMode, style: ColorConvert.string(color, opacity) };
|
|
9083
9715
|
case 'image':
|
|
9084
|
-
|
|
9716
|
+
data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
9717
|
+
break;
|
|
9085
9718
|
case 'linear':
|
|
9086
|
-
|
|
9719
|
+
data = PaintGradient.linearGradient(paint, boxBounds);
|
|
9720
|
+
break;
|
|
9087
9721
|
case 'radial':
|
|
9088
|
-
|
|
9722
|
+
data = PaintGradient.radialGradient(paint, boxBounds);
|
|
9723
|
+
break;
|
|
9089
9724
|
case 'angular':
|
|
9090
|
-
|
|
9725
|
+
data = PaintGradient.conicGradient(paint, boxBounds);
|
|
9726
|
+
break;
|
|
9727
|
+
case 'solid':
|
|
9728
|
+
const { type, blendMode, color, opacity } = paint;
|
|
9729
|
+
data = { type, blendMode, style: ColorConvert.string(color, opacity) };
|
|
9730
|
+
break;
|
|
9091
9731
|
default:
|
|
9092
|
-
|
|
9732
|
+
if (paint.r !== undefined)
|
|
9733
|
+
data = { type: 'solid', style: ColorConvert.string(paint) };
|
|
9734
|
+
}
|
|
9735
|
+
if (data) {
|
|
9736
|
+
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
9737
|
+
data.isTransparent = true;
|
|
9738
|
+
if (paint.blendMode)
|
|
9739
|
+
data.blendMode = paint.blendMode;
|
|
9093
9740
|
}
|
|
9741
|
+
return data;
|
|
9094
9742
|
}
|
|
9095
9743
|
|
|
9096
9744
|
const PaintModule = {
|
|
@@ -9156,12 +9804,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
9156
9804
|
|
|
9157
9805
|
const { get: get$2, translate } = MatrixHelper;
|
|
9158
9806
|
const tempBox = new Bounds();
|
|
9159
|
-
const tempPoint = {};
|
|
9160
9807
|
const tempScaleData = {};
|
|
9808
|
+
const tempImage = {};
|
|
9161
9809
|
function createData(leafPaint, image, paint, box) {
|
|
9162
|
-
const {
|
|
9163
|
-
if (blendMode)
|
|
9164
|
-
leafPaint.blendMode = blendMode;
|
|
9810
|
+
const { changeful, sync } = paint;
|
|
9165
9811
|
if (changeful)
|
|
9166
9812
|
leafPaint.changeful = changeful;
|
|
9167
9813
|
if (sync)
|
|
@@ -9169,38 +9815,38 @@ function createData(leafPaint, image, paint, box) {
|
|
|
9169
9815
|
leafPaint.data = getPatternData(paint, box, image);
|
|
9170
9816
|
}
|
|
9171
9817
|
function getPatternData(paint, box, image) {
|
|
9172
|
-
let { width, height } = image;
|
|
9173
9818
|
if (paint.padding)
|
|
9174
9819
|
box = tempBox.set(box).shrink(paint.padding);
|
|
9175
9820
|
if (paint.mode === 'strench')
|
|
9176
9821
|
paint.mode = 'stretch';
|
|
9822
|
+
let { width, height } = image;
|
|
9177
9823
|
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
9178
9824
|
const sameBox = box.width === width && box.height === height;
|
|
9179
9825
|
const data = { mode };
|
|
9180
9826
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
9181
|
-
|
|
9182
|
-
let
|
|
9827
|
+
BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
|
|
9828
|
+
let scaleX, scaleY;
|
|
9183
9829
|
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
9184
9830
|
if (!sameBox || rotation) {
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9831
|
+
scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
|
|
9832
|
+
BoundsHelper.put(box, image, align, scaleX, false, tempImage);
|
|
9833
|
+
BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
9188
9834
|
}
|
|
9189
9835
|
}
|
|
9190
|
-
else
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9836
|
+
else {
|
|
9837
|
+
if (scale || size) {
|
|
9838
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
9839
|
+
scaleX = tempScaleData.scaleX;
|
|
9840
|
+
scaleY = tempScaleData.scaleY;
|
|
9841
|
+
}
|
|
9842
|
+
if (align) {
|
|
9843
|
+
if (scaleX)
|
|
9844
|
+
BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
9845
|
+
AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
|
|
9846
|
+
}
|
|
9201
9847
|
}
|
|
9202
9848
|
if (offset)
|
|
9203
|
-
|
|
9849
|
+
PointHelper.move(tempImage, offset);
|
|
9204
9850
|
switch (mode) {
|
|
9205
9851
|
case 'stretch':
|
|
9206
9852
|
if (!sameBox)
|
|
@@ -9208,12 +9854,12 @@ function getPatternData(paint, box, image) {
|
|
|
9208
9854
|
break;
|
|
9209
9855
|
case 'normal':
|
|
9210
9856
|
case 'clip':
|
|
9211
|
-
if (x || y || scaleX || rotation)
|
|
9212
|
-
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
9857
|
+
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
9858
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9213
9859
|
break;
|
|
9214
9860
|
case 'repeat':
|
|
9215
9861
|
if (!sameBox || scaleX || rotation)
|
|
9216
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
|
|
9862
|
+
repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
|
|
9217
9863
|
if (!repeat)
|
|
9218
9864
|
data.repeat = 'repeat';
|
|
9219
9865
|
break;
|
|
@@ -9221,7 +9867,7 @@ function getPatternData(paint, box, image) {
|
|
|
9221
9867
|
case 'cover':
|
|
9222
9868
|
default:
|
|
9223
9869
|
if (scaleX)
|
|
9224
|
-
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
9870
|
+
fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9225
9871
|
}
|
|
9226
9872
|
if (!data.transform) {
|
|
9227
9873
|
if (box.x || box.y) {
|
|
@@ -9254,6 +9900,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
9254
9900
|
}
|
|
9255
9901
|
else {
|
|
9256
9902
|
leafPaint = { type: paint.type, image };
|
|
9903
|
+
if (image.hasAlphaPixel)
|
|
9904
|
+
leafPaint.isTransparent = true;
|
|
9257
9905
|
cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
|
|
9258
9906
|
}
|
|
9259
9907
|
if (firstUse || image.loading)
|
|
@@ -9278,7 +9926,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
9278
9926
|
ignoreRender(ui, false);
|
|
9279
9927
|
if (!ui.destroyed) {
|
|
9280
9928
|
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9281
|
-
if (image.
|
|
9929
|
+
if (image.hasAlphaPixel)
|
|
9282
9930
|
ui.__layout.hitCanvasChanged = true;
|
|
9283
9931
|
ui.forceUpdate('surface');
|
|
9284
9932
|
}
|
|
@@ -9290,13 +9938,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
9290
9938
|
onLoadError(ui, event, error);
|
|
9291
9939
|
leafPaint.loadId = null;
|
|
9292
9940
|
});
|
|
9293
|
-
if (ui.placeholderColor)
|
|
9294
|
-
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9941
|
+
if (ui.placeholderColor) {
|
|
9942
|
+
if (!ui.placeholderDelay)
|
|
9943
|
+
image.isPlacehold = true;
|
|
9944
|
+
else
|
|
9945
|
+
setTimeout(() => {
|
|
9946
|
+
if (!image.ready) {
|
|
9947
|
+
image.isPlacehold = true;
|
|
9948
|
+
ui.forceUpdate('surface');
|
|
9949
|
+
}
|
|
9950
|
+
}, ui.placeholderDelay);
|
|
9951
|
+
}
|
|
9300
9952
|
}
|
|
9301
9953
|
return leafPaint;
|
|
9302
9954
|
}
|
|
@@ -9502,32 +10154,33 @@ const PaintImageModule = {
|
|
|
9502
10154
|
repeatMode
|
|
9503
10155
|
};
|
|
9504
10156
|
|
|
9505
|
-
const { toPoint: toPoint$2 } = AroundHelper;
|
|
10157
|
+
const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
|
|
9506
10158
|
const realFrom$2 = {};
|
|
9507
10159
|
const realTo$2 = {};
|
|
9508
10160
|
function linearGradient(paint, box) {
|
|
9509
|
-
let { from, to, type,
|
|
10161
|
+
let { from, to, type, opacity } = paint;
|
|
9510
10162
|
toPoint$2(from || 'top', box, realFrom$2);
|
|
9511
10163
|
toPoint$2(to || 'bottom', box, realTo$2);
|
|
9512
10164
|
const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
|
|
9513
|
-
applyStops(style, paint.stops, opacity);
|
|
9514
10165
|
const data = { type, style };
|
|
9515
|
-
|
|
9516
|
-
data.blendMode = blendMode;
|
|
10166
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9517
10167
|
return data;
|
|
9518
10168
|
}
|
|
9519
|
-
function applyStops(gradient, stops, opacity) {
|
|
10169
|
+
function applyStops(data, gradient, stops, opacity) {
|
|
9520
10170
|
if (stops) {
|
|
9521
|
-
let stop;
|
|
10171
|
+
let stop, color, offset, isTransparent;
|
|
9522
10172
|
for (let i = 0, len = stops.length; i < len; i++) {
|
|
9523
10173
|
stop = stops[i];
|
|
9524
|
-
if (typeof stop === 'string')
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
10174
|
+
if (typeof stop === 'string')
|
|
10175
|
+
offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
|
|
10176
|
+
else
|
|
10177
|
+
offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
|
|
10178
|
+
gradient.addColorStop(offset, color);
|
|
10179
|
+
if (!isTransparent && hasTransparent(color))
|
|
10180
|
+
isTransparent = true;
|
|
9530
10181
|
}
|
|
10182
|
+
if (isTransparent)
|
|
10183
|
+
data.isTransparent = true;
|
|
9531
10184
|
}
|
|
9532
10185
|
}
|
|
9533
10186
|
|
|
@@ -9537,17 +10190,15 @@ const { toPoint: toPoint$1 } = AroundHelper;
|
|
|
9537
10190
|
const realFrom$1 = {};
|
|
9538
10191
|
const realTo$1 = {};
|
|
9539
10192
|
function radialGradient(paint, box) {
|
|
9540
|
-
let { from, to, type, opacity,
|
|
10193
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
9541
10194
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
9542
10195
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
9543
10196
|
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
9544
|
-
applyStops(style, paint.stops, opacity);
|
|
9545
10197
|
const data = { type, style };
|
|
10198
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9546
10199
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
9547
10200
|
if (transform)
|
|
9548
10201
|
data.transform = transform;
|
|
9549
|
-
if (blendMode)
|
|
9550
|
-
data.blendMode = blendMode;
|
|
9551
10202
|
return data;
|
|
9552
10203
|
}
|
|
9553
10204
|
function getTransform(box, from, to, stretch, rotate90) {
|
|
@@ -9573,17 +10224,15 @@ const { toPoint } = AroundHelper;
|
|
|
9573
10224
|
const realFrom = {};
|
|
9574
10225
|
const realTo = {};
|
|
9575
10226
|
function conicGradient(paint, box) {
|
|
9576
|
-
let { from, to, type, opacity,
|
|
10227
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
9577
10228
|
toPoint(from || 'center', box, realFrom);
|
|
9578
10229
|
toPoint(to || 'bottom', box, realTo);
|
|
9579
10230
|
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));
|
|
9580
|
-
applyStops(style, paint.stops, opacity);
|
|
9581
10231
|
const data = { type, style };
|
|
10232
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9582
10233
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
9583
10234
|
if (transform)
|
|
9584
10235
|
data.transform = transform;
|
|
9585
|
-
if (blendMode)
|
|
9586
|
-
data.blendMode = blendMode;
|
|
9587
10236
|
return data;
|
|
9588
10237
|
}
|
|
9589
10238
|
|
|
@@ -9916,6 +10565,8 @@ function createRows(drawData, content, style) {
|
|
|
9916
10565
|
lastCharType = null;
|
|
9917
10566
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
9918
10567
|
word = { data: [] }, row = { words: [] };
|
|
10568
|
+
if (__letterSpacing)
|
|
10569
|
+
content = [...content];
|
|
9919
10570
|
for (let i = 0, len = content.length; i < len; i++) {
|
|
9920
10571
|
char = content[i];
|
|
9921
10572
|
if (char === '\n') {
|
|
@@ -10329,4 +10980,4 @@ Object.assign(Effect, EffectModule);
|
|
|
10329
10980
|
|
|
10330
10981
|
useCanvas();
|
|
10331
10982
|
|
|
10332
|
-
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, 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$
|
|
10983
|
+
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, 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 };
|