leafer-draw 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.cjs +172 -172
- package/dist/web.esm.js +175 -175
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +1101 -449
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +1100 -449
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +2 -2
package/dist/web.js
CHANGED
|
@@ -26,8 +26,6 @@ var LeaferUI = (function (exports) {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
const Creator = {};
|
|
30
|
-
|
|
31
29
|
const IncrementId = {
|
|
32
30
|
RUNTIME: 'runtime',
|
|
33
31
|
LEAF: 'leaf',
|
|
@@ -153,7 +151,7 @@ var LeaferUI = (function (exports) {
|
|
|
153
151
|
|
|
154
152
|
const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
|
|
155
153
|
const { float: float$1 } = MathHelper;
|
|
156
|
-
const tempPoint$
|
|
154
|
+
const tempPoint$3 = {};
|
|
157
155
|
function getWorld() {
|
|
158
156
|
return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
|
|
159
157
|
}
|
|
@@ -196,8 +194,8 @@ var LeaferUI = (function (exports) {
|
|
|
196
194
|
t.d *= scaleY;
|
|
197
195
|
},
|
|
198
196
|
scaleOfOuter(t, origin, scaleX, scaleY) {
|
|
199
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
200
|
-
M$6.scaleOfInner(t, tempPoint$
|
|
197
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
198
|
+
M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
|
|
201
199
|
},
|
|
202
200
|
scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
|
|
203
201
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -215,8 +213,8 @@ var LeaferUI = (function (exports) {
|
|
|
215
213
|
t.d = c * sinR + d * cosR;
|
|
216
214
|
},
|
|
217
215
|
rotateOfOuter(t, origin, rotation) {
|
|
218
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
219
|
-
M$6.rotateOfInner(t, tempPoint$
|
|
216
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
217
|
+
M$6.rotateOfInner(t, tempPoint$3, rotation);
|
|
220
218
|
},
|
|
221
219
|
rotateOfInner(t, origin, rotation) {
|
|
222
220
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -237,8 +235,8 @@ var LeaferUI = (function (exports) {
|
|
|
237
235
|
}
|
|
238
236
|
},
|
|
239
237
|
skewOfOuter(t, origin, skewX, skewY) {
|
|
240
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
241
|
-
M$6.skewOfInner(t, tempPoint$
|
|
238
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
239
|
+
M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
|
|
242
240
|
},
|
|
243
241
|
skewOfInner(t, origin, skewX, skewY = 0) {
|
|
244
242
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -467,8 +465,10 @@ var LeaferUI = (function (exports) {
|
|
|
467
465
|
t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
|
|
468
466
|
},
|
|
469
467
|
move(t, x, y) {
|
|
470
|
-
|
|
471
|
-
|
|
468
|
+
if (typeof x === 'object')
|
|
469
|
+
t.x += x.x, t.y += x.y;
|
|
470
|
+
else
|
|
471
|
+
t.x += x, t.y += y;
|
|
472
472
|
},
|
|
473
473
|
scale(t, scaleX, scaleY = scaleX) {
|
|
474
474
|
if (t.x)
|
|
@@ -493,19 +493,19 @@ var LeaferUI = (function (exports) {
|
|
|
493
493
|
},
|
|
494
494
|
tempToInnerOf(t, matrix) {
|
|
495
495
|
const { tempPoint: temp } = P$5;
|
|
496
|
-
copy$
|
|
496
|
+
copy$b(temp, t);
|
|
497
497
|
toInnerPoint$2(matrix, temp, temp);
|
|
498
498
|
return temp;
|
|
499
499
|
},
|
|
500
500
|
tempToOuterOf(t, matrix) {
|
|
501
501
|
const { tempPoint: temp } = P$5;
|
|
502
|
-
copy$
|
|
502
|
+
copy$b(temp, t);
|
|
503
503
|
toOuterPoint$3(matrix, temp, temp);
|
|
504
504
|
return temp;
|
|
505
505
|
},
|
|
506
506
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
507
507
|
const { tempRadiusPoint: temp } = P$5;
|
|
508
|
-
copy$
|
|
508
|
+
copy$b(temp, t);
|
|
509
509
|
P$5.toInnerRadiusPointOf(t, matrix, temp);
|
|
510
510
|
return temp;
|
|
511
511
|
},
|
|
@@ -578,7 +578,7 @@ var LeaferUI = (function (exports) {
|
|
|
578
578
|
}
|
|
579
579
|
};
|
|
580
580
|
const P$5 = PointHelper;
|
|
581
|
-
const { getDistanceFrom, copy: copy$
|
|
581
|
+
const { getDistanceFrom, copy: copy$b, getAtan2 } = P$5;
|
|
582
582
|
|
|
583
583
|
class Point {
|
|
584
584
|
constructor(x, y) {
|
|
@@ -646,7 +646,7 @@ var LeaferUI = (function (exports) {
|
|
|
646
646
|
return this;
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
|
-
const tempPoint$
|
|
649
|
+
const tempPoint$2 = new Point();
|
|
650
650
|
|
|
651
651
|
class Matrix {
|
|
652
652
|
constructor(a, b, c, d, e, f) {
|
|
@@ -804,15 +804,87 @@ var LeaferUI = (function (exports) {
|
|
|
804
804
|
};
|
|
805
805
|
const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
|
|
806
806
|
|
|
807
|
+
exports.Direction4 = void 0;
|
|
808
|
+
(function (Direction4) {
|
|
809
|
+
Direction4[Direction4["top"] = 0] = "top";
|
|
810
|
+
Direction4[Direction4["right"] = 1] = "right";
|
|
811
|
+
Direction4[Direction4["bottom"] = 2] = "bottom";
|
|
812
|
+
Direction4[Direction4["left"] = 3] = "left";
|
|
813
|
+
})(exports.Direction4 || (exports.Direction4 = {}));
|
|
814
|
+
exports.Direction9 = void 0;
|
|
815
|
+
(function (Direction9) {
|
|
816
|
+
Direction9[Direction9["topLeft"] = 0] = "topLeft";
|
|
817
|
+
Direction9[Direction9["top"] = 1] = "top";
|
|
818
|
+
Direction9[Direction9["topRight"] = 2] = "topRight";
|
|
819
|
+
Direction9[Direction9["right"] = 3] = "right";
|
|
820
|
+
Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
|
|
821
|
+
Direction9[Direction9["bottom"] = 5] = "bottom";
|
|
822
|
+
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
823
|
+
Direction9[Direction9["left"] = 7] = "left";
|
|
824
|
+
Direction9[Direction9["center"] = 8] = "center";
|
|
825
|
+
Direction9[Direction9["top-left"] = 0] = "top-left";
|
|
826
|
+
Direction9[Direction9["top-right"] = 2] = "top-right";
|
|
827
|
+
Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
|
|
828
|
+
Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
|
|
829
|
+
})(exports.Direction9 || (exports.Direction9 = {}));
|
|
830
|
+
|
|
831
|
+
const directionData = [
|
|
832
|
+
{ x: 0, y: 0 },
|
|
833
|
+
{ x: 0.5, y: 0 },
|
|
834
|
+
{ x: 1, y: 0 },
|
|
835
|
+
{ x: 1, y: 0.5 },
|
|
836
|
+
{ x: 1, y: 1 },
|
|
837
|
+
{ x: 0.5, y: 1 },
|
|
838
|
+
{ x: 0, y: 1 },
|
|
839
|
+
{ x: 0, y: 0.5 },
|
|
840
|
+
{ x: 0.5, y: 0.5 }
|
|
841
|
+
];
|
|
842
|
+
directionData.forEach(item => item.type = 'percent');
|
|
843
|
+
const AroundHelper = {
|
|
844
|
+
directionData,
|
|
845
|
+
tempPoint: {},
|
|
846
|
+
get: get$4,
|
|
847
|
+
toPoint(around, box, to, onlyBoxSize, content, onlyContentSize) {
|
|
848
|
+
const point = get$4(around);
|
|
849
|
+
to.x = point.x;
|
|
850
|
+
to.y = point.y;
|
|
851
|
+
if (point.type === 'percent') {
|
|
852
|
+
to.x *= box.width;
|
|
853
|
+
to.y *= box.height;
|
|
854
|
+
if (content) {
|
|
855
|
+
if (!onlyContentSize)
|
|
856
|
+
to.x -= content.x, to.y -= content.y;
|
|
857
|
+
if (point.x)
|
|
858
|
+
to.x -= (point.x === 1) ? content.width : (point.x === 0.5 ? point.x * content.width : 0);
|
|
859
|
+
if (point.y)
|
|
860
|
+
to.y -= (point.y === 1) ? content.height : (point.y === 0.5 ? point.y * content.height : 0);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
if (!onlyBoxSize)
|
|
864
|
+
to.x += box.x, to.y += box.y;
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
function get$4(around) {
|
|
868
|
+
return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
const { toPoint: toPoint$5 } = AroundHelper;
|
|
872
|
+
const AlignHelper = {
|
|
873
|
+
toPoint(align, content, box, to, onlyBoxSize, onlyContentSize) {
|
|
874
|
+
toPoint$5(align, box, to, onlyBoxSize, content, onlyContentSize);
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
|
|
807
878
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
808
879
|
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
809
880
|
const { float, fourNumber } = MathHelper;
|
|
810
881
|
const { floor, ceil: ceil$2 } = Math;
|
|
811
882
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
812
883
|
const point = {};
|
|
813
|
-
const toPoint$
|
|
884
|
+
const toPoint$4 = {};
|
|
885
|
+
const tempBounds$2 = {};
|
|
814
886
|
const BoundsHelper = {
|
|
815
|
-
tempBounds:
|
|
887
|
+
tempBounds: tempBounds$2,
|
|
816
888
|
set(t, x = 0, y = 0, width = 0, height = 0) {
|
|
817
889
|
t.x = x;
|
|
818
890
|
t.y = y;
|
|
@@ -863,7 +935,7 @@ var LeaferUI = (function (exports) {
|
|
|
863
935
|
to = t;
|
|
864
936
|
}
|
|
865
937
|
else {
|
|
866
|
-
copy$
|
|
938
|
+
copy$a(to, t);
|
|
867
939
|
}
|
|
868
940
|
if (parent) {
|
|
869
941
|
to.offsetX = -(B.maxX(parent) - t.x);
|
|
@@ -875,8 +947,8 @@ var LeaferUI = (function (exports) {
|
|
|
875
947
|
}
|
|
876
948
|
B.move(to, -to.offsetX, -to.offsetY);
|
|
877
949
|
},
|
|
878
|
-
scale(t, scaleX, scaleY = scaleX) {
|
|
879
|
-
PointHelper.scale(t, scaleX, scaleY);
|
|
950
|
+
scale(t, scaleX, scaleY = scaleX, onlySize) {
|
|
951
|
+
onlySize || PointHelper.scale(t, scaleX, scaleY);
|
|
880
952
|
t.width *= scaleX;
|
|
881
953
|
t.height *= scaleY;
|
|
882
954
|
},
|
|
@@ -886,9 +958,9 @@ var LeaferUI = (function (exports) {
|
|
|
886
958
|
t.height *= scaleY;
|
|
887
959
|
},
|
|
888
960
|
tempToOuterOf(t, matrix) {
|
|
889
|
-
B.copy(
|
|
890
|
-
B.toOuterOf(
|
|
891
|
-
return
|
|
961
|
+
B.copy(tempBounds$2, t);
|
|
962
|
+
B.toOuterOf(tempBounds$2, matrix);
|
|
963
|
+
return tempBounds$2;
|
|
892
964
|
},
|
|
893
965
|
getOuterOf(t, matrix) {
|
|
894
966
|
t = Object.assign({}, t);
|
|
@@ -919,17 +991,17 @@ var LeaferUI = (function (exports) {
|
|
|
919
991
|
else {
|
|
920
992
|
point.x = t.x;
|
|
921
993
|
point.y = t.y;
|
|
922
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
923
|
-
setPoint$2(tempPointBounds$1, toPoint$
|
|
994
|
+
toOuterPoint$2(matrix, point, toPoint$4);
|
|
995
|
+
setPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
924
996
|
point.x = t.x + t.width;
|
|
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.y = t.y + t.height;
|
|
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
|
point.x = t.x;
|
|
931
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
932
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
1003
|
+
toOuterPoint$2(matrix, point, toPoint$4);
|
|
1004
|
+
addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
933
1005
|
toBounds$3(tempPointBounds$1, to);
|
|
934
1006
|
}
|
|
935
1007
|
},
|
|
@@ -939,9 +1011,21 @@ var LeaferUI = (function (exports) {
|
|
|
939
1011
|
B.scale(to, 1 / matrix.a, 1 / matrix.d);
|
|
940
1012
|
},
|
|
941
1013
|
getFitMatrix(t, put, baseScale = 1) {
|
|
942
|
-
const scale = Math.min(baseScale,
|
|
1014
|
+
const scale = Math.min(baseScale, B.getFitScale(t, put));
|
|
943
1015
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
944
1016
|
},
|
|
1017
|
+
getFitScale(t, put, isCoverMode) {
|
|
1018
|
+
const sw = t.width / put.width, sh = t.height / put.height;
|
|
1019
|
+
return isCoverMode ? Math.max(sw, sh) : Math.min(sw, sh);
|
|
1020
|
+
},
|
|
1021
|
+
put(t, put, align = 'center', putScale = 1, changeSize = true, to) {
|
|
1022
|
+
to || (to = put);
|
|
1023
|
+
if (typeof putScale === 'string')
|
|
1024
|
+
putScale = B.getFitScale(t, put, putScale === 'cover');
|
|
1025
|
+
tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
|
|
1026
|
+
tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
|
|
1027
|
+
AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
|
|
1028
|
+
},
|
|
945
1029
|
getSpread(t, spread, side) {
|
|
946
1030
|
const n = {};
|
|
947
1031
|
B.copyAndSpread(n, t, spread, false, side);
|
|
@@ -1009,7 +1093,7 @@ var LeaferUI = (function (exports) {
|
|
|
1009
1093
|
if (first) {
|
|
1010
1094
|
first = false;
|
|
1011
1095
|
if (!addMode)
|
|
1012
|
-
copy$
|
|
1096
|
+
copy$a(t, bounds);
|
|
1013
1097
|
}
|
|
1014
1098
|
else {
|
|
1015
1099
|
add$1(t, bounds);
|
|
@@ -1090,7 +1174,7 @@ var LeaferUI = (function (exports) {
|
|
|
1090
1174
|
}
|
|
1091
1175
|
};
|
|
1092
1176
|
const B = BoundsHelper;
|
|
1093
|
-
const { add: add$1, copy: copy$
|
|
1177
|
+
const { add: add$1, copy: copy$a } = B;
|
|
1094
1178
|
|
|
1095
1179
|
class Bounds {
|
|
1096
1180
|
get minX() { return BoundsHelper.minX(this); }
|
|
@@ -1115,8 +1199,8 @@ var LeaferUI = (function (exports) {
|
|
|
1115
1199
|
BoundsHelper.move(this, x, y);
|
|
1116
1200
|
return this;
|
|
1117
1201
|
}
|
|
1118
|
-
scale(scaleX, scaleY) {
|
|
1119
|
-
BoundsHelper.scale(this, scaleX, scaleY);
|
|
1202
|
+
scale(scaleX, scaleY, onlySize) {
|
|
1203
|
+
BoundsHelper.scale(this, scaleX, scaleY, onlySize);
|
|
1120
1204
|
return this;
|
|
1121
1205
|
}
|
|
1122
1206
|
scaleOf(origin, scaleX, scaleY) {
|
|
@@ -1134,6 +1218,9 @@ var LeaferUI = (function (exports) {
|
|
|
1134
1218
|
getFitMatrix(put, baseScale) {
|
|
1135
1219
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1136
1220
|
}
|
|
1221
|
+
put(put, align, putScale) {
|
|
1222
|
+
BoundsHelper.put(this, put, align, putScale);
|
|
1223
|
+
}
|
|
1137
1224
|
spread(fourNumber, side) {
|
|
1138
1225
|
BoundsHelper.spread(this, fourNumber, side);
|
|
1139
1226
|
return this;
|
|
@@ -1242,79 +1329,6 @@ var LeaferUI = (function (exports) {
|
|
|
1242
1329
|
}
|
|
1243
1330
|
}
|
|
1244
1331
|
|
|
1245
|
-
exports.Direction4 = void 0;
|
|
1246
|
-
(function (Direction4) {
|
|
1247
|
-
Direction4[Direction4["top"] = 0] = "top";
|
|
1248
|
-
Direction4[Direction4["right"] = 1] = "right";
|
|
1249
|
-
Direction4[Direction4["bottom"] = 2] = "bottom";
|
|
1250
|
-
Direction4[Direction4["left"] = 3] = "left";
|
|
1251
|
-
})(exports.Direction4 || (exports.Direction4 = {}));
|
|
1252
|
-
exports.Direction9 = void 0;
|
|
1253
|
-
(function (Direction9) {
|
|
1254
|
-
Direction9[Direction9["topLeft"] = 0] = "topLeft";
|
|
1255
|
-
Direction9[Direction9["top"] = 1] = "top";
|
|
1256
|
-
Direction9[Direction9["topRight"] = 2] = "topRight";
|
|
1257
|
-
Direction9[Direction9["right"] = 3] = "right";
|
|
1258
|
-
Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
|
|
1259
|
-
Direction9[Direction9["bottom"] = 5] = "bottom";
|
|
1260
|
-
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
1261
|
-
Direction9[Direction9["left"] = 7] = "left";
|
|
1262
|
-
Direction9[Direction9["center"] = 8] = "center";
|
|
1263
|
-
Direction9[Direction9["top-left"] = 0] = "top-left";
|
|
1264
|
-
Direction9[Direction9["top-right"] = 2] = "top-right";
|
|
1265
|
-
Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
|
|
1266
|
-
Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
|
|
1267
|
-
})(exports.Direction9 || (exports.Direction9 = {}));
|
|
1268
|
-
|
|
1269
|
-
const directionData = [
|
|
1270
|
-
{ x: 0, y: 0 },
|
|
1271
|
-
{ x: 0.5, y: 0 },
|
|
1272
|
-
{ x: 1, y: 0 },
|
|
1273
|
-
{ x: 1, y: 0.5 },
|
|
1274
|
-
{ x: 1, y: 1 },
|
|
1275
|
-
{ x: 0.5, y: 1 },
|
|
1276
|
-
{ x: 0, y: 1 },
|
|
1277
|
-
{ x: 0, y: 0.5 },
|
|
1278
|
-
{ x: 0.5, y: 0.5 }
|
|
1279
|
-
];
|
|
1280
|
-
directionData.forEach(item => item.type = 'percent');
|
|
1281
|
-
const AroundHelper = {
|
|
1282
|
-
directionData,
|
|
1283
|
-
tempPoint: {},
|
|
1284
|
-
get: get$4,
|
|
1285
|
-
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1286
|
-
const point = get$4(around);
|
|
1287
|
-
to.x = point.x;
|
|
1288
|
-
to.y = point.y;
|
|
1289
|
-
if (point.type === 'percent') {
|
|
1290
|
-
to.x *= bounds.width;
|
|
1291
|
-
to.y *= bounds.height;
|
|
1292
|
-
if (pointBounds) {
|
|
1293
|
-
to.x -= pointBounds.x;
|
|
1294
|
-
to.y -= pointBounds.y;
|
|
1295
|
-
if (point.x)
|
|
1296
|
-
to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
|
|
1297
|
-
if (point.y)
|
|
1298
|
-
to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
if (!onlySize) {
|
|
1302
|
-
to.x += bounds.x;
|
|
1303
|
-
to.y += bounds.y;
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
function get$4(around) {
|
|
1308
|
-
return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
const { toPoint: toPoint$4 } = AroundHelper;
|
|
1312
|
-
const AlignHelper = {
|
|
1313
|
-
toPoint(align, contentBounds, bounds, to, onlySize) {
|
|
1314
|
-
toPoint$4(align, bounds, to, onlySize, contentBounds);
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
|
|
1318
1332
|
const StringNumberMap = {
|
|
1319
1333
|
'0': 1,
|
|
1320
1334
|
'1': 1,
|
|
@@ -1445,11 +1459,17 @@ var LeaferUI = (function (exports) {
|
|
|
1445
1459
|
return rs;
|
|
1446
1460
|
},
|
|
1447
1461
|
need(name) {
|
|
1448
|
-
console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1462
|
+
console.error('please install and import plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1449
1463
|
}
|
|
1450
1464
|
};
|
|
1451
1465
|
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
1452
1466
|
|
|
1467
|
+
const Creator = {
|
|
1468
|
+
editor(_options) {
|
|
1469
|
+
return Plugin.need('editor');
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
|
|
1453
1473
|
const debug$e = Debug.get('UICreator');
|
|
1454
1474
|
const UICreator = {
|
|
1455
1475
|
list: {},
|
|
@@ -1587,6 +1607,10 @@ var LeaferUI = (function (exports) {
|
|
|
1587
1607
|
for (let i = 0, len = list.length; i < len; i++)
|
|
1588
1608
|
map[list[i]] = true;
|
|
1589
1609
|
return map;
|
|
1610
|
+
},
|
|
1611
|
+
stintSet(data, attrName, value) {
|
|
1612
|
+
value || (value = undefined);
|
|
1613
|
+
data[attrName] !== value && (data[attrName] = value);
|
|
1590
1614
|
}
|
|
1591
1615
|
};
|
|
1592
1616
|
const { assign } = DataHelper;
|
|
@@ -2045,7 +2069,7 @@ var LeaferUI = (function (exports) {
|
|
|
2045
2069
|
contextMethod()
|
|
2046
2070
|
], Canvas.prototype, "strokeText", null);
|
|
2047
2071
|
|
|
2048
|
-
const { copy: copy$
|
|
2072
|
+
const { copy: copy$9, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
|
|
2049
2073
|
const minSize = { width: 1, height: 1, pixelRatio: 1 };
|
|
2050
2074
|
const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
|
|
2051
2075
|
class LeaferCanvasBase extends Canvas {
|
|
@@ -2277,7 +2301,7 @@ var LeaferUI = (function (exports) {
|
|
|
2277
2301
|
const { size, pixelSnap } = this, canvas = this.manager ? this.manager.get(size) : Creator.canvas(Object.assign({}, size));
|
|
2278
2302
|
canvas.save();
|
|
2279
2303
|
if (useSameWorldTransform)
|
|
2280
|
-
copy$
|
|
2304
|
+
copy$9(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
|
|
2281
2305
|
if (useSameSmooth)
|
|
2282
2306
|
canvas.smooth = this.smooth;
|
|
2283
2307
|
canvas.pixelSnap !== pixelSnap && (canvas.pixelSnap = pixelSnap);
|
|
@@ -2388,7 +2412,7 @@ var LeaferUI = (function (exports) {
|
|
|
2388
2412
|
const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
|
|
2389
2413
|
const { set, toNumberPoints } = PointHelper;
|
|
2390
2414
|
const { M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5 } = PathCommandMap;
|
|
2391
|
-
const tempPoint$
|
|
2415
|
+
const tempPoint$1 = {};
|
|
2392
2416
|
const BezierHelper = {
|
|
2393
2417
|
points(data, originPoints, curve, close) {
|
|
2394
2418
|
let points = toNumberPoints(originPoints);
|
|
@@ -2410,6 +2434,8 @@ var LeaferUI = (function (exports) {
|
|
|
2410
2434
|
cY = points[i + 3];
|
|
2411
2435
|
ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
|
|
2412
2436
|
cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
|
|
2437
|
+
if (!ba && !cb)
|
|
2438
|
+
continue;
|
|
2413
2439
|
d = ba + cb;
|
|
2414
2440
|
ba = (t * ba) / d;
|
|
2415
2441
|
cb = (t * cb) / d;
|
|
@@ -2579,8 +2605,8 @@ var LeaferUI = (function (exports) {
|
|
|
2579
2605
|
addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
|
|
2580
2606
|
addPoint$1(pointBounds, toX, toY);
|
|
2581
2607
|
for (let i = 0, len = tList.length; i < len; i++) {
|
|
2582
|
-
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$
|
|
2583
|
-
addPoint$1(pointBounds, tempPoint$
|
|
2608
|
+
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
|
|
2609
|
+
addPoint$1(pointBounds, tempPoint$1.x, tempPoint$1.y);
|
|
2584
2610
|
}
|
|
2585
2611
|
},
|
|
2586
2612
|
getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
|
|
@@ -2654,7 +2680,7 @@ var LeaferUI = (function (exports) {
|
|
|
2654
2680
|
};
|
|
2655
2681
|
|
|
2656
2682
|
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;
|
|
2657
|
-
const { rect: rect$
|
|
2683
|
+
const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2658
2684
|
const { ellipticalArc } = EllipseHelper;
|
|
2659
2685
|
const debug$c = Debug.get('PathConvert');
|
|
2660
2686
|
const setEndPoint$1 = {};
|
|
@@ -2851,7 +2877,7 @@ var LeaferUI = (function (exports) {
|
|
|
2851
2877
|
case N$3:
|
|
2852
2878
|
x = old[i + 1];
|
|
2853
2879
|
y = old[i + 2];
|
|
2854
|
-
curveMode ? rect$
|
|
2880
|
+
curveMode ? rect$3(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
|
|
2855
2881
|
i += 5;
|
|
2856
2882
|
break;
|
|
2857
2883
|
case D$3:
|
|
@@ -3027,7 +3053,7 @@ var LeaferUI = (function (exports) {
|
|
|
3027
3053
|
};
|
|
3028
3054
|
const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
|
|
3029
3055
|
|
|
3030
|
-
const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$
|
|
3056
|
+
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;
|
|
3031
3057
|
class PathCreator {
|
|
3032
3058
|
set path(value) { this.__path = value; }
|
|
3033
3059
|
get path() { return this.__path; }
|
|
@@ -3074,7 +3100,7 @@ var LeaferUI = (function (exports) {
|
|
|
3074
3100
|
return this;
|
|
3075
3101
|
}
|
|
3076
3102
|
rect(x, y, width, height) {
|
|
3077
|
-
rect$
|
|
3103
|
+
rect$2(this.__path, x, y, width, height);
|
|
3078
3104
|
this.paint();
|
|
3079
3105
|
return this;
|
|
3080
3106
|
}
|
|
@@ -3192,7 +3218,7 @@ var LeaferUI = (function (exports) {
|
|
|
3192
3218
|
|
|
3193
3219
|
const { M: M$1, L: L$2, C, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
|
|
3194
3220
|
const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
|
|
3195
|
-
const { addPointBounds, copy: copy$
|
|
3221
|
+
const { addPointBounds, copy: copy$8, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
|
|
3196
3222
|
const debug$a = Debug.get('PathBounds');
|
|
3197
3223
|
let radius, radiusX, radiusY;
|
|
3198
3224
|
const tempPointBounds = {};
|
|
@@ -3264,7 +3290,7 @@ var LeaferUI = (function (exports) {
|
|
|
3264
3290
|
break;
|
|
3265
3291
|
case G:
|
|
3266
3292
|
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);
|
|
3267
|
-
i === 0 ? copy$
|
|
3293
|
+
i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3268
3294
|
x = setEndPoint.x;
|
|
3269
3295
|
y = setEndPoint.y;
|
|
3270
3296
|
i += 9;
|
|
@@ -3280,7 +3306,7 @@ var LeaferUI = (function (exports) {
|
|
|
3280
3306
|
break;
|
|
3281
3307
|
case O:
|
|
3282
3308
|
arc(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], tempPointBounds, setEndPoint);
|
|
3283
|
-
i === 0 ? copy$
|
|
3309
|
+
i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3284
3310
|
x = setEndPoint.x;
|
|
3285
3311
|
y = setEndPoint.y;
|
|
3286
3312
|
i += 7;
|
|
@@ -3295,7 +3321,7 @@ var LeaferUI = (function (exports) {
|
|
|
3295
3321
|
break;
|
|
3296
3322
|
case U:
|
|
3297
3323
|
arcTo$1(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
|
|
3298
|
-
i === 0 ? copy$
|
|
3324
|
+
i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3299
3325
|
x = setEndPoint.x;
|
|
3300
3326
|
y = setEndPoint.y;
|
|
3301
3327
|
i += 6;
|
|
@@ -3389,7 +3415,7 @@ var LeaferUI = (function (exports) {
|
|
|
3389
3415
|
}
|
|
3390
3416
|
|
|
3391
3417
|
const FileHelper = {
|
|
3392
|
-
|
|
3418
|
+
alphaPixelTypes: ['png', 'webp', 'svg'],
|
|
3393
3419
|
upperCaseTypeMap: {},
|
|
3394
3420
|
mineType(type) {
|
|
3395
3421
|
if (!type || type.startsWith('image'))
|
|
@@ -3416,7 +3442,7 @@ var LeaferUI = (function (exports) {
|
|
|
3416
3442
|
}
|
|
3417
3443
|
};
|
|
3418
3444
|
const F = FileHelper;
|
|
3419
|
-
F.
|
|
3445
|
+
F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3420
3446
|
|
|
3421
3447
|
const debug$9 = Debug.get('TaskProcessor');
|
|
3422
3448
|
class TaskItem {
|
|
@@ -3733,8 +3759,8 @@ var LeaferUI = (function (exports) {
|
|
|
3733
3759
|
list.length = 0;
|
|
3734
3760
|
}
|
|
3735
3761
|
},
|
|
3736
|
-
|
|
3737
|
-
return FileHelper.
|
|
3762
|
+
hasAlphaPixel(config) {
|
|
3763
|
+
return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
|
|
3738
3764
|
},
|
|
3739
3765
|
isFormat(format, config) {
|
|
3740
3766
|
if (config.format === format)
|
|
@@ -3772,7 +3798,7 @@ var LeaferUI = (function (exports) {
|
|
|
3772
3798
|
this.setView(view.config ? view.view : view);
|
|
3773
3799
|
}
|
|
3774
3800
|
ImageManager.isFormat('svg', config) && (this.isSVG = true);
|
|
3775
|
-
ImageManager.
|
|
3801
|
+
ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
|
|
3776
3802
|
}
|
|
3777
3803
|
load(onSuccess, onError) {
|
|
3778
3804
|
if (!this.loading) {
|
|
@@ -4231,8 +4257,8 @@ var LeaferUI = (function (exports) {
|
|
|
4231
4257
|
};
|
|
4232
4258
|
}
|
|
4233
4259
|
|
|
4234
|
-
const { copy: copy$
|
|
4235
|
-
const matrix = {}, { round } = Math;
|
|
4260
|
+
const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4261
|
+
const matrix$1 = {}, { round } = Math;
|
|
4236
4262
|
const LeafHelper = {
|
|
4237
4263
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
4238
4264
|
if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
|
|
@@ -4327,13 +4353,13 @@ var LeaferUI = (function (exports) {
|
|
|
4327
4353
|
transition = scaleY;
|
|
4328
4354
|
scaleY = scaleX;
|
|
4329
4355
|
}
|
|
4330
|
-
copy$
|
|
4331
|
-
scaleOfOuter$2(matrix, origin, scaleX, scaleY);
|
|
4356
|
+
copy$7(matrix$1, o);
|
|
4357
|
+
scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
|
|
4332
4358
|
if (t.origin || t.around) {
|
|
4333
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4359
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4334
4360
|
}
|
|
4335
4361
|
else {
|
|
4336
|
-
const x = t.x + matrix.e - o.e, y = t.y + matrix.f - o.f;
|
|
4362
|
+
const x = t.x + matrix$1.e - o.e, y = t.y + matrix$1.f - o.f;
|
|
4337
4363
|
if (transition && !resize)
|
|
4338
4364
|
t.animate({ x, y, scaleX: t.scaleX * scaleX, scaleY: t.scaleY * scaleY }, transition);
|
|
4339
4365
|
else
|
|
@@ -4345,32 +4371,32 @@ var LeaferUI = (function (exports) {
|
|
|
4345
4371
|
},
|
|
4346
4372
|
rotateOfLocal(t, origin, angle, transition) {
|
|
4347
4373
|
const o = t.__localMatrix;
|
|
4348
|
-
copy$
|
|
4349
|
-
rotateOfOuter$2(matrix, origin, angle);
|
|
4374
|
+
copy$7(matrix$1, o);
|
|
4375
|
+
rotateOfOuter$2(matrix$1, origin, angle);
|
|
4350
4376
|
if (t.origin || t.around)
|
|
4351
|
-
L.setTransform(t, matrix, false, transition);
|
|
4377
|
+
L.setTransform(t, matrix$1, false, transition);
|
|
4352
4378
|
else
|
|
4353
|
-
t.set({ x: t.x + matrix.e - o.e, y: t.y + matrix.f - o.f, rotation: MathHelper.formatRotation(t.rotation + angle) }, transition);
|
|
4379
|
+
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);
|
|
4354
4380
|
},
|
|
4355
4381
|
skewOfWorld(t, origin, skewX, skewY, resize, transition) {
|
|
4356
4382
|
L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize, transition);
|
|
4357
4383
|
},
|
|
4358
4384
|
skewOfLocal(t, origin, skewX, skewY = 0, resize, transition) {
|
|
4359
|
-
copy$
|
|
4360
|
-
skewOfOuter(matrix, origin, skewX, skewY);
|
|
4361
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4385
|
+
copy$7(matrix$1, t.__localMatrix);
|
|
4386
|
+
skewOfOuter(matrix$1, origin, skewX, skewY);
|
|
4387
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4362
4388
|
},
|
|
4363
4389
|
transformWorld(t, transform, resize, transition) {
|
|
4364
|
-
copy$
|
|
4365
|
-
multiplyParent$2(matrix, transform);
|
|
4390
|
+
copy$7(matrix$1, t.worldTransform);
|
|
4391
|
+
multiplyParent$2(matrix$1, transform);
|
|
4366
4392
|
if (t.parent)
|
|
4367
|
-
divideParent(matrix, t.parent.worldTransform);
|
|
4368
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4393
|
+
divideParent(matrix$1, t.parent.worldTransform);
|
|
4394
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4369
4395
|
},
|
|
4370
4396
|
transform(t, transform, resize, transition) {
|
|
4371
|
-
copy$
|
|
4372
|
-
multiplyParent$2(matrix, transform);
|
|
4373
|
-
L.setTransform(t, matrix, resize, transition);
|
|
4397
|
+
copy$7(matrix$1, t.localTransform);
|
|
4398
|
+
multiplyParent$2(matrix$1, transform);
|
|
4399
|
+
L.setTransform(t, matrix$1, resize, transition);
|
|
4374
4400
|
},
|
|
4375
4401
|
setTransform(t, transform, resize, transition) {
|
|
4376
4402
|
const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin);
|
|
@@ -4404,9 +4430,9 @@ var LeaferUI = (function (exports) {
|
|
|
4404
4430
|
return innerOrigin;
|
|
4405
4431
|
},
|
|
4406
4432
|
getRelativeWorld(t, relative, temp) {
|
|
4407
|
-
copy$
|
|
4408
|
-
divideParent(matrix, relative.worldTransform);
|
|
4409
|
-
return temp ? matrix : Object.assign({}, matrix);
|
|
4433
|
+
copy$7(matrix$1, t.worldTransform);
|
|
4434
|
+
divideParent(matrix$1, relative.worldTransform);
|
|
4435
|
+
return temp ? matrix$1 : Object.assign({}, matrix$1);
|
|
4410
4436
|
},
|
|
4411
4437
|
drop(t, parent, index, resize) {
|
|
4412
4438
|
t.setTransform(L.getRelativeWorld(t, parent, true), resize);
|
|
@@ -4460,7 +4486,7 @@ var LeaferUI = (function (exports) {
|
|
|
4460
4486
|
}
|
|
4461
4487
|
};
|
|
4462
4488
|
|
|
4463
|
-
const { updateBounds: updateBounds$
|
|
4489
|
+
const { updateBounds: updateBounds$3 } = LeafHelper;
|
|
4464
4490
|
const BranchHelper = {
|
|
4465
4491
|
sort(a, b) {
|
|
4466
4492
|
return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
|
|
@@ -4522,11 +4548,11 @@ var LeaferUI = (function (exports) {
|
|
|
4522
4548
|
branch = branchStack[i];
|
|
4523
4549
|
children = branch.children;
|
|
4524
4550
|
for (let j = 0, len = children.length; j < len; j++) {
|
|
4525
|
-
updateBounds$
|
|
4551
|
+
updateBounds$3(children[j]);
|
|
4526
4552
|
}
|
|
4527
4553
|
if (exclude && exclude === branch)
|
|
4528
4554
|
continue;
|
|
4529
|
-
updateBounds$
|
|
4555
|
+
updateBounds$3(branch);
|
|
4530
4556
|
}
|
|
4531
4557
|
}
|
|
4532
4558
|
};
|
|
@@ -4544,8 +4570,8 @@ var LeaferUI = (function (exports) {
|
|
|
4544
4570
|
}
|
|
4545
4571
|
};
|
|
4546
4572
|
|
|
4547
|
-
const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
|
|
4548
|
-
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$
|
|
4573
|
+
const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2 } = LeafHelper;
|
|
4574
|
+
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$6 } = BoundsHelper;
|
|
4549
4575
|
const localContent = '_localContentBounds';
|
|
4550
4576
|
const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
|
|
4551
4577
|
class LeafLayout {
|
|
@@ -4588,7 +4614,9 @@ var LeaferUI = (function (exports) {
|
|
|
4588
4614
|
this._localRenderBounds = local;
|
|
4589
4615
|
}
|
|
4590
4616
|
update() {
|
|
4591
|
-
const { leafer } =
|
|
4617
|
+
const { leaf } = this, { leafer } = leaf;
|
|
4618
|
+
if (leaf.isApp)
|
|
4619
|
+
return updateBounds$2(leaf);
|
|
4592
4620
|
if (leafer) {
|
|
4593
4621
|
if (leafer.ready)
|
|
4594
4622
|
leafer.watcher.changed && leafer.layouter.layout();
|
|
@@ -4596,7 +4624,7 @@ var LeaferUI = (function (exports) {
|
|
|
4596
4624
|
leafer.start();
|
|
4597
4625
|
}
|
|
4598
4626
|
else {
|
|
4599
|
-
let root =
|
|
4627
|
+
let root = leaf;
|
|
4600
4628
|
while (root.parent && !root.parent.leafer) {
|
|
4601
4629
|
root = root.parent;
|
|
4602
4630
|
}
|
|
@@ -4703,7 +4731,7 @@ var LeaferUI = (function (exports) {
|
|
|
4703
4731
|
}
|
|
4704
4732
|
if (!layoutBounds)
|
|
4705
4733
|
layoutBounds = MatrixHelper.getLayout(matrix);
|
|
4706
|
-
copy$
|
|
4734
|
+
copy$6(layoutBounds, bounds);
|
|
4707
4735
|
PointHelper.copy(layoutBounds, point);
|
|
4708
4736
|
if (unscale) {
|
|
4709
4737
|
const { scaleX, scaleY } = layoutBounds;
|
|
@@ -4818,7 +4846,7 @@ var LeaferUI = (function (exports) {
|
|
|
4818
4846
|
}
|
|
4819
4847
|
childrenSortChange() {
|
|
4820
4848
|
if (!this.childrenSortChanged) {
|
|
4821
|
-
this.childrenSortChanged = true;
|
|
4849
|
+
this.childrenSortChanged = this.affectChildrenSort = true;
|
|
4822
4850
|
this.leaf.forceUpdate('surface');
|
|
4823
4851
|
}
|
|
4824
4852
|
}
|
|
@@ -4885,6 +4913,40 @@ var LeaferUI = (function (exports) {
|
|
|
4885
4913
|
ImageEvent.LOADED = 'image.loaded';
|
|
4886
4914
|
ImageEvent.ERROR = 'image.error';
|
|
4887
4915
|
|
|
4916
|
+
class BoundsEvent extends Event {
|
|
4917
|
+
static checkHas(leaf, type, mode) {
|
|
4918
|
+
if (mode === 'on') {
|
|
4919
|
+
type === WORLD ? leaf.__hasWorldEvent = true : leaf.__hasLocalEvent = true;
|
|
4920
|
+
}
|
|
4921
|
+
else {
|
|
4922
|
+
leaf.__hasLocalEvent = leaf.hasEvent(RESIZE) || leaf.hasEvent(INNER) || leaf.hasEvent(LOCAL);
|
|
4923
|
+
leaf.__hasWorldEvent = leaf.hasEvent(WORLD);
|
|
4924
|
+
}
|
|
4925
|
+
}
|
|
4926
|
+
static emitLocal(leaf) {
|
|
4927
|
+
if (leaf.leaferIsReady) {
|
|
4928
|
+
const { resized } = leaf.__layout;
|
|
4929
|
+
if (resized !== 'local') {
|
|
4930
|
+
leaf.emit(RESIZE, leaf);
|
|
4931
|
+
if (resized === 'inner')
|
|
4932
|
+
leaf.emit(INNER, leaf);
|
|
4933
|
+
}
|
|
4934
|
+
leaf.emit(LOCAL, leaf);
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
static emitWorld(leaf) {
|
|
4938
|
+
if (leaf.leaferIsReady)
|
|
4939
|
+
leaf.emit(WORLD, this);
|
|
4940
|
+
}
|
|
4941
|
+
}
|
|
4942
|
+
BoundsEvent.RESIZE = 'bounds.resize';
|
|
4943
|
+
BoundsEvent.INNER = 'bounds.inner';
|
|
4944
|
+
BoundsEvent.LOCAL = 'bounds.local';
|
|
4945
|
+
BoundsEvent.WORLD = 'bounds.world';
|
|
4946
|
+
const { RESIZE, INNER, LOCAL, WORLD } = BoundsEvent;
|
|
4947
|
+
const boundsEventMap = {};
|
|
4948
|
+
[RESIZE, INNER, LOCAL, WORLD].forEach(key => boundsEventMap[key] = 1);
|
|
4949
|
+
|
|
4888
4950
|
class ResizeEvent extends Event {
|
|
4889
4951
|
get bigger() {
|
|
4890
4952
|
if (!this.old)
|
|
@@ -4981,9 +5043,12 @@ var LeaferUI = (function (exports) {
|
|
|
4981
5043
|
set event(map) { this.on(map); }
|
|
4982
5044
|
on(type, listener, options) {
|
|
4983
5045
|
if (!listener) {
|
|
4984
|
-
let event
|
|
4985
|
-
|
|
4986
|
-
|
|
5046
|
+
let event;
|
|
5047
|
+
if (type instanceof Array)
|
|
5048
|
+
type.forEach(item => this.on(item[0], item[1], item[2]));
|
|
5049
|
+
else
|
|
5050
|
+
for (let key in type)
|
|
5051
|
+
(event = type[key]) instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
|
|
4987
5052
|
return;
|
|
4988
5053
|
}
|
|
4989
5054
|
let capture, once;
|
|
@@ -5013,6 +5078,8 @@ var LeaferUI = (function (exports) {
|
|
|
5013
5078
|
else {
|
|
5014
5079
|
map[type] = [item];
|
|
5015
5080
|
}
|
|
5081
|
+
if (boundsEventMap[type])
|
|
5082
|
+
BoundsEvent.checkHas(this, type, 'on');
|
|
5016
5083
|
}
|
|
5017
5084
|
});
|
|
5018
5085
|
}
|
|
@@ -5034,6 +5101,8 @@ var LeaferUI = (function (exports) {
|
|
|
5034
5101
|
events.splice(index, 1);
|
|
5035
5102
|
if (!events.length)
|
|
5036
5103
|
delete map[type];
|
|
5104
|
+
if (boundsEventMap[type])
|
|
5105
|
+
BoundsEvent.checkHas(this, type, 'off');
|
|
5037
5106
|
}
|
|
5038
5107
|
}
|
|
5039
5108
|
});
|
|
@@ -5053,19 +5122,31 @@ var LeaferUI = (function (exports) {
|
|
|
5053
5122
|
}
|
|
5054
5123
|
}
|
|
5055
5124
|
on_(type, listener, bind, options) {
|
|
5056
|
-
if (
|
|
5057
|
-
|
|
5058
|
-
|
|
5125
|
+
if (!listener)
|
|
5126
|
+
(type instanceof Array) && type.forEach(item => this.on(item[0], item[2] ? item[1] = item[1].bind(item[2]) : item[1], item[3]));
|
|
5127
|
+
else
|
|
5128
|
+
this.on(type, bind ? listener = listener.bind(bind) : listener, options);
|
|
5059
5129
|
return { type, current: this, listener, options };
|
|
5060
5130
|
}
|
|
5061
5131
|
off_(id) {
|
|
5062
5132
|
if (!id)
|
|
5063
5133
|
return;
|
|
5064
5134
|
const list = id instanceof Array ? id : [id];
|
|
5065
|
-
list.forEach(item =>
|
|
5135
|
+
list.forEach(item => {
|
|
5136
|
+
if (!item.listener)
|
|
5137
|
+
(item.type instanceof Array) && item.type.forEach(v => item.current.off(v[0], v[1], v[3]));
|
|
5138
|
+
else
|
|
5139
|
+
item.current.off(item.type, item.listener, item.options);
|
|
5140
|
+
});
|
|
5066
5141
|
list.length = 0;
|
|
5067
5142
|
}
|
|
5068
|
-
once(type, listener, capture) {
|
|
5143
|
+
once(type, listener, captureOrBind, capture) {
|
|
5144
|
+
if (!listener)
|
|
5145
|
+
return (type instanceof Array) && type.forEach(item => this.once(item[0], item[1], item[2], item[3]));
|
|
5146
|
+
if (typeof captureOrBind === 'object')
|
|
5147
|
+
listener = listener.bind(captureOrBind);
|
|
5148
|
+
else
|
|
5149
|
+
capture = captureOrBind;
|
|
5069
5150
|
this.on(type, listener, { once: true, capture });
|
|
5070
5151
|
}
|
|
5071
5152
|
emit(type, event, capture) {
|
|
@@ -5177,7 +5258,7 @@ var LeaferUI = (function (exports) {
|
|
|
5177
5258
|
};
|
|
5178
5259
|
|
|
5179
5260
|
const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
|
|
5180
|
-
const { toPoint: toPoint$3, tempPoint
|
|
5261
|
+
const { toPoint: toPoint$3, tempPoint } = AroundHelper;
|
|
5181
5262
|
const LeafMatrix = {
|
|
5182
5263
|
__updateWorldMatrix() {
|
|
5183
5264
|
multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
|
|
@@ -5186,33 +5267,39 @@ var LeaferUI = (function (exports) {
|
|
|
5186
5267
|
if (this.__local) {
|
|
5187
5268
|
const layout = this.__layout, local = this.__local, data = this.__;
|
|
5188
5269
|
if (layout.affectScaleOrRotation) {
|
|
5189
|
-
if (layout.scaleChanged || layout.rotationChanged) {
|
|
5270
|
+
if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
|
|
5190
5271
|
setLayout(local, data, null, null, layout.affectRotation);
|
|
5191
|
-
layout.scaleChanged = layout.rotationChanged =
|
|
5272
|
+
layout.scaleChanged = layout.rotationChanged = undefined;
|
|
5192
5273
|
}
|
|
5193
5274
|
}
|
|
5194
5275
|
local.e = data.x + data.offsetX;
|
|
5195
5276
|
local.f = data.y + data.offsetY;
|
|
5196
5277
|
if (data.around || data.origin) {
|
|
5197
|
-
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint
|
|
5198
|
-
translateInner(local, -tempPoint
|
|
5278
|
+
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint);
|
|
5279
|
+
translateInner(local, -tempPoint.x, -tempPoint.y, !data.around);
|
|
5199
5280
|
}
|
|
5200
5281
|
}
|
|
5201
|
-
this.__layout.matrixChanged =
|
|
5282
|
+
this.__layout.matrixChanged = undefined;
|
|
5202
5283
|
}
|
|
5203
5284
|
};
|
|
5204
5285
|
|
|
5205
5286
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5206
5287
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5207
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$
|
|
5288
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
|
|
5208
5289
|
const { toBounds: toBounds$1 } = PathBounds;
|
|
5209
5290
|
const LeafBounds = {
|
|
5210
5291
|
__updateWorldBounds() {
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5292
|
+
const layout = this.__layout;
|
|
5293
|
+
toOuterOf$1(layout.renderBounds, this.__world, this.__world);
|
|
5294
|
+
if (layout.resized) {
|
|
5295
|
+
if (layout.resized === 'inner')
|
|
5296
|
+
this.__onUpdateSize();
|
|
5297
|
+
if (this.__hasLocalEvent)
|
|
5298
|
+
BoundsEvent.emitLocal(this);
|
|
5299
|
+
layout.resized = undefined;
|
|
5215
5300
|
}
|
|
5301
|
+
if (this.__hasWorldEvent)
|
|
5302
|
+
BoundsEvent.emitWorld(this);
|
|
5216
5303
|
},
|
|
5217
5304
|
__updateLocalBounds() {
|
|
5218
5305
|
const layout = this.__layout;
|
|
@@ -5221,12 +5308,12 @@ var LeaferUI = (function (exports) {
|
|
|
5221
5308
|
this.__updatePath();
|
|
5222
5309
|
this.__updateRenderPath();
|
|
5223
5310
|
this.__updateBoxBounds();
|
|
5224
|
-
layout.resized =
|
|
5311
|
+
layout.resized = 'inner';
|
|
5225
5312
|
}
|
|
5226
5313
|
if (layout.localBoxChanged) {
|
|
5227
5314
|
if (this.__local)
|
|
5228
5315
|
this.__updateLocalBoxBounds();
|
|
5229
|
-
layout.localBoxChanged =
|
|
5316
|
+
layout.localBoxChanged = undefined;
|
|
5230
5317
|
if (layout.strokeSpread)
|
|
5231
5318
|
layout.strokeChanged = true;
|
|
5232
5319
|
if (layout.renderSpread)
|
|
@@ -5234,7 +5321,7 @@ var LeaferUI = (function (exports) {
|
|
|
5234
5321
|
if (this.parent)
|
|
5235
5322
|
this.parent.__layout.boxChange();
|
|
5236
5323
|
}
|
|
5237
|
-
layout.boxChanged =
|
|
5324
|
+
layout.boxChanged = undefined;
|
|
5238
5325
|
if (layout.strokeChanged) {
|
|
5239
5326
|
layout.strokeSpread = this.__updateStrokeSpread();
|
|
5240
5327
|
if (layout.strokeSpread) {
|
|
@@ -5246,12 +5333,12 @@ var LeaferUI = (function (exports) {
|
|
|
5246
5333
|
else {
|
|
5247
5334
|
layout.spreadStrokeCancel();
|
|
5248
5335
|
}
|
|
5249
|
-
layout.strokeChanged =
|
|
5336
|
+
layout.strokeChanged = undefined;
|
|
5250
5337
|
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
|
|
5251
5338
|
layout.renderChanged = true;
|
|
5252
5339
|
if (this.parent)
|
|
5253
5340
|
this.parent.__layout.strokeChange();
|
|
5254
|
-
layout.resized =
|
|
5341
|
+
layout.resized = 'inner';
|
|
5255
5342
|
}
|
|
5256
5343
|
if (layout.renderChanged) {
|
|
5257
5344
|
layout.renderSpread = this.__updateRenderSpread();
|
|
@@ -5264,11 +5351,12 @@ var LeaferUI = (function (exports) {
|
|
|
5264
5351
|
else {
|
|
5265
5352
|
layout.spreadRenderCancel();
|
|
5266
5353
|
}
|
|
5267
|
-
layout.renderChanged =
|
|
5354
|
+
layout.renderChanged = undefined;
|
|
5268
5355
|
if (this.parent)
|
|
5269
5356
|
this.parent.__layout.renderChange();
|
|
5270
5357
|
}
|
|
5271
|
-
layout.
|
|
5358
|
+
layout.resized || (layout.resized = 'local');
|
|
5359
|
+
layout.boundsChanged = undefined;
|
|
5272
5360
|
},
|
|
5273
5361
|
__updateLocalBoxBounds() {
|
|
5274
5362
|
if (this.__hasMotionPath)
|
|
@@ -5328,7 +5416,7 @@ var LeaferUI = (function (exports) {
|
|
|
5328
5416
|
},
|
|
5329
5417
|
__updateRenderBounds() {
|
|
5330
5418
|
const layout = this.__layout;
|
|
5331
|
-
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$
|
|
5419
|
+
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5332
5420
|
}
|
|
5333
5421
|
};
|
|
5334
5422
|
|
|
@@ -5433,7 +5521,7 @@ var LeaferUI = (function (exports) {
|
|
|
5433
5521
|
const { LEAF, create } = IncrementId;
|
|
5434
5522
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5435
5523
|
const { toOuterOf } = BoundsHelper;
|
|
5436
|
-
const { copy: copy$
|
|
5524
|
+
const { copy: copy$4, move } = PointHelper;
|
|
5437
5525
|
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5438
5526
|
exports.Leaf = class Leaf {
|
|
5439
5527
|
get tag() { return this.__tag; }
|
|
@@ -5646,7 +5734,7 @@ var LeaferUI = (function (exports) {
|
|
|
5646
5734
|
}
|
|
5647
5735
|
else {
|
|
5648
5736
|
if (to)
|
|
5649
|
-
copy$
|
|
5737
|
+
copy$4(to, world);
|
|
5650
5738
|
}
|
|
5651
5739
|
}
|
|
5652
5740
|
localToWorld(local, to, distance, relative) {
|
|
@@ -5655,7 +5743,7 @@ var LeaferUI = (function (exports) {
|
|
|
5655
5743
|
}
|
|
5656
5744
|
else {
|
|
5657
5745
|
if (to)
|
|
5658
|
-
copy$
|
|
5746
|
+
copy$4(to, local);
|
|
5659
5747
|
}
|
|
5660
5748
|
}
|
|
5661
5749
|
worldToInner(world, to, distance, relative) {
|
|
@@ -5808,7 +5896,7 @@ var LeaferUI = (function (exports) {
|
|
|
5808
5896
|
off(_type, _listener, _options) { }
|
|
5809
5897
|
on_(_type, _listener, _bind, _options) { return undefined; }
|
|
5810
5898
|
off_(_id) { }
|
|
5811
|
-
once(_type, _listener, _capture) { }
|
|
5899
|
+
once(_type, _listener, _captureOrBind, _capture) { }
|
|
5812
5900
|
emit(_type, _event, _capture) { }
|
|
5813
5901
|
emitEvent(_event, _capture) { }
|
|
5814
5902
|
hasEvent(_type, _capture) { return false; }
|
|
@@ -6145,7 +6233,7 @@ var LeaferUI = (function (exports) {
|
|
|
6145
6233
|
}
|
|
6146
6234
|
}
|
|
6147
6235
|
|
|
6148
|
-
const version = "1.6.
|
|
6236
|
+
const version = "1.6.3";
|
|
6149
6237
|
|
|
6150
6238
|
const debug$4 = Debug.get('LeaferCanvas');
|
|
6151
6239
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6485,17 +6573,15 @@ var LeaferUI = (function (exports) {
|
|
|
6485
6573
|
this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
|
|
6486
6574
|
this.__updatedList = new LeafList();
|
|
6487
6575
|
this.totalTimes++;
|
|
6488
|
-
this.changed = false;
|
|
6489
|
-
this.hasVisible = false;
|
|
6490
|
-
this.hasRemove = false;
|
|
6491
|
-
this.hasAdd = false;
|
|
6576
|
+
this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
|
|
6492
6577
|
}
|
|
6493
6578
|
__listenEvents() {
|
|
6494
|
-
const { target } = this;
|
|
6495
6579
|
this.__eventIds = [
|
|
6496
|
-
target.on_(
|
|
6497
|
-
|
|
6498
|
-
|
|
6580
|
+
this.target.on_([
|
|
6581
|
+
[PropertyEvent.CHANGE, this.__onAttrChange, this],
|
|
6582
|
+
[[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
|
|
6583
|
+
[WatchEvent.REQUEST, this.__onRquestData, this]
|
|
6584
|
+
])
|
|
6499
6585
|
];
|
|
6500
6586
|
}
|
|
6501
6587
|
__removeListenEvents() {
|
|
@@ -6505,8 +6591,7 @@ var LeaferUI = (function (exports) {
|
|
|
6505
6591
|
if (this.target) {
|
|
6506
6592
|
this.stop();
|
|
6507
6593
|
this.__removeListenEvents();
|
|
6508
|
-
this.target = null;
|
|
6509
|
-
this.__updatedList = null;
|
|
6594
|
+
this.target = this.__updatedList = null;
|
|
6510
6595
|
}
|
|
6511
6596
|
}
|
|
6512
6597
|
}
|
|
@@ -6611,7 +6696,7 @@ var LeaferUI = (function (exports) {
|
|
|
6611
6696
|
this.disabled = true;
|
|
6612
6697
|
}
|
|
6613
6698
|
layout() {
|
|
6614
|
-
if (!this.running)
|
|
6699
|
+
if (this.layouting || !this.running)
|
|
6615
6700
|
return;
|
|
6616
6701
|
const { target } = this;
|
|
6617
6702
|
this.times = 0;
|
|
@@ -6694,12 +6779,10 @@ var LeaferUI = (function (exports) {
|
|
|
6694
6779
|
}
|
|
6695
6780
|
static fullLayout(target) {
|
|
6696
6781
|
updateAllMatrix(target, true);
|
|
6697
|
-
if (target.isBranch)
|
|
6782
|
+
if (target.isBranch)
|
|
6698
6783
|
BranchHelper.updateBounds(target);
|
|
6699
|
-
|
|
6700
|
-
else {
|
|
6784
|
+
else
|
|
6701
6785
|
LeafHelper.updateBounds(target);
|
|
6702
|
-
}
|
|
6703
6786
|
updateAllChange(target);
|
|
6704
6787
|
}
|
|
6705
6788
|
addExtra(leaf) {
|
|
@@ -6722,11 +6805,12 @@ var LeaferUI = (function (exports) {
|
|
|
6722
6805
|
this.__updatedList = event.data.updatedList;
|
|
6723
6806
|
}
|
|
6724
6807
|
__listenEvents() {
|
|
6725
|
-
const { target } = this;
|
|
6726
6808
|
this.__eventIds = [
|
|
6727
|
-
target.on_(
|
|
6728
|
-
|
|
6729
|
-
|
|
6809
|
+
this.target.on_([
|
|
6810
|
+
[LayoutEvent.REQUEST, this.layout, this],
|
|
6811
|
+
[LayoutEvent.AGAIN, this.layoutAgain, this],
|
|
6812
|
+
[WatchEvent.DATA, this.__onReceiveWatchData, this]
|
|
6813
|
+
])
|
|
6730
6814
|
];
|
|
6731
6815
|
}
|
|
6732
6816
|
__removeListenEvents() {
|
|
@@ -6957,12 +7041,13 @@ var LeaferUI = (function (exports) {
|
|
|
6957
7041
|
this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
|
|
6958
7042
|
}
|
|
6959
7043
|
__listenEvents() {
|
|
6960
|
-
const { target } = this;
|
|
6961
7044
|
this.__eventIds = [
|
|
6962
|
-
target.on_(
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
7045
|
+
this.target.on_([
|
|
7046
|
+
[RenderEvent.REQUEST, this.update, this],
|
|
7047
|
+
[LayoutEvent.END, this.__onLayoutEnd, this],
|
|
7048
|
+
[RenderEvent.AGAIN, this.renderAgain, this],
|
|
7049
|
+
[ResizeEvent.RESIZE, this.__onResize, this]
|
|
7050
|
+
])
|
|
6966
7051
|
];
|
|
6967
7052
|
}
|
|
6968
7053
|
__removeListenEvents() {
|
|
@@ -7021,8 +7106,32 @@ var LeaferUI = (function (exports) {
|
|
|
7021
7106
|
};
|
|
7022
7107
|
}
|
|
7023
7108
|
|
|
7109
|
+
function hasTransparent$3(color) {
|
|
7110
|
+
if (!color || color.length === 7 || color.length === 4)
|
|
7111
|
+
return false;
|
|
7112
|
+
if (color === 'transparent')
|
|
7113
|
+
return true;
|
|
7114
|
+
const first = color[0];
|
|
7115
|
+
if (first === '#') {
|
|
7116
|
+
switch (color.length) {
|
|
7117
|
+
case 5: return color[4] !== 'f' && color[4] !== 'F';
|
|
7118
|
+
case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
|
|
7119
|
+
}
|
|
7120
|
+
}
|
|
7121
|
+
else if (first === 'r' || first === 'h') {
|
|
7122
|
+
if (color[3] === 'a') {
|
|
7123
|
+
const i = color.lastIndexOf(',');
|
|
7124
|
+
if (i > -1)
|
|
7125
|
+
return parseFloat(color.slice(i + 1)) < 1;
|
|
7126
|
+
}
|
|
7127
|
+
}
|
|
7128
|
+
return false;
|
|
7129
|
+
}
|
|
7130
|
+
|
|
7024
7131
|
const TextConvert = {};
|
|
7025
|
-
const ColorConvert = {
|
|
7132
|
+
const ColorConvert = {
|
|
7133
|
+
hasTransparent: hasTransparent$3
|
|
7134
|
+
};
|
|
7026
7135
|
const UnitConvert = {
|
|
7027
7136
|
number(value, percentRefer) {
|
|
7028
7137
|
return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
|
|
@@ -7048,6 +7157,7 @@ var LeaferUI = (function (exports) {
|
|
|
7048
7157
|
};
|
|
7049
7158
|
|
|
7050
7159
|
const { parse, objectToCanvasData } = PathConvert;
|
|
7160
|
+
const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
|
|
7051
7161
|
const emptyPaint = {};
|
|
7052
7162
|
const debug$1 = Debug.get('UIData');
|
|
7053
7163
|
class UIData extends LeafData {
|
|
@@ -7106,38 +7216,22 @@ var LeaferUI = (function (exports) {
|
|
|
7106
7216
|
if (this.__naturalWidth)
|
|
7107
7217
|
this.__removeNaturalSize();
|
|
7108
7218
|
if (typeof value === 'string' || !value) {
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
PaintImage.recycleImage('fill', this);
|
|
7112
|
-
this.__isFills = false;
|
|
7113
|
-
this.__pixelFill && (this.__pixelFill = false);
|
|
7114
|
-
}
|
|
7219
|
+
stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
|
|
7220
|
+
this.__isFills && this.__removePaint('fill', true);
|
|
7115
7221
|
this._fill = value;
|
|
7116
7222
|
}
|
|
7117
7223
|
else if (typeof value === 'object') {
|
|
7118
|
-
this.
|
|
7119
|
-
const layout = this.__leaf.__layout;
|
|
7120
|
-
layout.boxChanged || layout.boxChange();
|
|
7121
|
-
this.__isFills = true;
|
|
7122
|
-
this._fill || (this._fill = emptyPaint);
|
|
7224
|
+
this.__setPaint('fill', value);
|
|
7123
7225
|
}
|
|
7124
7226
|
}
|
|
7125
7227
|
setStroke(value) {
|
|
7126
7228
|
if (typeof value === 'string' || !value) {
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
PaintImage.recycleImage('stroke', this);
|
|
7130
|
-
this.__isStrokes = false;
|
|
7131
|
-
this.__pixelStroke && (this.__pixelStroke = false);
|
|
7132
|
-
}
|
|
7229
|
+
stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
|
|
7230
|
+
this.__isStrokes && this.__removePaint('stroke', true);
|
|
7133
7231
|
this._stroke = value;
|
|
7134
7232
|
}
|
|
7135
7233
|
else if (typeof value === 'object') {
|
|
7136
|
-
this.
|
|
7137
|
-
const layout = this.__leaf.__layout;
|
|
7138
|
-
layout.boxChanged || layout.boxChange();
|
|
7139
|
-
this.__isStrokes = true;
|
|
7140
|
-
this._stroke || (this._stroke = emptyPaint);
|
|
7234
|
+
this.__setPaint('stroke', value);
|
|
7141
7235
|
}
|
|
7142
7236
|
}
|
|
7143
7237
|
setPath(value) {
|
|
@@ -7167,7 +7261,34 @@ var LeaferUI = (function (exports) {
|
|
|
7167
7261
|
Paint.compute('fill', this.__leaf);
|
|
7168
7262
|
if (stroke)
|
|
7169
7263
|
Paint.compute('stroke', this.__leaf);
|
|
7170
|
-
this.__needComputePaint =
|
|
7264
|
+
this.__needComputePaint = undefined;
|
|
7265
|
+
}
|
|
7266
|
+
__setPaint(attrName, value) {
|
|
7267
|
+
this.__setInput(attrName, value);
|
|
7268
|
+
const layout = this.__leaf.__layout;
|
|
7269
|
+
layout.boxChanged || layout.boxChange();
|
|
7270
|
+
if (value instanceof Array && !value.length) {
|
|
7271
|
+
this.__removePaint(attrName);
|
|
7272
|
+
}
|
|
7273
|
+
else {
|
|
7274
|
+
if (attrName === 'fill')
|
|
7275
|
+
this.__isFills = true, this._fill || (this._fill = emptyPaint);
|
|
7276
|
+
else
|
|
7277
|
+
this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
|
|
7278
|
+
}
|
|
7279
|
+
}
|
|
7280
|
+
__removePaint(attrName, removeInput) {
|
|
7281
|
+
if (removeInput)
|
|
7282
|
+
this.__removeInput(attrName);
|
|
7283
|
+
PaintImage.recycleImage(attrName, this);
|
|
7284
|
+
if (attrName === 'fill') {
|
|
7285
|
+
stintSet$2(this, '__isAlphaPixelFill', undefined);
|
|
7286
|
+
this._fill = this.__isFills = undefined;
|
|
7287
|
+
}
|
|
7288
|
+
else {
|
|
7289
|
+
stintSet$2(this, '__isAlphaPixelStroke', undefined);
|
|
7290
|
+
this._stroke = this.__isStrokes = undefined;
|
|
7291
|
+
}
|
|
7171
7292
|
}
|
|
7172
7293
|
}
|
|
7173
7294
|
function setArray(data, key, value) {
|
|
@@ -7175,10 +7296,10 @@ var LeaferUI = (function (exports) {
|
|
|
7175
7296
|
if (value instanceof Array) {
|
|
7176
7297
|
if (value.some((item) => item.visible === false))
|
|
7177
7298
|
value = value.filter((item) => item.visible !== false);
|
|
7178
|
-
value.length || (value =
|
|
7299
|
+
value.length || (value = undefined);
|
|
7179
7300
|
}
|
|
7180
7301
|
else
|
|
7181
|
-
value = value && value.visible !== false ? [value] :
|
|
7302
|
+
value = value && value.visible !== false ? [value] : undefined;
|
|
7182
7303
|
data['_' + key] = value;
|
|
7183
7304
|
}
|
|
7184
7305
|
|
|
@@ -7281,8 +7402,6 @@ var LeaferUI = (function (exports) {
|
|
|
7281
7402
|
this._url = value;
|
|
7282
7403
|
}
|
|
7283
7404
|
__setImageFill(value) {
|
|
7284
|
-
if (this.__leaf.image)
|
|
7285
|
-
this.__leaf.image = null;
|
|
7286
7405
|
this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
|
|
7287
7406
|
}
|
|
7288
7407
|
__getData() {
|
|
@@ -7348,21 +7467,19 @@ var LeaferUI = (function (exports) {
|
|
|
7348
7467
|
}
|
|
7349
7468
|
};
|
|
7350
7469
|
|
|
7470
|
+
const { stintSet: stintSet$1 } = DataHelper;
|
|
7351
7471
|
const UIRender = {
|
|
7352
7472
|
__updateChange() {
|
|
7353
|
-
const data = this.__
|
|
7473
|
+
const data = this.__;
|
|
7354
7474
|
if (data.__useEffect) {
|
|
7355
|
-
const { shadow,
|
|
7356
|
-
data.
|
|
7475
|
+
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7476
|
+
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')));
|
|
7477
|
+
data.__useEffect = !!(shadow || otherEffect);
|
|
7357
7478
|
}
|
|
7358
|
-
|
|
7359
|
-
|
|
7479
|
+
stintSet$1(this.__world, 'half', data.__hasHalf);
|
|
7480
|
+
stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7360
7481
|
data.__checkSingle();
|
|
7361
|
-
|
|
7362
|
-
if (complex)
|
|
7363
|
-
data.__complex = true;
|
|
7364
|
-
else
|
|
7365
|
-
data.__complex && (data.__complex = false);
|
|
7482
|
+
stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7366
7483
|
},
|
|
7367
7484
|
__drawFast(canvas, options) {
|
|
7368
7485
|
drawFast(this, canvas, options);
|
|
@@ -7372,21 +7489,23 @@ var LeaferUI = (function (exports) {
|
|
|
7372
7489
|
if (data.__complex) {
|
|
7373
7490
|
if (data.__needComputePaint)
|
|
7374
7491
|
data.__computePaint();
|
|
7375
|
-
const { fill, stroke, __drawAfterFill } = data;
|
|
7492
|
+
const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
|
|
7376
7493
|
this.__drawRenderPath(canvas);
|
|
7377
|
-
if (data.__useEffect) {
|
|
7494
|
+
if (data.__useEffect && !__isFastShadow) {
|
|
7378
7495
|
const shape = Paint.shape(this, canvas, options);
|
|
7379
7496
|
this.__nowWorld = this.__getNowWorld(options);
|
|
7380
7497
|
const { shadow, innerShadow, filter } = data;
|
|
7381
7498
|
if (shadow)
|
|
7382
7499
|
Effect.shadow(this, canvas, shape);
|
|
7500
|
+
if (__fillAfterStroke)
|
|
7501
|
+
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7383
7502
|
if (fill)
|
|
7384
7503
|
data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7385
7504
|
if (__drawAfterFill)
|
|
7386
7505
|
this.__drawAfterFill(canvas, options);
|
|
7387
7506
|
if (innerShadow)
|
|
7388
7507
|
Effect.innerShadow(this, canvas, shape);
|
|
7389
|
-
if (stroke)
|
|
7508
|
+
if (stroke && !__fillAfterStroke)
|
|
7390
7509
|
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7391
7510
|
if (filter)
|
|
7392
7511
|
Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
|
|
@@ -7395,21 +7514,27 @@ var LeaferUI = (function (exports) {
|
|
|
7395
7514
|
shape.canvas.recycle();
|
|
7396
7515
|
}
|
|
7397
7516
|
else {
|
|
7517
|
+
if (__fillAfterStroke)
|
|
7518
|
+
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7519
|
+
if (__isFastShadow) {
|
|
7520
|
+
const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
|
|
7521
|
+
canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
|
|
7522
|
+
}
|
|
7398
7523
|
if (fill)
|
|
7399
7524
|
data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
|
|
7525
|
+
if (__isFastShadow)
|
|
7526
|
+
canvas.restore();
|
|
7400
7527
|
if (__drawAfterFill)
|
|
7401
7528
|
this.__drawAfterFill(canvas, options);
|
|
7402
|
-
if (stroke)
|
|
7529
|
+
if (stroke && !__fillAfterStroke)
|
|
7403
7530
|
data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
|
|
7404
7531
|
}
|
|
7405
7532
|
}
|
|
7406
7533
|
else {
|
|
7407
|
-
if (data.__pathInputed)
|
|
7534
|
+
if (data.__pathInputed)
|
|
7408
7535
|
drawFast(this, canvas, options);
|
|
7409
|
-
|
|
7410
|
-
else {
|
|
7536
|
+
else
|
|
7411
7537
|
this.__drawFast(canvas, options);
|
|
7412
|
-
}
|
|
7413
7538
|
}
|
|
7414
7539
|
},
|
|
7415
7540
|
__renderShape(canvas, options, ignoreFill, ignoreStroke) {
|
|
@@ -7418,11 +7543,11 @@ var LeaferUI = (function (exports) {
|
|
|
7418
7543
|
const { fill, stroke } = this.__;
|
|
7419
7544
|
this.__drawRenderPath(canvas);
|
|
7420
7545
|
if (fill && !ignoreFill)
|
|
7421
|
-
this.__.
|
|
7546
|
+
this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
7422
7547
|
if (this.__.__isCanvas)
|
|
7423
7548
|
this.__drawAfterFill(canvas, options);
|
|
7424
7549
|
if (stroke && !ignoreStroke)
|
|
7425
|
-
this.__.
|
|
7550
|
+
this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7426
7551
|
}
|
|
7427
7552
|
},
|
|
7428
7553
|
__drawAfterFill(canvas, options) {
|
|
@@ -7437,13 +7562,15 @@ var LeaferUI = (function (exports) {
|
|
|
7437
7562
|
}
|
|
7438
7563
|
};
|
|
7439
7564
|
function drawFast(ui, canvas, options) {
|
|
7440
|
-
const { fill, stroke, __drawAfterFill } = ui.__;
|
|
7565
|
+
const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
|
|
7441
7566
|
ui.__drawRenderPath(canvas);
|
|
7567
|
+
if (__fillAfterStroke)
|
|
7568
|
+
Paint.stroke(stroke, ui, canvas);
|
|
7442
7569
|
if (fill)
|
|
7443
7570
|
Paint.fill(fill, ui, canvas);
|
|
7444
7571
|
if (__drawAfterFill)
|
|
7445
7572
|
ui.__drawAfterFill(canvas, options);
|
|
7446
|
-
if (stroke)
|
|
7573
|
+
if (stroke && !__fillAfterStroke)
|
|
7447
7574
|
Paint.stroke(stroke, ui, canvas);
|
|
7448
7575
|
}
|
|
7449
7576
|
|
|
@@ -7815,6 +7942,9 @@ var LeaferUI = (function (exports) {
|
|
|
7815
7942
|
__decorate([
|
|
7816
7943
|
surfaceType()
|
|
7817
7944
|
], exports.UI.prototype, "placeholderColor", void 0);
|
|
7945
|
+
__decorate([
|
|
7946
|
+
dataType(100)
|
|
7947
|
+
], exports.UI.prototype, "placeholderDelay", void 0);
|
|
7818
7948
|
__decorate([
|
|
7819
7949
|
dataType({})
|
|
7820
7950
|
], exports.UI.prototype, "data", void 0);
|
|
@@ -8216,15 +8346,20 @@ var LeaferUI = (function (exports) {
|
|
|
8216
8346
|
}
|
|
8217
8347
|
__listenEvents() {
|
|
8218
8348
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
8219
|
-
this.once(
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8349
|
+
this.once([
|
|
8350
|
+
[LeaferEvent.START, () => Run.end(runId)],
|
|
8351
|
+
[LayoutEvent.START, this.updateLazyBounds, this],
|
|
8352
|
+
[RenderEvent.START, this.__onCreated, this],
|
|
8353
|
+
[RenderEvent.END, this.__onViewReady, this]
|
|
8354
|
+
]);
|
|
8355
|
+
this.__eventIds.push(this.on_([
|
|
8356
|
+
[WatchEvent.DATA, this.__onWatchData, this],
|
|
8357
|
+
[LayoutEvent.END, this.__onLayoutEnd, this],
|
|
8358
|
+
[RenderEvent.NEXT, this.__onNextRender, this]
|
|
8359
|
+
]));
|
|
8224
8360
|
}
|
|
8225
8361
|
__removeListenEvents() {
|
|
8226
8362
|
this.off_(this.__eventIds);
|
|
8227
|
-
this.__eventIds.length = 0;
|
|
8228
8363
|
}
|
|
8229
8364
|
destroy(sync) {
|
|
8230
8365
|
const doDestory = () => {
|
|
@@ -8284,8 +8419,8 @@ var LeaferUI = (function (exports) {
|
|
|
8284
8419
|
registerUI()
|
|
8285
8420
|
], exports.Rect);
|
|
8286
8421
|
|
|
8287
|
-
const { copy: copy$
|
|
8288
|
-
const rect = exports.Rect.prototype, group = exports.Group.prototype;
|
|
8422
|
+
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8423
|
+
const rect$1 = exports.Rect.prototype, group = exports.Group.prototype;
|
|
8289
8424
|
const childrenRenderBounds = {};
|
|
8290
8425
|
exports.Box = class Box extends exports.Group {
|
|
8291
8426
|
get __tag() { return 'Box'; }
|
|
@@ -8330,15 +8465,15 @@ var LeaferUI = (function (exports) {
|
|
|
8330
8465
|
const { renderBounds } = this.__layout;
|
|
8331
8466
|
if (this.children.length) {
|
|
8332
8467
|
super.__updateRenderBounds();
|
|
8333
|
-
copy$
|
|
8468
|
+
copy$3(childrenRenderBounds, renderBounds);
|
|
8334
8469
|
this.__updateRectRenderBounds();
|
|
8335
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds)
|
|
8470
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds);
|
|
8336
8471
|
if (isOverflow && this.__.overflow !== 'hide')
|
|
8337
8472
|
add(renderBounds, childrenRenderBounds);
|
|
8338
8473
|
}
|
|
8339
8474
|
else
|
|
8340
8475
|
this.__updateRectRenderBounds();
|
|
8341
|
-
|
|
8476
|
+
DataHelper.stintSet(this, 'isOverflow', isOverflow);
|
|
8342
8477
|
}
|
|
8343
8478
|
__updateRectRenderBounds() { }
|
|
8344
8479
|
__updateRectChange() { }
|
|
@@ -8382,25 +8517,25 @@ var LeaferUI = (function (exports) {
|
|
|
8382
8517
|
affectRenderBoundsType('show')
|
|
8383
8518
|
], exports.Box.prototype, "overflow", void 0);
|
|
8384
8519
|
__decorate([
|
|
8385
|
-
rewrite(rect.__updateStrokeSpread)
|
|
8520
|
+
rewrite(rect$1.__updateStrokeSpread)
|
|
8386
8521
|
], exports.Box.prototype, "__updateStrokeSpread", null);
|
|
8387
8522
|
__decorate([
|
|
8388
|
-
rewrite(rect.__updateRenderSpread)
|
|
8523
|
+
rewrite(rect$1.__updateRenderSpread)
|
|
8389
8524
|
], exports.Box.prototype, "__updateRectRenderSpread", null);
|
|
8390
8525
|
__decorate([
|
|
8391
|
-
rewrite(rect.__updateBoxBounds)
|
|
8526
|
+
rewrite(rect$1.__updateBoxBounds)
|
|
8392
8527
|
], exports.Box.prototype, "__updateRectBoxBounds", null);
|
|
8393
8528
|
__decorate([
|
|
8394
|
-
rewrite(rect.__updateStrokeBounds)
|
|
8529
|
+
rewrite(rect$1.__updateStrokeBounds)
|
|
8395
8530
|
], exports.Box.prototype, "__updateStrokeBounds", null);
|
|
8396
8531
|
__decorate([
|
|
8397
|
-
rewrite(rect.__updateRenderBounds)
|
|
8532
|
+
rewrite(rect$1.__updateRenderBounds)
|
|
8398
8533
|
], exports.Box.prototype, "__updateRectRenderBounds", null);
|
|
8399
8534
|
__decorate([
|
|
8400
|
-
rewrite(rect.__updateChange)
|
|
8535
|
+
rewrite(rect$1.__updateChange)
|
|
8401
8536
|
], exports.Box.prototype, "__updateRectChange", null);
|
|
8402
8537
|
__decorate([
|
|
8403
|
-
rewrite(rect.__render)
|
|
8538
|
+
rewrite(rect$1.__render)
|
|
8404
8539
|
], exports.Box.prototype, "__renderRect", null);
|
|
8405
8540
|
__decorate([
|
|
8406
8541
|
rewrite(group.__render)
|
|
@@ -8642,18 +8777,10 @@ var LeaferUI = (function (exports) {
|
|
|
8642
8777
|
|
|
8643
8778
|
exports.Image = class Image extends exports.Rect {
|
|
8644
8779
|
get __tag() { return 'Image'; }
|
|
8645
|
-
get ready() {
|
|
8780
|
+
get ready() { const { image } = this; return image && image.ready; }
|
|
8781
|
+
get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
|
|
8646
8782
|
constructor(data) {
|
|
8647
8783
|
super(data);
|
|
8648
|
-
this.on_(ImageEvent.LOADED, this.__onLoaded, this);
|
|
8649
|
-
}
|
|
8650
|
-
__onLoaded(e) {
|
|
8651
|
-
if (e.attrName === 'fill' && e.attrValue.url === this.url)
|
|
8652
|
-
this.image = e.image;
|
|
8653
|
-
}
|
|
8654
|
-
destroy() {
|
|
8655
|
-
this.image = null;
|
|
8656
|
-
super.destroy();
|
|
8657
8784
|
}
|
|
8658
8785
|
};
|
|
8659
8786
|
__decorate([
|
|
@@ -8669,11 +8796,11 @@ var LeaferUI = (function (exports) {
|
|
|
8669
8796
|
|
|
8670
8797
|
exports.Canvas = class Canvas extends exports.Rect {
|
|
8671
8798
|
get __tag() { return 'Canvas'; }
|
|
8799
|
+
get context() { return this.canvas.context; }
|
|
8672
8800
|
get ready() { return !this.url; }
|
|
8673
8801
|
constructor(data) {
|
|
8674
8802
|
super(data);
|
|
8675
8803
|
this.canvas = Creator.canvas(this.__);
|
|
8676
|
-
this.context = this.canvas.context;
|
|
8677
8804
|
if (data && data.url)
|
|
8678
8805
|
this.drawImage(data.url);
|
|
8679
8806
|
}
|
|
@@ -8717,7 +8844,7 @@ var LeaferUI = (function (exports) {
|
|
|
8717
8844
|
destroy() {
|
|
8718
8845
|
if (this.canvas) {
|
|
8719
8846
|
this.canvas.destroy();
|
|
8720
|
-
this.canvas =
|
|
8847
|
+
this.canvas = null;
|
|
8721
8848
|
}
|
|
8722
8849
|
super.destroy();
|
|
8723
8850
|
}
|
|
@@ -8793,12 +8920,11 @@ var LeaferUI = (function (exports) {
|
|
|
8793
8920
|
super.__updateBoxBounds();
|
|
8794
8921
|
if (italic)
|
|
8795
8922
|
b.width += fontSize * 0.16;
|
|
8796
|
-
|
|
8797
|
-
if (isOverflow)
|
|
8923
|
+
DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
|
|
8924
|
+
if (this.isOverflow)
|
|
8798
8925
|
setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
|
|
8799
8926
|
else
|
|
8800
8927
|
data.__textBoxBounds = b;
|
|
8801
|
-
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8802
8928
|
}
|
|
8803
8929
|
__onUpdateSize() {
|
|
8804
8930
|
if (this.__box)
|
|
@@ -9043,32 +9169,557 @@ var LeaferUI = (function (exports) {
|
|
|
9043
9169
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
9044
9170
|
}
|
|
9045
9171
|
|
|
9172
|
+
let App = class App extends exports.Leafer {
|
|
9173
|
+
get __tag() { return 'App'; }
|
|
9174
|
+
get isApp() { return true; }
|
|
9175
|
+
constructor(userConfig, data) {
|
|
9176
|
+
super(userConfig, data);
|
|
9177
|
+
}
|
|
9178
|
+
init(userConfig, parentApp) {
|
|
9179
|
+
super.init(userConfig, parentApp);
|
|
9180
|
+
if (userConfig) {
|
|
9181
|
+
const { ground, tree, sky, editor } = userConfig;
|
|
9182
|
+
if (ground)
|
|
9183
|
+
this.ground = this.addLeafer(ground);
|
|
9184
|
+
if (tree || editor)
|
|
9185
|
+
this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
|
|
9186
|
+
if (sky || editor)
|
|
9187
|
+
this.sky = this.addLeafer(sky);
|
|
9188
|
+
if (editor)
|
|
9189
|
+
Creator.editor(editor, this);
|
|
9190
|
+
}
|
|
9191
|
+
}
|
|
9192
|
+
__setApp() {
|
|
9193
|
+
const { canvas } = this;
|
|
9194
|
+
const { realCanvas, view } = this.config;
|
|
9195
|
+
if (realCanvas || view === this.canvas.view || !canvas.parentView)
|
|
9196
|
+
this.realCanvas = true;
|
|
9197
|
+
else
|
|
9198
|
+
canvas.unrealCanvas();
|
|
9199
|
+
this.leafer = this;
|
|
9200
|
+
this.watcher.disable();
|
|
9201
|
+
this.layouter.disable();
|
|
9202
|
+
}
|
|
9203
|
+
__updateLocalBounds() {
|
|
9204
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9205
|
+
super.__updateLocalBounds();
|
|
9206
|
+
}
|
|
9207
|
+
start() {
|
|
9208
|
+
super.start();
|
|
9209
|
+
this.forEach(leafer => leafer.start());
|
|
9210
|
+
}
|
|
9211
|
+
stop() {
|
|
9212
|
+
this.forEach(leafer => leafer.stop());
|
|
9213
|
+
super.stop();
|
|
9214
|
+
}
|
|
9215
|
+
unlockLayout() {
|
|
9216
|
+
super.unlockLayout();
|
|
9217
|
+
this.forEach(leafer => leafer.unlockLayout());
|
|
9218
|
+
}
|
|
9219
|
+
lockLayout() {
|
|
9220
|
+
super.lockLayout();
|
|
9221
|
+
this.forEach(leafer => leafer.lockLayout());
|
|
9222
|
+
}
|
|
9223
|
+
forceRender(bounds, sync) {
|
|
9224
|
+
this.forEach(leafer => leafer.forceRender(bounds, sync));
|
|
9225
|
+
}
|
|
9226
|
+
addLeafer(merge) {
|
|
9227
|
+
const leafer = new exports.Leafer(merge);
|
|
9228
|
+
this.add(leafer);
|
|
9229
|
+
return leafer;
|
|
9230
|
+
}
|
|
9231
|
+
add(leafer, index) {
|
|
9232
|
+
if (!leafer.view) {
|
|
9233
|
+
if (this.realCanvas && !this.canvas.bounds) {
|
|
9234
|
+
setTimeout(() => this.add(leafer, index), 10);
|
|
9235
|
+
return;
|
|
9236
|
+
}
|
|
9237
|
+
leafer.init(this.__getChildConfig(leafer.userConfig), this);
|
|
9238
|
+
}
|
|
9239
|
+
super.add(leafer, index);
|
|
9240
|
+
if (index !== undefined)
|
|
9241
|
+
leafer.canvas.childIndex = index;
|
|
9242
|
+
this.__listenChildEvents(leafer);
|
|
9243
|
+
}
|
|
9244
|
+
forEach(fn) {
|
|
9245
|
+
this.children.forEach(fn);
|
|
9246
|
+
}
|
|
9247
|
+
__onCreated() {
|
|
9248
|
+
this.created = this.children.every(child => child.created);
|
|
9249
|
+
}
|
|
9250
|
+
__onReady() {
|
|
9251
|
+
if (this.children.every(child => child.ready))
|
|
9252
|
+
super.__onReady();
|
|
9253
|
+
}
|
|
9254
|
+
__onViewReady() {
|
|
9255
|
+
if (this.children.every(child => child.viewReady))
|
|
9256
|
+
super.__onViewReady();
|
|
9257
|
+
}
|
|
9258
|
+
__onChildRenderEnd(e) {
|
|
9259
|
+
this.renderer.addBlock(e.renderBounds);
|
|
9260
|
+
if (this.viewReady)
|
|
9261
|
+
this.renderer.update();
|
|
9262
|
+
}
|
|
9263
|
+
__render(canvas, options) {
|
|
9264
|
+
if (canvas.context)
|
|
9265
|
+
this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
|
|
9266
|
+
}
|
|
9267
|
+
__onResize(event) {
|
|
9268
|
+
this.forEach(leafer => leafer.resize(event));
|
|
9269
|
+
super.__onResize(event);
|
|
9270
|
+
}
|
|
9271
|
+
updateLayout() {
|
|
9272
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9273
|
+
}
|
|
9274
|
+
__getChildConfig(userConfig) {
|
|
9275
|
+
const config = Object.assign({}, this.config);
|
|
9276
|
+
config.hittable = config.realCanvas = undefined;
|
|
9277
|
+
if (userConfig)
|
|
9278
|
+
DataHelper.assign(config, userConfig);
|
|
9279
|
+
if (this.autoLayout)
|
|
9280
|
+
DataHelper.copyAttrs(config, this, canvasSizeAttrs);
|
|
9281
|
+
config.view = this.realCanvas ? undefined : this.view;
|
|
9282
|
+
config.fill = undefined;
|
|
9283
|
+
return config;
|
|
9284
|
+
}
|
|
9285
|
+
__listenChildEvents(leafer) {
|
|
9286
|
+
leafer.once([
|
|
9287
|
+
[LayoutEvent.END, this.__onReady, this],
|
|
9288
|
+
[RenderEvent.START, this.__onCreated, this],
|
|
9289
|
+
[RenderEvent.END, this.__onViewReady, this]
|
|
9290
|
+
]);
|
|
9291
|
+
if (this.realCanvas)
|
|
9292
|
+
this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
|
|
9293
|
+
}
|
|
9294
|
+
};
|
|
9295
|
+
App = __decorate([
|
|
9296
|
+
registerUI()
|
|
9297
|
+
], App);
|
|
9298
|
+
|
|
9299
|
+
const downKeyMap = {};
|
|
9300
|
+
const Keyboard = {
|
|
9301
|
+
isHoldSpaceKey() {
|
|
9302
|
+
return Keyboard.isHold('Space');
|
|
9303
|
+
},
|
|
9304
|
+
isHold(code) {
|
|
9305
|
+
return downKeyMap[code];
|
|
9306
|
+
},
|
|
9307
|
+
setDownCode(code) {
|
|
9308
|
+
if (!downKeyMap[code])
|
|
9309
|
+
downKeyMap[code] = true;
|
|
9310
|
+
},
|
|
9311
|
+
setUpCode(code) {
|
|
9312
|
+
downKeyMap[code] = false;
|
|
9313
|
+
}
|
|
9314
|
+
};
|
|
9315
|
+
|
|
9316
|
+
const PointerButton = {
|
|
9317
|
+
LEFT: 1,
|
|
9318
|
+
RIGHT: 2,
|
|
9319
|
+
MIDDLE: 4,
|
|
9320
|
+
defaultLeft(event) { if (!event.buttons)
|
|
9321
|
+
event.buttons = 1; },
|
|
9322
|
+
left(event) { return event.buttons === 1; },
|
|
9323
|
+
right(event) { return event.buttons === 2; },
|
|
9324
|
+
middle(event) { return event.buttons === 4; }
|
|
9325
|
+
};
|
|
9326
|
+
|
|
9327
|
+
class UIEvent extends Event {
|
|
9328
|
+
get spaceKey() { return Keyboard.isHoldSpaceKey(); }
|
|
9329
|
+
get left() { return PointerButton.left(this); }
|
|
9330
|
+
get right() { return PointerButton.right(this); }
|
|
9331
|
+
get middle() { return PointerButton.middle(this); }
|
|
9332
|
+
constructor(params) {
|
|
9333
|
+
super(params.type);
|
|
9334
|
+
this.bubbles = true;
|
|
9335
|
+
Object.assign(this, params);
|
|
9336
|
+
}
|
|
9337
|
+
getBoxPoint(relative) {
|
|
9338
|
+
return (relative || this.current).getBoxPoint(this);
|
|
9339
|
+
}
|
|
9340
|
+
getInnerPoint(relative) {
|
|
9341
|
+
return (relative || this.current).getInnerPoint(this);
|
|
9342
|
+
}
|
|
9343
|
+
getLocalPoint(relative) {
|
|
9344
|
+
return (relative || this.current).getLocalPoint(this);
|
|
9345
|
+
}
|
|
9346
|
+
getPagePoint() {
|
|
9347
|
+
return this.current.getPagePoint(this);
|
|
9348
|
+
}
|
|
9349
|
+
getInner(relative) { return this.getInnerPoint(relative); }
|
|
9350
|
+
getLocal(relative) { return this.getLocalPoint(relative); }
|
|
9351
|
+
getPage() { return this.getPagePoint(); }
|
|
9352
|
+
static changeName(oldName, newName) {
|
|
9353
|
+
EventCreator.changeName(oldName, newName);
|
|
9354
|
+
}
|
|
9355
|
+
}
|
|
9356
|
+
|
|
9357
|
+
let PointerEvent$1 = class PointerEvent extends UIEvent {
|
|
9358
|
+
};
|
|
9359
|
+
PointerEvent$1.POINTER = 'pointer';
|
|
9360
|
+
PointerEvent$1.BEFORE_DOWN = 'pointer.before_down';
|
|
9361
|
+
PointerEvent$1.BEFORE_MOVE = 'pointer.before_move';
|
|
9362
|
+
PointerEvent$1.BEFORE_UP = 'pointer.before_up';
|
|
9363
|
+
PointerEvent$1.DOWN = 'pointer.down';
|
|
9364
|
+
PointerEvent$1.MOVE = 'pointer.move';
|
|
9365
|
+
PointerEvent$1.UP = 'pointer.up';
|
|
9366
|
+
PointerEvent$1.OVER = 'pointer.over';
|
|
9367
|
+
PointerEvent$1.OUT = 'pointer.out';
|
|
9368
|
+
PointerEvent$1.ENTER = 'pointer.enter';
|
|
9369
|
+
PointerEvent$1.LEAVE = 'pointer.leave';
|
|
9370
|
+
PointerEvent$1.TAP = 'tap';
|
|
9371
|
+
PointerEvent$1.DOUBLE_TAP = 'double_tap';
|
|
9372
|
+
PointerEvent$1.CLICK = 'click';
|
|
9373
|
+
PointerEvent$1.DOUBLE_CLICK = 'double_click';
|
|
9374
|
+
PointerEvent$1.LONG_PRESS = 'long_press';
|
|
9375
|
+
PointerEvent$1.LONG_TAP = 'long_tap';
|
|
9376
|
+
PointerEvent$1.MENU = 'pointer.menu';
|
|
9377
|
+
PointerEvent$1.MENU_TAP = 'pointer.menu_tap';
|
|
9378
|
+
PointerEvent$1 = __decorate([
|
|
9379
|
+
registerUIEvent()
|
|
9380
|
+
], PointerEvent$1);
|
|
9381
|
+
|
|
9382
|
+
const tempMove = {};
|
|
9383
|
+
let DragEvent$1 = class DragEvent extends PointerEvent$1 {
|
|
9384
|
+
static setList(data) {
|
|
9385
|
+
this.list = data instanceof LeafList ? data : new LeafList(data);
|
|
9386
|
+
}
|
|
9387
|
+
static setData(data) {
|
|
9388
|
+
this.data = data;
|
|
9389
|
+
}
|
|
9390
|
+
static getValidMove(leaf, start, total) {
|
|
9391
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9392
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9393
|
+
if (dragBounds)
|
|
9394
|
+
this.getMoveInDragBounds(leaf.__localBoxBounds, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9395
|
+
if (draggable === 'x')
|
|
9396
|
+
move.y = 0;
|
|
9397
|
+
if (draggable === 'y')
|
|
9398
|
+
move.x = 0;
|
|
9399
|
+
return move;
|
|
9400
|
+
}
|
|
9401
|
+
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9402
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9403
|
+
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9404
|
+
if (!change)
|
|
9405
|
+
move = Object.assign({}, move);
|
|
9406
|
+
if (BoundsHelper.includes(childBox, dragBounds)) {
|
|
9407
|
+
if (x > dragBounds.x)
|
|
9408
|
+
move.x += dragBounds.x - x;
|
|
9409
|
+
else if (right < boundsRight)
|
|
9410
|
+
move.x += boundsRight - right;
|
|
9411
|
+
if (y > dragBounds.y)
|
|
9412
|
+
move.y += dragBounds.y - y;
|
|
9413
|
+
else if (bottom < boundsBottom)
|
|
9414
|
+
move.y += boundsBottom - bottom;
|
|
9415
|
+
}
|
|
9416
|
+
else {
|
|
9417
|
+
if (x < dragBounds.x)
|
|
9418
|
+
move.x += dragBounds.x - x;
|
|
9419
|
+
else if (right > boundsRight)
|
|
9420
|
+
move.x += boundsRight - right;
|
|
9421
|
+
if (y < dragBounds.y)
|
|
9422
|
+
move.y += dragBounds.y - y;
|
|
9423
|
+
else if (bottom > boundsBottom)
|
|
9424
|
+
move.y += boundsBottom - bottom;
|
|
9425
|
+
}
|
|
9426
|
+
return move;
|
|
9427
|
+
}
|
|
9428
|
+
getPageMove(total) {
|
|
9429
|
+
this.assignMove(total);
|
|
9430
|
+
return this.current.getPagePoint(tempMove, null, true);
|
|
9431
|
+
}
|
|
9432
|
+
getInnerMove(relative, total) {
|
|
9433
|
+
if (!relative)
|
|
9434
|
+
relative = this.current;
|
|
9435
|
+
this.assignMove(total);
|
|
9436
|
+
return relative.getInnerPoint(tempMove, null, true);
|
|
9437
|
+
}
|
|
9438
|
+
getLocalMove(relative, total) {
|
|
9439
|
+
if (!relative)
|
|
9440
|
+
relative = this.current;
|
|
9441
|
+
this.assignMove(total);
|
|
9442
|
+
return relative.getLocalPoint(tempMove, null, true);
|
|
9443
|
+
}
|
|
9444
|
+
getPageTotal() {
|
|
9445
|
+
return this.getPageMove(true);
|
|
9446
|
+
}
|
|
9447
|
+
getInnerTotal(relative) {
|
|
9448
|
+
return this.getInnerMove(relative, true);
|
|
9449
|
+
}
|
|
9450
|
+
getLocalTotal(relative) {
|
|
9451
|
+
return this.getLocalMove(relative, true);
|
|
9452
|
+
}
|
|
9453
|
+
getPageBounds() {
|
|
9454
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9455
|
+
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9456
|
+
BoundsHelper.unsign(bounds);
|
|
9457
|
+
return bounds;
|
|
9458
|
+
}
|
|
9459
|
+
assignMove(total) {
|
|
9460
|
+
tempMove.x = total ? this.totalX : this.moveX;
|
|
9461
|
+
tempMove.y = total ? this.totalY : this.moveY;
|
|
9462
|
+
}
|
|
9463
|
+
};
|
|
9464
|
+
DragEvent$1.BEFORE_DRAG = 'drag.before_drag';
|
|
9465
|
+
DragEvent$1.START = 'drag.start';
|
|
9466
|
+
DragEvent$1.DRAG = 'drag';
|
|
9467
|
+
DragEvent$1.END = 'drag.end';
|
|
9468
|
+
DragEvent$1.OVER = 'drag.over';
|
|
9469
|
+
DragEvent$1.OUT = 'drag.out';
|
|
9470
|
+
DragEvent$1.ENTER = 'drag.enter';
|
|
9471
|
+
DragEvent$1.LEAVE = 'drag.leave';
|
|
9472
|
+
DragEvent$1 = __decorate([
|
|
9473
|
+
registerUIEvent()
|
|
9474
|
+
], DragEvent$1);
|
|
9475
|
+
|
|
9476
|
+
let DropEvent = class DropEvent extends PointerEvent$1 {
|
|
9477
|
+
static setList(data) {
|
|
9478
|
+
DragEvent$1.setList(data);
|
|
9479
|
+
}
|
|
9480
|
+
static setData(data) {
|
|
9481
|
+
DragEvent$1.setData(data);
|
|
9482
|
+
}
|
|
9483
|
+
};
|
|
9484
|
+
DropEvent.DROP = 'drop';
|
|
9485
|
+
DropEvent = __decorate([
|
|
9486
|
+
registerUIEvent()
|
|
9487
|
+
], DropEvent);
|
|
9488
|
+
|
|
9489
|
+
let MoveEvent = class MoveEvent extends DragEvent$1 {
|
|
9490
|
+
};
|
|
9491
|
+
MoveEvent.BEFORE_MOVE = 'move.before_move';
|
|
9492
|
+
MoveEvent.START = 'move.start';
|
|
9493
|
+
MoveEvent.MOVE = 'move';
|
|
9494
|
+
MoveEvent.END = 'move.end';
|
|
9495
|
+
MoveEvent = __decorate([
|
|
9496
|
+
registerUIEvent()
|
|
9497
|
+
], MoveEvent);
|
|
9498
|
+
|
|
9499
|
+
let RotateEvent = class RotateEvent extends PointerEvent$1 {
|
|
9500
|
+
};
|
|
9501
|
+
RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
|
|
9502
|
+
RotateEvent.START = 'rotate.start';
|
|
9503
|
+
RotateEvent.ROTATE = 'rotate';
|
|
9504
|
+
RotateEvent.END = 'rotate.end';
|
|
9505
|
+
RotateEvent = __decorate([
|
|
9506
|
+
registerUIEvent()
|
|
9507
|
+
], RotateEvent);
|
|
9508
|
+
|
|
9509
|
+
let SwipeEvent = class SwipeEvent extends DragEvent$1 {
|
|
9510
|
+
};
|
|
9511
|
+
SwipeEvent.SWIPE = 'swipe';
|
|
9512
|
+
SwipeEvent.LEFT = 'swipe.left';
|
|
9513
|
+
SwipeEvent.RIGHT = 'swipe.right';
|
|
9514
|
+
SwipeEvent.UP = 'swipe.up';
|
|
9515
|
+
SwipeEvent.DOWN = 'swipe.down';
|
|
9516
|
+
SwipeEvent = __decorate([
|
|
9517
|
+
registerUIEvent()
|
|
9518
|
+
], SwipeEvent);
|
|
9519
|
+
|
|
9520
|
+
let ZoomEvent = class ZoomEvent extends PointerEvent$1 {
|
|
9521
|
+
};
|
|
9522
|
+
ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
|
|
9523
|
+
ZoomEvent.START = 'zoom.start';
|
|
9524
|
+
ZoomEvent.ZOOM = 'zoom';
|
|
9525
|
+
ZoomEvent.END = 'zoom.end';
|
|
9526
|
+
ZoomEvent = __decorate([
|
|
9527
|
+
registerUIEvent()
|
|
9528
|
+
], ZoomEvent);
|
|
9529
|
+
|
|
9530
|
+
let KeyEvent = class KeyEvent extends UIEvent {
|
|
9531
|
+
};
|
|
9532
|
+
KeyEvent.DOWN = 'key.down';
|
|
9533
|
+
KeyEvent.HOLD = 'key.hold';
|
|
9534
|
+
KeyEvent.UP = 'key.up';
|
|
9535
|
+
KeyEvent = __decorate([
|
|
9536
|
+
registerUIEvent()
|
|
9537
|
+
], KeyEvent);
|
|
9538
|
+
|
|
9539
|
+
new LeafList();
|
|
9540
|
+
|
|
9541
|
+
Debug.get('emit');
|
|
9542
|
+
|
|
9543
|
+
const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
|
|
9544
|
+
const inner = {};
|
|
9545
|
+
const leaf = exports.Leaf.prototype;
|
|
9546
|
+
leaf.__hitWorld = function (point) {
|
|
9547
|
+
const data = this.__;
|
|
9548
|
+
if (!data.hitSelf)
|
|
9549
|
+
return false;
|
|
9550
|
+
const world = this.__world, layout = this.__layout;
|
|
9551
|
+
const isSmall = world.width < 10 && world.height < 10;
|
|
9552
|
+
if (data.hitRadius) {
|
|
9553
|
+
copy$2(inner, point), point = inner;
|
|
9554
|
+
setRadius(point, data.hitRadius);
|
|
9555
|
+
}
|
|
9556
|
+
toInnerRadiusPointOf(point, world, inner);
|
|
9557
|
+
if (data.hitBox || isSmall) {
|
|
9558
|
+
if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
|
|
9559
|
+
return true;
|
|
9560
|
+
if (isSmall)
|
|
9561
|
+
return false;
|
|
9562
|
+
}
|
|
9563
|
+
if (layout.hitCanvasChanged || !this.__hitCanvas) {
|
|
9564
|
+
this.__updateHitCanvas();
|
|
9565
|
+
if (!layout.boundsChanged)
|
|
9566
|
+
layout.hitCanvasChanged = false;
|
|
9567
|
+
}
|
|
9568
|
+
return this.__hit(inner);
|
|
9569
|
+
};
|
|
9570
|
+
leaf.__hitFill = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, this.__.windingRule); };
|
|
9571
|
+
leaf.__hitStroke = function (inner, strokeWidth) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth); };
|
|
9572
|
+
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); };
|
|
9573
|
+
leaf.__drawHitPath = function (canvas) { if (canvas)
|
|
9574
|
+
this.__drawRenderPath(canvas); };
|
|
9575
|
+
|
|
9576
|
+
const matrix = new Matrix();
|
|
9577
|
+
const ui$1 = exports.UI.prototype;
|
|
9578
|
+
ui$1.__updateHitCanvas = function () {
|
|
9579
|
+
if (this.__box)
|
|
9580
|
+
this.__box.__updateHitCanvas();
|
|
9581
|
+
const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
|
|
9582
|
+
const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
9583
|
+
const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
|
|
9584
|
+
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
9585
|
+
if (!this.__hitCanvas)
|
|
9586
|
+
this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
|
|
9587
|
+
const h = this.__hitCanvas;
|
|
9588
|
+
if (isHitPixel) {
|
|
9589
|
+
const { renderBounds } = this.__layout;
|
|
9590
|
+
const size = Platform.image.hitCanvasSize;
|
|
9591
|
+
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
|
|
9592
|
+
const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
|
|
9593
|
+
h.resize({ width, height, pixelRatio: 1 });
|
|
9594
|
+
h.clear();
|
|
9595
|
+
ImageManager.patternLocked = true;
|
|
9596
|
+
this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y) }, !isHitPixelFill, !isHitPixelStroke);
|
|
9597
|
+
ImageManager.patternLocked = false;
|
|
9598
|
+
h.resetTransform();
|
|
9599
|
+
data.__isHitPixel = true;
|
|
9600
|
+
}
|
|
9601
|
+
else {
|
|
9602
|
+
data.__isHitPixel && (data.__isHitPixel = false);
|
|
9603
|
+
}
|
|
9604
|
+
this.__drawHitPath(h);
|
|
9605
|
+
h.setStrokeOptions(data);
|
|
9606
|
+
};
|
|
9607
|
+
ui$1.__hit = function (inner) {
|
|
9608
|
+
if (this.__box && this.__box.__hit(inner))
|
|
9609
|
+
return true;
|
|
9610
|
+
const data = this.__;
|
|
9611
|
+
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
9612
|
+
return true;
|
|
9613
|
+
const { hitFill } = data;
|
|
9614
|
+
const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
|
|
9615
|
+
if (needHitFillPath && this.__hitFill(inner))
|
|
9616
|
+
return true;
|
|
9617
|
+
const { hitStroke, __strokeWidth } = data;
|
|
9618
|
+
const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
|
|
9619
|
+
if (!needHitFillPath && !needHitStrokePath)
|
|
9620
|
+
return false;
|
|
9621
|
+
const radiusWidth = inner.radiusX * 2;
|
|
9622
|
+
let hitWidth = radiusWidth;
|
|
9623
|
+
if (needHitStrokePath) {
|
|
9624
|
+
switch (data.strokeAlign) {
|
|
9625
|
+
case 'inside':
|
|
9626
|
+
hitWidth += __strokeWidth * 2;
|
|
9627
|
+
if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
|
|
9628
|
+
return true;
|
|
9629
|
+
hitWidth = radiusWidth;
|
|
9630
|
+
break;
|
|
9631
|
+
case 'center':
|
|
9632
|
+
hitWidth += __strokeWidth;
|
|
9633
|
+
break;
|
|
9634
|
+
case 'outside':
|
|
9635
|
+
hitWidth += __strokeWidth * 2;
|
|
9636
|
+
if (!needHitFillPath) {
|
|
9637
|
+
if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
|
|
9638
|
+
return true;
|
|
9639
|
+
hitWidth = radiusWidth;
|
|
9640
|
+
}
|
|
9641
|
+
break;
|
|
9642
|
+
}
|
|
9643
|
+
}
|
|
9644
|
+
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
9645
|
+
};
|
|
9646
|
+
|
|
9647
|
+
const ui = exports.UI.prototype, rect = exports.Rect.prototype, box$1 = exports.Box.prototype;
|
|
9648
|
+
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
9649
|
+
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
9650
|
+
ui.__updateHitCanvas.call(this);
|
|
9651
|
+
else if (this.__hitCanvas)
|
|
9652
|
+
this.__hitCanvas = null;
|
|
9653
|
+
};
|
|
9654
|
+
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
9655
|
+
return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
9656
|
+
};
|
|
9657
|
+
|
|
9658
|
+
exports.Text.prototype.__drawHitPath = function (canvas) {
|
|
9659
|
+
const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
|
|
9660
|
+
canvas.beginPath();
|
|
9661
|
+
if (__letterSpacing < 0)
|
|
9662
|
+
this.__drawPathByBox(canvas);
|
|
9663
|
+
else
|
|
9664
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
9665
|
+
};
|
|
9666
|
+
|
|
9667
|
+
function getSelector(ui) {
|
|
9668
|
+
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
9669
|
+
}
|
|
9670
|
+
exports.Group.prototype.pick = function (hitPoint, options) {
|
|
9671
|
+
options || (options = emptyData);
|
|
9672
|
+
this.updateLayout();
|
|
9673
|
+
return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
9674
|
+
};
|
|
9675
|
+
|
|
9676
|
+
const canvas = LeaferCanvasBase.prototype;
|
|
9677
|
+
canvas.hitFill = function (point, fillRule) {
|
|
9678
|
+
return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
|
|
9679
|
+
};
|
|
9680
|
+
canvas.hitStroke = function (point, strokeWidth) {
|
|
9681
|
+
this.strokeWidth = strokeWidth;
|
|
9682
|
+
return this.context.isPointInStroke(point.x, point.y);
|
|
9683
|
+
};
|
|
9684
|
+
canvas.hitPixel = function (radiusPoint, offset, scale = 1) {
|
|
9685
|
+
let { x, y, radiusX, radiusY } = radiusPoint;
|
|
9686
|
+
if (offset)
|
|
9687
|
+
x -= offset.x, y -= offset.y;
|
|
9688
|
+
tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
|
|
9689
|
+
const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
|
|
9690
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
9691
|
+
if (data[i + 3] > 0)
|
|
9692
|
+
return true;
|
|
9693
|
+
}
|
|
9694
|
+
return data[3] > 0;
|
|
9695
|
+
};
|
|
9696
|
+
|
|
9046
9697
|
function strokeText(stroke, ui, canvas) {
|
|
9047
|
-
|
|
9048
|
-
const isStrokes = typeof stroke !== 'string';
|
|
9049
|
-
switch (strokeAlign) {
|
|
9698
|
+
switch (ui.__.strokeAlign) {
|
|
9050
9699
|
case 'center':
|
|
9051
|
-
|
|
9052
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
9700
|
+
drawCenter$1(stroke, 1, ui, canvas);
|
|
9053
9701
|
break;
|
|
9054
9702
|
case 'inside':
|
|
9055
|
-
|
|
9703
|
+
drawAlign(stroke, 'inside', ui, canvas);
|
|
9056
9704
|
break;
|
|
9057
9705
|
case 'outside':
|
|
9058
|
-
|
|
9706
|
+
ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
|
|
9059
9707
|
break;
|
|
9060
9708
|
}
|
|
9061
9709
|
}
|
|
9062
|
-
function
|
|
9063
|
-
const
|
|
9710
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
9711
|
+
const data = ui.__;
|
|
9712
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
|
|
9713
|
+
data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
9714
|
+
}
|
|
9715
|
+
function drawAlign(stroke, align, ui, canvas) {
|
|
9064
9716
|
const out = canvas.getSameCanvas(true, true);
|
|
9065
|
-
out.
|
|
9066
|
-
|
|
9067
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
|
|
9717
|
+
out.font = ui.__.__font;
|
|
9718
|
+
drawCenter$1(stroke, 2, ui, out);
|
|
9068
9719
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
9069
9720
|
fillText(ui, out);
|
|
9070
9721
|
out.blendMode = 'normal';
|
|
9071
|
-
if (ui.__worldFlipped)
|
|
9722
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
9072
9723
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9073
9724
|
else
|
|
9074
9725
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
@@ -9110,90 +9761,60 @@ var LeaferUI = (function (exports) {
|
|
|
9110
9761
|
}
|
|
9111
9762
|
|
|
9112
9763
|
function stroke(stroke, ui, canvas) {
|
|
9113
|
-
const
|
|
9114
|
-
|
|
9115
|
-
if (!__strokeWidth)
|
|
9764
|
+
const data = ui.__;
|
|
9765
|
+
if (!data.__strokeWidth)
|
|
9116
9766
|
return;
|
|
9117
|
-
if (__font) {
|
|
9767
|
+
if (data.__font) {
|
|
9118
9768
|
strokeText(stroke, ui, canvas);
|
|
9119
9769
|
}
|
|
9120
9770
|
else {
|
|
9121
|
-
switch (strokeAlign) {
|
|
9771
|
+
switch (data.strokeAlign) {
|
|
9122
9772
|
case 'center':
|
|
9123
|
-
|
|
9124
|
-
canvas.stroke();
|
|
9125
|
-
if (options.__useArrow)
|
|
9126
|
-
strokeArrow(ui, canvas);
|
|
9773
|
+
drawCenter(stroke, 1, ui, canvas);
|
|
9127
9774
|
break;
|
|
9128
9775
|
case 'inside':
|
|
9129
|
-
canvas
|
|
9130
|
-
canvas.setStroke(stroke, __strokeWidth * 2, options);
|
|
9131
|
-
options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
|
|
9132
|
-
canvas.stroke();
|
|
9133
|
-
canvas.restore();
|
|
9776
|
+
drawInside(stroke, ui, canvas);
|
|
9134
9777
|
break;
|
|
9135
9778
|
case 'outside':
|
|
9136
|
-
|
|
9137
|
-
out.setStroke(stroke, __strokeWidth * 2, options);
|
|
9138
|
-
ui.__drawRenderPath(out);
|
|
9139
|
-
out.stroke();
|
|
9140
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
9141
|
-
out.clearWorld(ui.__layout.renderBounds);
|
|
9142
|
-
if (ui.__worldFlipped)
|
|
9143
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9144
|
-
else
|
|
9145
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
9146
|
-
out.recycle(ui.__nowWorld);
|
|
9779
|
+
drawOutside(stroke, ui, canvas);
|
|
9147
9780
|
break;
|
|
9148
9781
|
}
|
|
9149
9782
|
}
|
|
9150
9783
|
}
|
|
9151
9784
|
function strokes(strokes, ui, canvas) {
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9785
|
+
stroke(strokes, ui, canvas);
|
|
9786
|
+
}
|
|
9787
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
9788
|
+
const data = ui.__;
|
|
9789
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
9790
|
+
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
9791
|
+
if (data.__useArrow)
|
|
9792
|
+
Paint.strokeArrow(stroke, ui, canvas);
|
|
9793
|
+
}
|
|
9794
|
+
function drawInside(stroke, ui, canvas) {
|
|
9795
|
+
const data = ui.__;
|
|
9796
|
+
canvas.save();
|
|
9797
|
+
data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
|
|
9798
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
9799
|
+
canvas.restore();
|
|
9800
|
+
}
|
|
9801
|
+
function drawOutside(stroke, ui, canvas) {
|
|
9802
|
+
const data = ui.__;
|
|
9803
|
+
if (data.__fillAfterStroke) {
|
|
9804
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
9158
9805
|
}
|
|
9159
9806
|
else {
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
drawStrokesStyle(strokes, false, ui, canvas);
|
|
9172
|
-
canvas.restore();
|
|
9173
|
-
break;
|
|
9174
|
-
case 'outside':
|
|
9175
|
-
const { renderBounds } = ui.__layout;
|
|
9176
|
-
const out = canvas.getSameCanvas(true, true);
|
|
9177
|
-
ui.__drawRenderPath(out);
|
|
9178
|
-
out.setStroke(undefined, __strokeWidth * 2, options);
|
|
9179
|
-
drawStrokesStyle(strokes, false, ui, out);
|
|
9180
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
9181
|
-
out.clearWorld(renderBounds);
|
|
9182
|
-
if (ui.__worldFlipped)
|
|
9183
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9184
|
-
else
|
|
9185
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
9186
|
-
out.recycle(ui.__nowWorld);
|
|
9187
|
-
break;
|
|
9188
|
-
}
|
|
9189
|
-
}
|
|
9190
|
-
}
|
|
9191
|
-
function strokeArrow(ui, canvas) {
|
|
9192
|
-
if (ui.__.dashPattern) {
|
|
9193
|
-
canvas.beginPath();
|
|
9194
|
-
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
9195
|
-
canvas.dashPattern = null;
|
|
9196
|
-
canvas.stroke();
|
|
9807
|
+
const { renderBounds } = ui.__layout;
|
|
9808
|
+
const out = canvas.getSameCanvas(true, true);
|
|
9809
|
+
ui.__drawRenderPath(out);
|
|
9810
|
+
drawCenter(stroke, 2, ui, out);
|
|
9811
|
+
data.windingRule ? out.clip(data.windingRule) : out.clip();
|
|
9812
|
+
out.clearWorld(renderBounds);
|
|
9813
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
9814
|
+
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
9815
|
+
else
|
|
9816
|
+
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
9817
|
+
out.recycle(ui.__nowWorld);
|
|
9197
9818
|
}
|
|
9198
9819
|
}
|
|
9199
9820
|
|
|
@@ -9240,9 +9861,10 @@ var LeaferUI = (function (exports) {
|
|
|
9240
9861
|
}
|
|
9241
9862
|
|
|
9242
9863
|
let recycleMap;
|
|
9864
|
+
const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
|
|
9243
9865
|
function compute(attrName, ui) {
|
|
9244
9866
|
const data = ui.__, leafPaints = [];
|
|
9245
|
-
let paints = data.__input[attrName],
|
|
9867
|
+
let paints = data.__input[attrName], isAlphaPixel, isTransparent;
|
|
9246
9868
|
if (!(paints instanceof Array))
|
|
9247
9869
|
paints = [paints];
|
|
9248
9870
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
@@ -9252,29 +9874,55 @@ var LeaferUI = (function (exports) {
|
|
|
9252
9874
|
leafPaints.push(item);
|
|
9253
9875
|
}
|
|
9254
9876
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
9255
|
-
if (leafPaints.length
|
|
9256
|
-
|
|
9257
|
-
|
|
9877
|
+
if (leafPaints.length) {
|
|
9878
|
+
if (leafPaints.every(item => item.isTransparent)) {
|
|
9879
|
+
if (leafPaints.some(item => item.image))
|
|
9880
|
+
isAlphaPixel = true;
|
|
9881
|
+
isTransparent = true;
|
|
9882
|
+
}
|
|
9883
|
+
}
|
|
9884
|
+
if (attrName === 'fill') {
|
|
9885
|
+
stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
|
|
9886
|
+
stintSet(data, '__isTransparentFill', isTransparent);
|
|
9887
|
+
}
|
|
9888
|
+
else {
|
|
9889
|
+
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
9890
|
+
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
9891
|
+
}
|
|
9258
9892
|
}
|
|
9259
9893
|
function getLeafPaint(attrName, paint, ui) {
|
|
9260
9894
|
if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
|
|
9261
9895
|
return undefined;
|
|
9896
|
+
let data;
|
|
9262
9897
|
const { boxBounds } = ui.__layout;
|
|
9263
9898
|
switch (paint.type) {
|
|
9264
|
-
case 'solid':
|
|
9265
|
-
let { type, blendMode, color, opacity } = paint;
|
|
9266
|
-
return { type, blendMode, style: ColorConvert.string(color, opacity) };
|
|
9267
9899
|
case 'image':
|
|
9268
|
-
|
|
9900
|
+
data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
9901
|
+
break;
|
|
9269
9902
|
case 'linear':
|
|
9270
|
-
|
|
9903
|
+
data = PaintGradient.linearGradient(paint, boxBounds);
|
|
9904
|
+
break;
|
|
9271
9905
|
case 'radial':
|
|
9272
|
-
|
|
9906
|
+
data = PaintGradient.radialGradient(paint, boxBounds);
|
|
9907
|
+
break;
|
|
9273
9908
|
case 'angular':
|
|
9274
|
-
|
|
9909
|
+
data = PaintGradient.conicGradient(paint, boxBounds);
|
|
9910
|
+
break;
|
|
9911
|
+
case 'solid':
|
|
9912
|
+
const { type, blendMode, color, opacity } = paint;
|
|
9913
|
+
data = { type, blendMode, style: ColorConvert.string(color, opacity) };
|
|
9914
|
+
break;
|
|
9275
9915
|
default:
|
|
9276
|
-
|
|
9916
|
+
if (paint.r !== undefined)
|
|
9917
|
+
data = { type: 'solid', style: ColorConvert.string(paint) };
|
|
9918
|
+
}
|
|
9919
|
+
if (data) {
|
|
9920
|
+
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
9921
|
+
data.isTransparent = true;
|
|
9922
|
+
if (paint.blendMode)
|
|
9923
|
+
data.blendMode = paint.blendMode;
|
|
9277
9924
|
}
|
|
9925
|
+
return data;
|
|
9278
9926
|
}
|
|
9279
9927
|
|
|
9280
9928
|
const PaintModule = {
|
|
@@ -9340,12 +9988,10 @@ var LeaferUI = (function (exports) {
|
|
|
9340
9988
|
|
|
9341
9989
|
const { get: get$2, translate } = MatrixHelper;
|
|
9342
9990
|
const tempBox = new Bounds();
|
|
9343
|
-
const tempPoint = {};
|
|
9344
9991
|
const tempScaleData = {};
|
|
9992
|
+
const tempImage = {};
|
|
9345
9993
|
function createData(leafPaint, image, paint, box) {
|
|
9346
|
-
const {
|
|
9347
|
-
if (blendMode)
|
|
9348
|
-
leafPaint.blendMode = blendMode;
|
|
9994
|
+
const { changeful, sync } = paint;
|
|
9349
9995
|
if (changeful)
|
|
9350
9996
|
leafPaint.changeful = changeful;
|
|
9351
9997
|
if (sync)
|
|
@@ -9353,38 +9999,38 @@ var LeaferUI = (function (exports) {
|
|
|
9353
9999
|
leafPaint.data = getPatternData(paint, box, image);
|
|
9354
10000
|
}
|
|
9355
10001
|
function getPatternData(paint, box, image) {
|
|
9356
|
-
let { width, height } = image;
|
|
9357
10002
|
if (paint.padding)
|
|
9358
10003
|
box = tempBox.set(box).shrink(paint.padding);
|
|
9359
10004
|
if (paint.mode === 'strench')
|
|
9360
10005
|
paint.mode = 'stretch';
|
|
10006
|
+
let { width, height } = image;
|
|
9361
10007
|
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
9362
10008
|
const sameBox = box.width === width && box.height === height;
|
|
9363
10009
|
const data = { mode };
|
|
9364
10010
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
9365
|
-
|
|
9366
|
-
let
|
|
10011
|
+
BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
|
|
10012
|
+
let scaleX, scaleY;
|
|
9367
10013
|
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
9368
10014
|
if (!sameBox || rotation) {
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
10015
|
+
scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
|
|
10016
|
+
BoundsHelper.put(box, image, align, scaleX, false, tempImage);
|
|
10017
|
+
BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
9372
10018
|
}
|
|
9373
10019
|
}
|
|
9374
|
-
else
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
10020
|
+
else {
|
|
10021
|
+
if (scale || size) {
|
|
10022
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
10023
|
+
scaleX = tempScaleData.scaleX;
|
|
10024
|
+
scaleY = tempScaleData.scaleY;
|
|
10025
|
+
}
|
|
10026
|
+
if (align) {
|
|
10027
|
+
if (scaleX)
|
|
10028
|
+
BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
10029
|
+
AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
|
|
10030
|
+
}
|
|
9385
10031
|
}
|
|
9386
10032
|
if (offset)
|
|
9387
|
-
|
|
10033
|
+
PointHelper.move(tempImage, offset);
|
|
9388
10034
|
switch (mode) {
|
|
9389
10035
|
case 'stretch':
|
|
9390
10036
|
if (!sameBox)
|
|
@@ -9392,12 +10038,12 @@ var LeaferUI = (function (exports) {
|
|
|
9392
10038
|
break;
|
|
9393
10039
|
case 'normal':
|
|
9394
10040
|
case 'clip':
|
|
9395
|
-
if (x || y || scaleX || rotation)
|
|
9396
|
-
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
10041
|
+
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
10042
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9397
10043
|
break;
|
|
9398
10044
|
case 'repeat':
|
|
9399
10045
|
if (!sameBox || scaleX || rotation)
|
|
9400
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
|
|
10046
|
+
repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
|
|
9401
10047
|
if (!repeat)
|
|
9402
10048
|
data.repeat = 'repeat';
|
|
9403
10049
|
break;
|
|
@@ -9405,7 +10051,7 @@ var LeaferUI = (function (exports) {
|
|
|
9405
10051
|
case 'cover':
|
|
9406
10052
|
default:
|
|
9407
10053
|
if (scaleX)
|
|
9408
|
-
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
10054
|
+
fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9409
10055
|
}
|
|
9410
10056
|
if (!data.transform) {
|
|
9411
10057
|
if (box.x || box.y) {
|
|
@@ -9438,6 +10084,8 @@ var LeaferUI = (function (exports) {
|
|
|
9438
10084
|
}
|
|
9439
10085
|
else {
|
|
9440
10086
|
leafPaint = { type: paint.type, image };
|
|
10087
|
+
if (image.hasAlphaPixel)
|
|
10088
|
+
leafPaint.isTransparent = true;
|
|
9441
10089
|
cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
|
|
9442
10090
|
}
|
|
9443
10091
|
if (firstUse || image.loading)
|
|
@@ -9462,7 +10110,7 @@ var LeaferUI = (function (exports) {
|
|
|
9462
10110
|
ignoreRender(ui, false);
|
|
9463
10111
|
if (!ui.destroyed) {
|
|
9464
10112
|
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
9465
|
-
if (image.
|
|
10113
|
+
if (image.hasAlphaPixel)
|
|
9466
10114
|
ui.__layout.hitCanvasChanged = true;
|
|
9467
10115
|
ui.forceUpdate('surface');
|
|
9468
10116
|
}
|
|
@@ -9474,13 +10122,17 @@ var LeaferUI = (function (exports) {
|
|
|
9474
10122
|
onLoadError(ui, event, error);
|
|
9475
10123
|
leafPaint.loadId = null;
|
|
9476
10124
|
});
|
|
9477
|
-
if (ui.placeholderColor)
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
10125
|
+
if (ui.placeholderColor) {
|
|
10126
|
+
if (!ui.placeholderDelay)
|
|
10127
|
+
image.isPlacehold = true;
|
|
10128
|
+
else
|
|
10129
|
+
setTimeout(() => {
|
|
10130
|
+
if (!image.ready) {
|
|
10131
|
+
image.isPlacehold = true;
|
|
10132
|
+
ui.forceUpdate('surface');
|
|
10133
|
+
}
|
|
10134
|
+
}, ui.placeholderDelay);
|
|
10135
|
+
}
|
|
9484
10136
|
}
|
|
9485
10137
|
return leafPaint;
|
|
9486
10138
|
}
|
|
@@ -9686,32 +10338,33 @@ var LeaferUI = (function (exports) {
|
|
|
9686
10338
|
repeatMode
|
|
9687
10339
|
};
|
|
9688
10340
|
|
|
9689
|
-
const { toPoint: toPoint$2 } = AroundHelper;
|
|
10341
|
+
const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
|
|
9690
10342
|
const realFrom$2 = {};
|
|
9691
10343
|
const realTo$2 = {};
|
|
9692
10344
|
function linearGradient(paint, box) {
|
|
9693
|
-
let { from, to, type,
|
|
10345
|
+
let { from, to, type, opacity } = paint;
|
|
9694
10346
|
toPoint$2(from || 'top', box, realFrom$2);
|
|
9695
10347
|
toPoint$2(to || 'bottom', box, realTo$2);
|
|
9696
10348
|
const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
|
|
9697
|
-
applyStops(style, paint.stops, opacity);
|
|
9698
10349
|
const data = { type, style };
|
|
9699
|
-
|
|
9700
|
-
data.blendMode = blendMode;
|
|
10350
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9701
10351
|
return data;
|
|
9702
10352
|
}
|
|
9703
|
-
function applyStops(gradient, stops, opacity) {
|
|
10353
|
+
function applyStops(data, gradient, stops, opacity) {
|
|
9704
10354
|
if (stops) {
|
|
9705
|
-
let stop;
|
|
10355
|
+
let stop, color, offset, isTransparent;
|
|
9706
10356
|
for (let i = 0, len = stops.length; i < len; i++) {
|
|
9707
10357
|
stop = stops[i];
|
|
9708
|
-
if (typeof stop === 'string')
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
10358
|
+
if (typeof stop === 'string')
|
|
10359
|
+
offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
|
|
10360
|
+
else
|
|
10361
|
+
offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
|
|
10362
|
+
gradient.addColorStop(offset, color);
|
|
10363
|
+
if (!isTransparent && hasTransparent(color))
|
|
10364
|
+
isTransparent = true;
|
|
9714
10365
|
}
|
|
10366
|
+
if (isTransparent)
|
|
10367
|
+
data.isTransparent = true;
|
|
9715
10368
|
}
|
|
9716
10369
|
}
|
|
9717
10370
|
|
|
@@ -9721,17 +10374,15 @@ var LeaferUI = (function (exports) {
|
|
|
9721
10374
|
const realFrom$1 = {};
|
|
9722
10375
|
const realTo$1 = {};
|
|
9723
10376
|
function radialGradient(paint, box) {
|
|
9724
|
-
let { from, to, type, opacity,
|
|
10377
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
9725
10378
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
9726
10379
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
9727
10380
|
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
9728
|
-
applyStops(style, paint.stops, opacity);
|
|
9729
10381
|
const data = { type, style };
|
|
10382
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9730
10383
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
9731
10384
|
if (transform)
|
|
9732
10385
|
data.transform = transform;
|
|
9733
|
-
if (blendMode)
|
|
9734
|
-
data.blendMode = blendMode;
|
|
9735
10386
|
return data;
|
|
9736
10387
|
}
|
|
9737
10388
|
function getTransform(box, from, to, stretch, rotate90) {
|
|
@@ -9757,17 +10408,15 @@ var LeaferUI = (function (exports) {
|
|
|
9757
10408
|
const realFrom = {};
|
|
9758
10409
|
const realTo = {};
|
|
9759
10410
|
function conicGradient(paint, box) {
|
|
9760
|
-
let { from, to, type, opacity,
|
|
10411
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
9761
10412
|
toPoint(from || 'center', box, realFrom);
|
|
9762
10413
|
toPoint(to || 'bottom', box, realTo);
|
|
9763
10414
|
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));
|
|
9764
|
-
applyStops(style, paint.stops, opacity);
|
|
9765
10415
|
const data = { type, style };
|
|
10416
|
+
applyStops(data, style, paint.stops, opacity);
|
|
9766
10417
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
9767
10418
|
if (transform)
|
|
9768
10419
|
data.transform = transform;
|
|
9769
|
-
if (blendMode)
|
|
9770
|
-
data.blendMode = blendMode;
|
|
9771
10420
|
return data;
|
|
9772
10421
|
}
|
|
9773
10422
|
|
|
@@ -10100,6 +10749,8 @@ var LeaferUI = (function (exports) {
|
|
|
10100
10749
|
lastCharType = null;
|
|
10101
10750
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
10102
10751
|
word = { data: [] }, row = { words: [] };
|
|
10752
|
+
if (__letterSpacing)
|
|
10753
|
+
content = [...content];
|
|
10103
10754
|
for (let i = 0, len = content.length; i < len; i++) {
|
|
10104
10755
|
char = content[i];
|
|
10105
10756
|
if (char === '\n') {
|
|
@@ -10518,6 +11169,7 @@ var LeaferUI = (function (exports) {
|
|
|
10518
11169
|
exports.AutoBounds = AutoBounds;
|
|
10519
11170
|
exports.BezierHelper = BezierHelper;
|
|
10520
11171
|
exports.Bounds = Bounds;
|
|
11172
|
+
exports.BoundsEvent = BoundsEvent;
|
|
10521
11173
|
exports.BoundsHelper = BoundsHelper;
|
|
10522
11174
|
exports.BoxData = BoxData;
|
|
10523
11175
|
exports.BranchHelper = BranchHelper;
|
|
@@ -10664,7 +11316,7 @@ var LeaferUI = (function (exports) {
|
|
|
10664
11316
|
exports.surfaceType = surfaceType;
|
|
10665
11317
|
exports.tempBounds = tempBounds$1;
|
|
10666
11318
|
exports.tempMatrix = tempMatrix;
|
|
10667
|
-
exports.tempPoint = tempPoint$
|
|
11319
|
+
exports.tempPoint = tempPoint$2;
|
|
10668
11320
|
exports.useCanvas = useCanvas;
|
|
10669
11321
|
exports.useModule = useModule;
|
|
10670
11322
|
exports.version = version;
|