@leafer-draw/worker 1.0.0-rc.19 → 1.0.0-rc.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.esm.js +65 -20
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +472 -433
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +466 -434
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.module.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const Platform = {
|
|
2
2
|
image: {
|
|
3
|
+
hitCanvasSize: 100,
|
|
3
4
|
maxCacheSize: 2560 * 1600,
|
|
4
5
|
maxPatternSize: 4096 * 2160,
|
|
5
6
|
suffix: 'leaf',
|
|
@@ -41,7 +42,7 @@ const MathHelper = {
|
|
|
41
42
|
minus(value, isFourNumber) {
|
|
42
43
|
if (value instanceof Array) {
|
|
43
44
|
if (isFourNumber)
|
|
44
|
-
value = MathHelper.fourNumber(value);
|
|
45
|
+
value = MathHelper.fourNumber(value, 0);
|
|
45
46
|
for (let i = 0; i < value.length; i++)
|
|
46
47
|
value[i] = -value[i];
|
|
47
48
|
}
|
|
@@ -55,7 +56,7 @@ const MathHelper = {
|
|
|
55
56
|
if (num instanceof Array) {
|
|
56
57
|
switch (num.length) {
|
|
57
58
|
case 4:
|
|
58
|
-
data = num;
|
|
59
|
+
data = maxValue === undefined ? num : [...num];
|
|
59
60
|
break;
|
|
60
61
|
case 2:
|
|
61
62
|
data = [num[0], num[1], num[0], num[1]];
|
|
@@ -116,7 +117,7 @@ function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
|
|
|
116
117
|
|
|
117
118
|
const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
|
|
118
119
|
const { float: float$1 } = MathHelper;
|
|
119
|
-
const tempPoint$
|
|
120
|
+
const tempPoint$3 = {};
|
|
120
121
|
function getWorld() {
|
|
121
122
|
return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
|
|
122
123
|
}
|
|
@@ -157,8 +158,8 @@ const MatrixHelper = {
|
|
|
157
158
|
t.d *= scaleY;
|
|
158
159
|
},
|
|
159
160
|
scaleOfOuter(t, origin, scaleX, scaleY) {
|
|
160
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
161
|
-
M$6.scaleOfInner(t, tempPoint$
|
|
161
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
162
|
+
M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
|
|
162
163
|
},
|
|
163
164
|
scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
|
|
164
165
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -176,8 +177,8 @@ const MatrixHelper = {
|
|
|
176
177
|
t.d = c * sinR + d * cosR;
|
|
177
178
|
},
|
|
178
179
|
rotateOfOuter(t, origin, rotation) {
|
|
179
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
180
|
-
M$6.rotateOfInner(t, tempPoint$
|
|
180
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
181
|
+
M$6.rotateOfInner(t, tempPoint$3, rotation);
|
|
181
182
|
},
|
|
182
183
|
rotateOfInner(t, origin, rotation) {
|
|
183
184
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -198,8 +199,8 @@ const MatrixHelper = {
|
|
|
198
199
|
}
|
|
199
200
|
},
|
|
200
201
|
skewOfOuter(t, origin, skewX, skewY) {
|
|
201
|
-
M$6.toInnerPoint(t, origin, tempPoint$
|
|
202
|
-
M$6.skewOfInner(t, tempPoint$
|
|
202
|
+
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
203
|
+
M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
|
|
203
204
|
},
|
|
204
205
|
skewOfInner(t, origin, skewX, skewY = 0) {
|
|
205
206
|
M$6.translateInner(t, origin.x, origin.y);
|
|
@@ -446,19 +447,19 @@ const PointHelper = {
|
|
|
446
447
|
},
|
|
447
448
|
tempToInnerOf(t, matrix) {
|
|
448
449
|
const { tempPoint: temp } = P$5;
|
|
449
|
-
copy$
|
|
450
|
+
copy$a(temp, t);
|
|
450
451
|
toInnerPoint$2(matrix, temp, temp);
|
|
451
452
|
return temp;
|
|
452
453
|
},
|
|
453
454
|
tempToOuterOf(t, matrix) {
|
|
454
455
|
const { tempPoint: temp } = P$5;
|
|
455
|
-
copy$
|
|
456
|
+
copy$a(temp, t);
|
|
456
457
|
toOuterPoint$2(matrix, temp, temp);
|
|
457
458
|
return temp;
|
|
458
459
|
},
|
|
459
460
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
460
461
|
const { tempRadiusPoint: temp } = P$5;
|
|
461
|
-
copy$
|
|
462
|
+
copy$a(temp, t);
|
|
462
463
|
P$5.toInnerRadiusPointOf(t, matrix, temp);
|
|
463
464
|
return temp;
|
|
464
465
|
},
|
|
@@ -525,7 +526,7 @@ const PointHelper = {
|
|
|
525
526
|
}
|
|
526
527
|
};
|
|
527
528
|
const P$5 = PointHelper;
|
|
528
|
-
const { getDistanceFrom, copy: copy$
|
|
529
|
+
const { getDistanceFrom, copy: copy$a, getAtan2 } = P$5;
|
|
529
530
|
|
|
530
531
|
class Point {
|
|
531
532
|
constructor(x, y) {
|
|
@@ -593,6 +594,7 @@ class Point {
|
|
|
593
594
|
return this;
|
|
594
595
|
}
|
|
595
596
|
}
|
|
597
|
+
const tempPoint$2 = new Point();
|
|
596
598
|
|
|
597
599
|
class Matrix {
|
|
598
600
|
constructor(a, b, c, d, e, f) {
|
|
@@ -602,6 +604,12 @@ class Matrix {
|
|
|
602
604
|
typeof a === 'object' ? MatrixHelper.copy(this, a) : MatrixHelper.set(this, a, b, c, d, e, f);
|
|
603
605
|
return this;
|
|
604
606
|
}
|
|
607
|
+
setWith(dataWithScale) {
|
|
608
|
+
MatrixHelper.copy(this, dataWithScale);
|
|
609
|
+
this.scaleX = dataWithScale.scaleX;
|
|
610
|
+
this.scaleY = dataWithScale.scaleY;
|
|
611
|
+
return this;
|
|
612
|
+
}
|
|
605
613
|
get() {
|
|
606
614
|
const { a, b, c, d, e, f } = this;
|
|
607
615
|
return { a, b, c, d, e, f };
|
|
@@ -621,6 +629,12 @@ class Matrix {
|
|
|
621
629
|
MatrixHelper.scale(this, x, y);
|
|
622
630
|
return this;
|
|
623
631
|
}
|
|
632
|
+
scaleWith(x, y) {
|
|
633
|
+
MatrixHelper.scale(this, x, y);
|
|
634
|
+
this.scaleX *= x;
|
|
635
|
+
this.scaleY *= y || x;
|
|
636
|
+
return this;
|
|
637
|
+
}
|
|
624
638
|
scaleOfOuter(origin, x, y) {
|
|
625
639
|
MatrixHelper.scaleOfOuter(this, origin, x, y);
|
|
626
640
|
return this;
|
|
@@ -673,6 +687,12 @@ class Matrix {
|
|
|
673
687
|
MatrixHelper.invert(this);
|
|
674
688
|
return this;
|
|
675
689
|
}
|
|
690
|
+
invertWith() {
|
|
691
|
+
MatrixHelper.invert(this);
|
|
692
|
+
this.scaleX = 1 / this.scaleX;
|
|
693
|
+
this.scaleY = 1 / this.scaleY;
|
|
694
|
+
return this;
|
|
695
|
+
}
|
|
676
696
|
toOuterPoint(inner, to, distance) {
|
|
677
697
|
MatrixHelper.toOuterPoint(this, inner, to, distance);
|
|
678
698
|
}
|
|
@@ -693,6 +713,7 @@ class Matrix {
|
|
|
693
713
|
MatrixHelper.reset(this);
|
|
694
714
|
}
|
|
695
715
|
}
|
|
716
|
+
const tempMatrix = new Matrix();
|
|
696
717
|
|
|
697
718
|
const TwoPointBoundsHelper = {
|
|
698
719
|
tempPointBounds: {},
|
|
@@ -781,7 +802,7 @@ const BoundsHelper = {
|
|
|
781
802
|
to = t;
|
|
782
803
|
}
|
|
783
804
|
else {
|
|
784
|
-
copy$
|
|
805
|
+
copy$9(to, t);
|
|
785
806
|
}
|
|
786
807
|
if (parent) {
|
|
787
808
|
to.offsetX = -(B.maxX(parent) - t.x);
|
|
@@ -856,8 +877,8 @@ const BoundsHelper = {
|
|
|
856
877
|
B.move(to, -matrix.e, -matrix.f);
|
|
857
878
|
B.scale(to, 1 / matrix.a, 1 / matrix.d);
|
|
858
879
|
},
|
|
859
|
-
getFitMatrix(t, put) {
|
|
860
|
-
const scale = Math.min(
|
|
880
|
+
getFitMatrix(t, put, baseScale = 1) {
|
|
881
|
+
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
861
882
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
862
883
|
},
|
|
863
884
|
getSpread(t, spreadX, spreadY) {
|
|
@@ -891,11 +912,15 @@ const BoundsHelper = {
|
|
|
891
912
|
t.width = float(t.width, maxLength);
|
|
892
913
|
t.height = float(t.height, maxLength);
|
|
893
914
|
},
|
|
894
|
-
add(t, bounds) {
|
|
915
|
+
add(t, bounds, isPoint) {
|
|
895
916
|
right$1 = t.x + t.width;
|
|
896
917
|
bottom$1 = t.y + t.height;
|
|
897
|
-
boundsRight = bounds.x
|
|
898
|
-
boundsBottom = bounds.y
|
|
918
|
+
boundsRight = bounds.x;
|
|
919
|
+
boundsBottom = bounds.y;
|
|
920
|
+
if (!isPoint) {
|
|
921
|
+
boundsRight += bounds.width;
|
|
922
|
+
boundsBottom += bounds.height;
|
|
923
|
+
}
|
|
899
924
|
right$1 = right$1 > boundsRight ? right$1 : boundsRight;
|
|
900
925
|
bottom$1 = bottom$1 > boundsBottom ? bottom$1 : boundsBottom;
|
|
901
926
|
t.x = t.x < bounds.x ? t.x : bounds.x;
|
|
@@ -920,7 +945,7 @@ const BoundsHelper = {
|
|
|
920
945
|
if (first) {
|
|
921
946
|
first = false;
|
|
922
947
|
if (!addMode)
|
|
923
|
-
copy$
|
|
948
|
+
copy$9(t, bounds);
|
|
924
949
|
}
|
|
925
950
|
else {
|
|
926
951
|
add$1(t, bounds);
|
|
@@ -934,6 +959,9 @@ const BoundsHelper = {
|
|
|
934
959
|
points.forEach((point, index) => index === 0 ? setPoint$3(tempPointBounds$1, point.x, point.y) : addPoint$3(tempPointBounds$1, point.x, point.y));
|
|
935
960
|
toBounds$4(tempPointBounds$1, t);
|
|
936
961
|
},
|
|
962
|
+
addPoint(t, point) {
|
|
963
|
+
add$1(t, point, true);
|
|
964
|
+
},
|
|
937
965
|
getPoints(t) {
|
|
938
966
|
const { x, y, width, height } = t;
|
|
939
967
|
return [
|
|
@@ -995,7 +1023,7 @@ const BoundsHelper = {
|
|
|
995
1023
|
}
|
|
996
1024
|
};
|
|
997
1025
|
const B = BoundsHelper;
|
|
998
|
-
const { add: add$1, copy: copy$
|
|
1026
|
+
const { add: add$1, copy: copy$9 } = B;
|
|
999
1027
|
|
|
1000
1028
|
class Bounds {
|
|
1001
1029
|
get minX() { return BoundsHelper.minX(this); }
|
|
@@ -1036,8 +1064,8 @@ class Bounds {
|
|
|
1036
1064
|
BoundsHelper.toInnerOf(this, matrix, to);
|
|
1037
1065
|
return this;
|
|
1038
1066
|
}
|
|
1039
|
-
getFitMatrix(put) {
|
|
1040
|
-
return BoundsHelper.getFitMatrix(this, put);
|
|
1067
|
+
getFitMatrix(put, baseScale) {
|
|
1068
|
+
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1041
1069
|
}
|
|
1042
1070
|
spread(fourNumber, spreadY) {
|
|
1043
1071
|
BoundsHelper.spread(this, fourNumber, spreadY);
|
|
@@ -1083,6 +1111,10 @@ class Bounds {
|
|
|
1083
1111
|
BoundsHelper.setPoints(this, points);
|
|
1084
1112
|
return this;
|
|
1085
1113
|
}
|
|
1114
|
+
addPoint(point) {
|
|
1115
|
+
BoundsHelper.addPoint(this, point);
|
|
1116
|
+
return this;
|
|
1117
|
+
}
|
|
1086
1118
|
getPoints() {
|
|
1087
1119
|
return BoundsHelper.getPoints(this);
|
|
1088
1120
|
}
|
|
@@ -1115,6 +1147,7 @@ class Bounds {
|
|
|
1115
1147
|
BoundsHelper.reset(this);
|
|
1116
1148
|
}
|
|
1117
1149
|
}
|
|
1150
|
+
const tempBounds$1 = new Bounds();
|
|
1118
1151
|
|
|
1119
1152
|
class AutoBounds {
|
|
1120
1153
|
constructor(top, right, bottom, left, width, height) {
|
|
@@ -1260,7 +1293,7 @@ function getNameList(name) {
|
|
|
1260
1293
|
}
|
|
1261
1294
|
const D$4 = Debug;
|
|
1262
1295
|
|
|
1263
|
-
const debug$
|
|
1296
|
+
const debug$d = Debug.get('RunTime');
|
|
1264
1297
|
const Run = {
|
|
1265
1298
|
currentId: 0,
|
|
1266
1299
|
currentName: '',
|
|
@@ -1278,7 +1311,7 @@ const Run = {
|
|
|
1278
1311
|
const time = R.idMap[id], name = R.nameMap[id];
|
|
1279
1312
|
const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
|
|
1280
1313
|
R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
|
|
1281
|
-
debug$
|
|
1314
|
+
debug$d.log(name, duration, 'ms');
|
|
1282
1315
|
},
|
|
1283
1316
|
endOfName(name, microsecond) {
|
|
1284
1317
|
const id = R.nameToIdMap[name];
|
|
@@ -1288,13 +1321,13 @@ const Run = {
|
|
|
1288
1321
|
};
|
|
1289
1322
|
const R = Run;
|
|
1290
1323
|
|
|
1291
|
-
const debug$
|
|
1324
|
+
const debug$c = Debug.get('UICreator');
|
|
1292
1325
|
const UICreator = {
|
|
1293
1326
|
list: {},
|
|
1294
1327
|
register(UI) {
|
|
1295
1328
|
const { __tag: tag } = UI.prototype;
|
|
1296
1329
|
if (list$1[tag]) {
|
|
1297
|
-
debug$
|
|
1330
|
+
debug$c.repeat(tag);
|
|
1298
1331
|
}
|
|
1299
1332
|
else {
|
|
1300
1333
|
list$1[tag] = UI;
|
|
@@ -1316,7 +1349,7 @@ const UICreator = {
|
|
|
1316
1349
|
};
|
|
1317
1350
|
const { list: list$1 } = UICreator;
|
|
1318
1351
|
|
|
1319
|
-
const debug$
|
|
1352
|
+
const debug$b = Debug.get('EventCreator');
|
|
1320
1353
|
const EventCreator = {
|
|
1321
1354
|
nameList: {},
|
|
1322
1355
|
register(Event) {
|
|
@@ -1324,7 +1357,7 @@ const EventCreator = {
|
|
|
1324
1357
|
Object.keys(Event).forEach(key => {
|
|
1325
1358
|
name = Event[key];
|
|
1326
1359
|
if (typeof name === 'string')
|
|
1327
|
-
nameList[name] ? debug$
|
|
1360
|
+
nameList[name] ? debug$b.repeat(name) : nameList[name] = Event;
|
|
1328
1361
|
});
|
|
1329
1362
|
},
|
|
1330
1363
|
changeName(oldName, newName) {
|
|
@@ -1535,36 +1568,7 @@ var Answer;
|
|
|
1535
1568
|
Answer[Answer["NoAndSkip"] = 2] = "NoAndSkip";
|
|
1536
1569
|
Answer[Answer["YesAndSkip"] = 3] = "YesAndSkip";
|
|
1537
1570
|
})(Answer || (Answer = {}));
|
|
1538
|
-
|
|
1539
|
-
const FileHelper = {
|
|
1540
|
-
opacityTypes: ['png', 'webp', 'svg'],
|
|
1541
|
-
upperCaseTypeMap: {},
|
|
1542
|
-
mineType(type) {
|
|
1543
|
-
if (!type || type.startsWith('image'))
|
|
1544
|
-
return type;
|
|
1545
|
-
if (type === 'jpg')
|
|
1546
|
-
type = 'jpeg';
|
|
1547
|
-
return 'image/' + type;
|
|
1548
|
-
},
|
|
1549
|
-
fileType(filename) {
|
|
1550
|
-
const l = filename.split('.');
|
|
1551
|
-
return l[l.length - 1];
|
|
1552
|
-
},
|
|
1553
|
-
isOpaqueImage(filename) {
|
|
1554
|
-
const type = F$4.fileType(filename);
|
|
1555
|
-
return ['jpg', 'jpeg'].some(item => item === type);
|
|
1556
|
-
},
|
|
1557
|
-
getExportOptions(options) {
|
|
1558
|
-
switch (typeof options) {
|
|
1559
|
-
case 'object': return options;
|
|
1560
|
-
case 'number': return { quality: options };
|
|
1561
|
-
case 'boolean': return { blob: options };
|
|
1562
|
-
default: return {};
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
};
|
|
1566
|
-
const F$4 = FileHelper;
|
|
1567
|
-
F$4.opacityTypes.forEach(type => F$4.upperCaseTypeMap[type] = type.toUpperCase());
|
|
1571
|
+
const emptyData = {};
|
|
1568
1572
|
|
|
1569
1573
|
/******************************************************************************
|
|
1570
1574
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1888,10 +1892,8 @@ __decorate([
|
|
|
1888
1892
|
contextMethod()
|
|
1889
1893
|
], Canvas$1.prototype, "strokeText", null);
|
|
1890
1894
|
|
|
1891
|
-
const { copy: copy$
|
|
1892
|
-
const temp = new Bounds();
|
|
1895
|
+
const { copy: copy$8 } = MatrixHelper;
|
|
1893
1896
|
const minSize = { width: 1, height: 1, pixelRatio: 1 };
|
|
1894
|
-
const debug$9 = Debug.get('LeaferCanvasBase');
|
|
1895
1897
|
const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
|
|
1896
1898
|
class LeaferCanvasBase extends Canvas$1 {
|
|
1897
1899
|
get width() { return this.size.width; }
|
|
@@ -1918,44 +1920,15 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
1918
1920
|
}
|
|
1919
1921
|
init() { }
|
|
1920
1922
|
__createContext() {
|
|
1921
|
-
|
|
1923
|
+
const { view } = this;
|
|
1924
|
+
const { contextSettings } = this.config;
|
|
1925
|
+
this.context = contextSettings ? view.getContext('2d', contextSettings) : view.getContext('2d');
|
|
1922
1926
|
this.__bindContext();
|
|
1923
1927
|
}
|
|
1924
|
-
export(
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
}
|
|
1929
|
-
else if (blob) {
|
|
1930
|
-
return this.toBlob(filename, quality);
|
|
1931
|
-
}
|
|
1932
|
-
else {
|
|
1933
|
-
return this.toDataURL(filename, quality);
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
toBlob(type, quality) {
|
|
1937
|
-
return new Promise((resolve) => {
|
|
1938
|
-
Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
1939
|
-
resolve(blob);
|
|
1940
|
-
}).catch((e) => {
|
|
1941
|
-
debug$9.error(e);
|
|
1942
|
-
resolve(null);
|
|
1943
|
-
});
|
|
1944
|
-
});
|
|
1945
|
-
}
|
|
1946
|
-
toDataURL(type, quality) {
|
|
1947
|
-
return Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
1948
|
-
}
|
|
1949
|
-
saveAs(filename, quality) {
|
|
1950
|
-
return new Promise((resolve) => {
|
|
1951
|
-
Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
1952
|
-
resolve(true);
|
|
1953
|
-
}).catch((e) => {
|
|
1954
|
-
debug$9.error(e);
|
|
1955
|
-
resolve(false);
|
|
1956
|
-
});
|
|
1957
|
-
});
|
|
1958
|
-
}
|
|
1928
|
+
export(_filename, _options) { return undefined; }
|
|
1929
|
+
toBlob(_type, _quality) { return undefined; }
|
|
1930
|
+
toDataURL(_type, _quality) { return undefined; }
|
|
1931
|
+
saveAs(_filename, _quality) { return undefined; }
|
|
1959
1932
|
resize(size) {
|
|
1960
1933
|
if (this.isSameSize(size))
|
|
1961
1934
|
return;
|
|
@@ -2023,13 +1996,9 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2023
1996
|
restoreBlendMode() {
|
|
2024
1997
|
this.blendMode = this.savedBlendMode;
|
|
2025
1998
|
}
|
|
2026
|
-
hitFill(
|
|
2027
|
-
|
|
2028
|
-
}
|
|
2029
|
-
hitStroke(point, strokeWidth) {
|
|
2030
|
-
this.strokeWidth = strokeWidth;
|
|
2031
|
-
return this.context.isPointInStroke(point.x, point.y);
|
|
2032
|
-
}
|
|
1999
|
+
hitFill(_point, _fillRule) { return true; }
|
|
2000
|
+
hitStroke(_point, _strokeWidth) { return true; }
|
|
2001
|
+
hitPixel(_radiusPoint, _offset, _scale = 1) { return true; }
|
|
2033
2002
|
setWorldShadow(x, y, blur, color) {
|
|
2034
2003
|
const { pixelRatio } = this;
|
|
2035
2004
|
this.shadowOffsetX = x * pixelRatio;
|
|
@@ -2088,8 +2057,8 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2088
2057
|
if (blendMode)
|
|
2089
2058
|
this.blendMode = blendMode;
|
|
2090
2059
|
this.fillStyle = color;
|
|
2091
|
-
|
|
2092
|
-
this.fillRect(
|
|
2060
|
+
tempBounds$1.set(bounds).scale(this.pixelRatio);
|
|
2061
|
+
this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2093
2062
|
if (blendMode)
|
|
2094
2063
|
this.blendMode = 'source-over';
|
|
2095
2064
|
}
|
|
@@ -2097,23 +2066,23 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2097
2066
|
if (blendMode)
|
|
2098
2067
|
this.blendMode = blendMode;
|
|
2099
2068
|
this.strokeStyle = color;
|
|
2100
|
-
|
|
2101
|
-
this.strokeRect(
|
|
2069
|
+
tempBounds$1.set(bounds).scale(this.pixelRatio);
|
|
2070
|
+
this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2102
2071
|
if (blendMode)
|
|
2103
2072
|
this.blendMode = 'source-over';
|
|
2104
2073
|
}
|
|
2105
2074
|
clearWorld(bounds, ceilPixel) {
|
|
2106
|
-
|
|
2075
|
+
tempBounds$1.set(bounds).scale(this.pixelRatio);
|
|
2107
2076
|
if (ceilPixel)
|
|
2108
|
-
|
|
2109
|
-
this.clearRect(
|
|
2077
|
+
tempBounds$1.ceil();
|
|
2078
|
+
this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2110
2079
|
}
|
|
2111
2080
|
clipWorld(bounds, ceilPixel) {
|
|
2112
2081
|
this.beginPath();
|
|
2113
|
-
|
|
2082
|
+
tempBounds$1.set(bounds).scale(this.pixelRatio);
|
|
2114
2083
|
if (ceilPixel)
|
|
2115
|
-
|
|
2116
|
-
this.rect(
|
|
2084
|
+
tempBounds$1.ceil();
|
|
2085
|
+
this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2117
2086
|
this.clip();
|
|
2118
2087
|
}
|
|
2119
2088
|
clear() {
|
|
@@ -2127,7 +2096,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2127
2096
|
const canvas = this.manager ? this.manager.get(this.size) : Creator.canvas(Object.assign({}, this.size));
|
|
2128
2097
|
canvas.save();
|
|
2129
2098
|
if (useSameWorldTransform)
|
|
2130
|
-
copy$
|
|
2099
|
+
copy$8(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
|
|
2131
2100
|
if (useSameSmooth)
|
|
2132
2101
|
canvas.smooth = this.smooth;
|
|
2133
2102
|
return canvas;
|
|
@@ -2497,10 +2466,10 @@ const EllipseHelper = {
|
|
|
2497
2466
|
}
|
|
2498
2467
|
};
|
|
2499
2468
|
|
|
2500
|
-
const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, 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$
|
|
2469
|
+
const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, 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;
|
|
2501
2470
|
const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2502
2471
|
const { ellipticalArc } = EllipseHelper;
|
|
2503
|
-
const debug$
|
|
2472
|
+
const debug$a = Debug.get('PathConvert');
|
|
2504
2473
|
const setEndPoint$1 = {};
|
|
2505
2474
|
const PathConvert = {
|
|
2506
2475
|
current: { dot: 0 },
|
|
@@ -2712,7 +2681,7 @@ const PathConvert = {
|
|
|
2712
2681
|
y = setEndPoint$1.y;
|
|
2713
2682
|
i += 9;
|
|
2714
2683
|
break;
|
|
2715
|
-
case F$
|
|
2684
|
+
case F$4:
|
|
2716
2685
|
curveMode ? ellipse$4(data, old[i + 1], old[i + 2], old[i + 3], old[i + 4], 0, 0, 360, false) : copyData(data, old, i, 5);
|
|
2717
2686
|
x = old[i + 1] + old[i + 3];
|
|
2718
2687
|
y = old[i + 2];
|
|
@@ -2737,7 +2706,7 @@ const PathConvert = {
|
|
|
2737
2706
|
i += 6;
|
|
2738
2707
|
break;
|
|
2739
2708
|
default:
|
|
2740
|
-
debug$
|
|
2709
|
+
debug$a.error(`command: ${command} [index:${i}]`, old);
|
|
2741
2710
|
return data;
|
|
2742
2711
|
}
|
|
2743
2712
|
lastCommand = command;
|
|
@@ -2761,7 +2730,7 @@ const PathConvert = {
|
|
|
2761
2730
|
};
|
|
2762
2731
|
const { current, pushData, copyData } = PathConvert;
|
|
2763
2732
|
|
|
2764
|
-
const { M: M$3, L: L$4, C: C$3, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$
|
|
2733
|
+
const { M: M$3, L: L$4, C: C$3, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$3, O: O$2, P: P$2, U: U$2 } = PathCommandMap;
|
|
2765
2734
|
const { getMinDistanceFrom, getRadianFrom } = PointHelper;
|
|
2766
2735
|
const { tan, min, abs: abs$2 } = Math;
|
|
2767
2736
|
const startPoint = {};
|
|
@@ -2803,7 +2772,7 @@ const PathCommandDataHelper = {
|
|
|
2803
2772
|
},
|
|
2804
2773
|
ellipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2805
2774
|
if (rotation === undefined) {
|
|
2806
|
-
data.push(F$
|
|
2775
|
+
data.push(F$3, x, y, radiusX, radiusY);
|
|
2807
2776
|
}
|
|
2808
2777
|
else {
|
|
2809
2778
|
if (startAngle === undefined)
|
|
@@ -2853,6 +2822,7 @@ class PathCreator {
|
|
|
2853
2822
|
set path(value) { this.__path = value; }
|
|
2854
2823
|
get path() { return this.__path; }
|
|
2855
2824
|
constructor(path) {
|
|
2825
|
+
this.clearPath = this.beginPath;
|
|
2856
2826
|
this.set(path);
|
|
2857
2827
|
}
|
|
2858
2828
|
set(path) {
|
|
@@ -2922,8 +2892,8 @@ class PathCreator {
|
|
|
2922
2892
|
}
|
|
2923
2893
|
}
|
|
2924
2894
|
|
|
2925
|
-
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$
|
|
2926
|
-
const debug$
|
|
2895
|
+
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
2896
|
+
const debug$9 = Debug.get('PathDrawer');
|
|
2927
2897
|
const PathDrawer = {
|
|
2928
2898
|
drawPathByData(drawer, data) {
|
|
2929
2899
|
if (!data)
|
|
@@ -2969,7 +2939,7 @@ const PathDrawer = {
|
|
|
2969
2939
|
drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5] * OneRadian, data[i + 6] * OneRadian, data[i + 7] * OneRadian, data[i + 8]);
|
|
2970
2940
|
i += 9;
|
|
2971
2941
|
break;
|
|
2972
|
-
case F$
|
|
2942
|
+
case F$2:
|
|
2973
2943
|
drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], 0, 0, PI2, false);
|
|
2974
2944
|
i += 5;
|
|
2975
2945
|
break;
|
|
@@ -2986,17 +2956,17 @@ const PathDrawer = {
|
|
|
2986
2956
|
i += 6;
|
|
2987
2957
|
break;
|
|
2988
2958
|
default:
|
|
2989
|
-
debug$
|
|
2959
|
+
debug$9.error(`command: ${command} [index:${i}]`, data);
|
|
2990
2960
|
return;
|
|
2991
2961
|
}
|
|
2992
2962
|
}
|
|
2993
2963
|
}
|
|
2994
2964
|
};
|
|
2995
2965
|
|
|
2996
|
-
const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F, O, P, U } = PathCommandMap;
|
|
2966
|
+
const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
|
|
2997
2967
|
const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
|
|
2998
|
-
const { addPointBounds, copy: copy$
|
|
2999
|
-
const debug$
|
|
2968
|
+
const { addPointBounds, copy: copy$7, addPoint: addPoint$1, setPoint: setPoint$1, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
2969
|
+
const debug$8 = Debug.get('PathBounds');
|
|
3000
2970
|
let radius, radiusX, radiusY;
|
|
3001
2971
|
const tempPointBounds = {};
|
|
3002
2972
|
const setPointBounds = {};
|
|
@@ -3068,12 +3038,12 @@ const PathBounds = {
|
|
|
3068
3038
|
break;
|
|
3069
3039
|
case G:
|
|
3070
3040
|
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);
|
|
3071
|
-
i === 0 ? copy$
|
|
3041
|
+
i === 0 ? copy$7(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3072
3042
|
x = setEndPoint.x;
|
|
3073
3043
|
y = setEndPoint.y;
|
|
3074
3044
|
i += 9;
|
|
3075
3045
|
break;
|
|
3076
|
-
case F:
|
|
3046
|
+
case F$1:
|
|
3077
3047
|
x = data[i + 1];
|
|
3078
3048
|
y = data[i + 2];
|
|
3079
3049
|
radiusX = data[i + 3];
|
|
@@ -3084,7 +3054,7 @@ const PathBounds = {
|
|
|
3084
3054
|
break;
|
|
3085
3055
|
case O:
|
|
3086
3056
|
arc(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], tempPointBounds, setEndPoint);
|
|
3087
|
-
i === 0 ? copy$
|
|
3057
|
+
i === 0 ? copy$7(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3088
3058
|
x = setEndPoint.x;
|
|
3089
3059
|
y = setEndPoint.y;
|
|
3090
3060
|
i += 7;
|
|
@@ -3099,13 +3069,13 @@ const PathBounds = {
|
|
|
3099
3069
|
break;
|
|
3100
3070
|
case U:
|
|
3101
3071
|
arcTo$1(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
|
|
3102
|
-
i === 0 ? copy$
|
|
3072
|
+
i === 0 ? copy$7(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
|
|
3103
3073
|
x = setEndPoint.x;
|
|
3104
3074
|
y = setEndPoint.y;
|
|
3105
3075
|
i += 6;
|
|
3106
3076
|
break;
|
|
3107
3077
|
default:
|
|
3108
|
-
debug$
|
|
3078
|
+
debug$8.error(`command: ${command} [index:${i}]`, data);
|
|
3109
3079
|
return;
|
|
3110
3080
|
}
|
|
3111
3081
|
}
|
|
@@ -3191,7 +3161,37 @@ function canvasPatch(drawer) {
|
|
|
3191
3161
|
roundRect(drawer);
|
|
3192
3162
|
}
|
|
3193
3163
|
|
|
3194
|
-
const
|
|
3164
|
+
const FileHelper = {
|
|
3165
|
+
opacityTypes: ['png', 'webp', 'svg'],
|
|
3166
|
+
upperCaseTypeMap: {},
|
|
3167
|
+
mineType(type) {
|
|
3168
|
+
if (!type || type.startsWith('image'))
|
|
3169
|
+
return type;
|
|
3170
|
+
if (type === 'jpg')
|
|
3171
|
+
type = 'jpeg';
|
|
3172
|
+
return 'image/' + type;
|
|
3173
|
+
},
|
|
3174
|
+
fileType(filename) {
|
|
3175
|
+
const l = filename.split('.');
|
|
3176
|
+
return l[l.length - 1];
|
|
3177
|
+
},
|
|
3178
|
+
isOpaqueImage(filename) {
|
|
3179
|
+
const type = F.fileType(filename);
|
|
3180
|
+
return ['jpg', 'jpeg'].some(item => item === type);
|
|
3181
|
+
},
|
|
3182
|
+
getExportOptions(options) {
|
|
3183
|
+
switch (typeof options) {
|
|
3184
|
+
case 'object': return options;
|
|
3185
|
+
case 'number': return { quality: options };
|
|
3186
|
+
case 'boolean': return { blob: options };
|
|
3187
|
+
default: return {};
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
};
|
|
3191
|
+
const F = FileHelper;
|
|
3192
|
+
F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3193
|
+
|
|
3194
|
+
const debug$7 = Debug.get('TaskProcessor');
|
|
3195
3195
|
class TaskItem {
|
|
3196
3196
|
constructor(task) {
|
|
3197
3197
|
this.parallel = true;
|
|
@@ -3206,7 +3206,7 @@ class TaskItem {
|
|
|
3206
3206
|
yield this.task();
|
|
3207
3207
|
}
|
|
3208
3208
|
catch (error) {
|
|
3209
|
-
debug$
|
|
3209
|
+
debug$7.error(error);
|
|
3210
3210
|
}
|
|
3211
3211
|
});
|
|
3212
3212
|
}
|
|
@@ -3490,6 +3490,7 @@ const ImageManager = {
|
|
|
3490
3490
|
},
|
|
3491
3491
|
destroy() {
|
|
3492
3492
|
I.map = {};
|
|
3493
|
+
I.recycledList = [];
|
|
3493
3494
|
}
|
|
3494
3495
|
};
|
|
3495
3496
|
const I = ImageManager;
|
|
@@ -3604,84 +3605,75 @@ function getNames(object) {
|
|
|
3604
3605
|
return Object.getOwnPropertyNames(object);
|
|
3605
3606
|
}
|
|
3606
3607
|
|
|
3607
|
-
function
|
|
3608
|
+
function decorateLeafAttr(defaultValue, descriptorFn) {
|
|
3609
|
+
return (target, key) => defineLeafAttr(target, key, defaultValue, descriptorFn && descriptorFn(key));
|
|
3610
|
+
}
|
|
3611
|
+
function attr(partDescriptor) {
|
|
3612
|
+
return partDescriptor;
|
|
3613
|
+
}
|
|
3614
|
+
function defineLeafAttr(target, key, defaultValue, partDescriptor) {
|
|
3608
3615
|
const defaultDescriptor = {
|
|
3609
3616
|
get() { return this.__getAttr(key); },
|
|
3610
3617
|
set(value) { this.__setAttr(key, value); },
|
|
3611
3618
|
configurable: true,
|
|
3612
3619
|
enumerable: true
|
|
3613
3620
|
};
|
|
3614
|
-
defineKey(target, key, Object.assign(defaultDescriptor,
|
|
3621
|
+
defineKey(target, key, Object.assign(defaultDescriptor, partDescriptor || {}));
|
|
3615
3622
|
defineDataProcessor(target, key, defaultValue);
|
|
3616
3623
|
}
|
|
3617
3624
|
function dataType(defaultValue) {
|
|
3618
|
-
return (
|
|
3619
|
-
defineLeafAttr(target, key, defaultValue);
|
|
3620
|
-
};
|
|
3625
|
+
return decorateLeafAttr(defaultValue);
|
|
3621
3626
|
}
|
|
3622
|
-
function positionType(defaultValue) {
|
|
3623
|
-
return (
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
});
|
|
3630
|
-
};
|
|
3627
|
+
function positionType(defaultValue, checkFiniteNumber) {
|
|
3628
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3629
|
+
set(value) {
|
|
3630
|
+
this.__setAttr(key, value, checkFiniteNumber);
|
|
3631
|
+
this.__layout.matrixChanged || this.__layout.matrixChange();
|
|
3632
|
+
}
|
|
3633
|
+
}));
|
|
3631
3634
|
}
|
|
3632
3635
|
function autoLayoutType(defaultValue) {
|
|
3633
|
-
return (
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
});
|
|
3643
|
-
};
|
|
3636
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3637
|
+
set(value) {
|
|
3638
|
+
this.__setAttr(key, value);
|
|
3639
|
+
this.__layout.matrixChanged || this.__layout.matrixChange();
|
|
3640
|
+
this.__hasAutoLayout = !!value;
|
|
3641
|
+
if (!this.__local)
|
|
3642
|
+
this.__layout.createLocal();
|
|
3643
|
+
}
|
|
3644
|
+
}));
|
|
3644
3645
|
}
|
|
3645
|
-
function scaleType(defaultValue) {
|
|
3646
|
-
return (
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
});
|
|
3653
|
-
};
|
|
3646
|
+
function scaleType(defaultValue, checkFiniteNumber) {
|
|
3647
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3648
|
+
set(value) {
|
|
3649
|
+
this.__setAttr(key, value, checkFiniteNumber);
|
|
3650
|
+
this.__layout.scaleChanged || this.__layout.scaleChange();
|
|
3651
|
+
}
|
|
3652
|
+
}));
|
|
3654
3653
|
}
|
|
3655
|
-
function rotationType(defaultValue) {
|
|
3656
|
-
return (
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
});
|
|
3663
|
-
};
|
|
3654
|
+
function rotationType(defaultValue, checkFiniteNumber) {
|
|
3655
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3656
|
+
set(value) {
|
|
3657
|
+
this.__setAttr(key, value, checkFiniteNumber);
|
|
3658
|
+
this.__layout.rotationChanged || this.__layout.rotationChange();
|
|
3659
|
+
}
|
|
3660
|
+
}));
|
|
3664
3661
|
}
|
|
3665
|
-
function boundsType(defaultValue) {
|
|
3666
|
-
return (
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
}
|
|
3672
|
-
});
|
|
3673
|
-
};
|
|
3662
|
+
function boundsType(defaultValue, checkFiniteNumber) {
|
|
3663
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3664
|
+
set(value) {
|
|
3665
|
+
this.__setAttr(key, value, checkFiniteNumber) && doBoundsType(this);
|
|
3666
|
+
}
|
|
3667
|
+
}));
|
|
3674
3668
|
}
|
|
3675
3669
|
function naturalBoundsType(defaultValue) {
|
|
3676
|
-
return (
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
});
|
|
3684
|
-
};
|
|
3670
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3671
|
+
set(value) {
|
|
3672
|
+
this.__setAttr(key, value);
|
|
3673
|
+
doBoundsType(this);
|
|
3674
|
+
this.__.__removeNaturalSize();
|
|
3675
|
+
}
|
|
3676
|
+
}));
|
|
3685
3677
|
}
|
|
3686
3678
|
function doBoundsType(leaf) {
|
|
3687
3679
|
leaf.__layout.boxChanged || leaf.__layout.boxChange();
|
|
@@ -3689,27 +3681,22 @@ function doBoundsType(leaf) {
|
|
|
3689
3681
|
leaf.__layout.matrixChanged || leaf.__layout.matrixChange();
|
|
3690
3682
|
}
|
|
3691
3683
|
function pathInputType(defaultValue) {
|
|
3692
|
-
return (
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
});
|
|
3701
|
-
};
|
|
3684
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3685
|
+
set(value) {
|
|
3686
|
+
if (this.__.__pathInputed !== 2)
|
|
3687
|
+
this.__.__pathInputed = value ? 1 : 0;
|
|
3688
|
+
this.__setAttr(key, value);
|
|
3689
|
+
doBoundsType(this);
|
|
3690
|
+
}
|
|
3691
|
+
}));
|
|
3702
3692
|
}
|
|
3703
3693
|
const pathType = boundsType;
|
|
3704
3694
|
function affectStrokeBoundsType(defaultValue) {
|
|
3705
|
-
return (
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
}
|
|
3711
|
-
});
|
|
3712
|
-
};
|
|
3695
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3696
|
+
set(value) {
|
|
3697
|
+
this.__setAttr(key, value) && doStrokeType(this);
|
|
3698
|
+
}
|
|
3699
|
+
}));
|
|
3713
3700
|
}
|
|
3714
3701
|
function doStrokeType(leaf) {
|
|
3715
3702
|
leaf.__layout.strokeChanged || leaf.__layout.strokeChange();
|
|
@@ -3718,91 +3705,75 @@ function doStrokeType(leaf) {
|
|
|
3718
3705
|
}
|
|
3719
3706
|
const strokeType = affectStrokeBoundsType;
|
|
3720
3707
|
function affectRenderBoundsType(defaultValue) {
|
|
3721
|
-
return (
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
});
|
|
3728
|
-
};
|
|
3708
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3709
|
+
set(value) {
|
|
3710
|
+
this.__setAttr(key, value);
|
|
3711
|
+
this.__layout.renderChanged || this.__layout.renderChange();
|
|
3712
|
+
}
|
|
3713
|
+
}));
|
|
3729
3714
|
}
|
|
3730
3715
|
function surfaceType(defaultValue) {
|
|
3731
|
-
return (
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
});
|
|
3738
|
-
};
|
|
3716
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3717
|
+
set(value) {
|
|
3718
|
+
this.__setAttr(key, value);
|
|
3719
|
+
this.__layout.surfaceChanged || this.__layout.surfaceChange();
|
|
3720
|
+
}
|
|
3721
|
+
}));
|
|
3739
3722
|
}
|
|
3740
3723
|
function opacityType(defaultValue) {
|
|
3741
|
-
return (
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
});
|
|
3748
|
-
};
|
|
3724
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3725
|
+
set(value) {
|
|
3726
|
+
this.__setAttr(key, value);
|
|
3727
|
+
this.__layout.opacityChanged || this.__layout.opacityChange();
|
|
3728
|
+
}
|
|
3729
|
+
}));
|
|
3749
3730
|
}
|
|
3750
3731
|
function sortType(defaultValue) {
|
|
3751
|
-
return (
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
});
|
|
3759
|
-
};
|
|
3732
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3733
|
+
set(value) {
|
|
3734
|
+
this.__setAttr(key, value);
|
|
3735
|
+
this.__layout.surfaceChanged || this.__layout.surfaceChange();
|
|
3736
|
+
this.waitParent(() => { this.parent.__layout.childrenSortChange(); });
|
|
3737
|
+
}
|
|
3738
|
+
}));
|
|
3760
3739
|
}
|
|
3761
3740
|
function maskType(defaultValue) {
|
|
3762
|
-
return (
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
});
|
|
3770
|
-
};
|
|
3741
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3742
|
+
set(value) {
|
|
3743
|
+
this.__setAttr(key, value);
|
|
3744
|
+
this.__layout.boxChanged || this.__layout.boxChange();
|
|
3745
|
+
this.waitParent(() => { this.parent.__updateMask(value); });
|
|
3746
|
+
}
|
|
3747
|
+
}));
|
|
3771
3748
|
}
|
|
3772
3749
|
function eraserType(defaultValue) {
|
|
3773
|
-
return (
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
});
|
|
3780
|
-
};
|
|
3750
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3751
|
+
set(value) {
|
|
3752
|
+
this.__setAttr(key, value);
|
|
3753
|
+
this.waitParent(() => { this.parent.__updateEraser(value); });
|
|
3754
|
+
}
|
|
3755
|
+
}));
|
|
3781
3756
|
}
|
|
3782
3757
|
function hitType(defaultValue) {
|
|
3783
|
-
return (
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
this.__layout.surfaceChanged || this.__layout.surfaceChange();
|
|
3789
|
-
}
|
|
3790
|
-
if (this.leafer)
|
|
3791
|
-
this.leafer.updateCursor();
|
|
3758
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3759
|
+
set(value) {
|
|
3760
|
+
this.__setAttr(key, value);
|
|
3761
|
+
if (Debug.showHitView) {
|
|
3762
|
+
this.__layout.surfaceChanged || this.__layout.surfaceChange();
|
|
3792
3763
|
}
|
|
3793
|
-
|
|
3794
|
-
|
|
3764
|
+
if (this.leafer)
|
|
3765
|
+
this.leafer.updateCursor();
|
|
3766
|
+
}
|
|
3767
|
+
}));
|
|
3795
3768
|
}
|
|
3796
3769
|
function cursorType(defaultValue) {
|
|
3797
|
-
return (
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
});
|
|
3805
|
-
};
|
|
3770
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3771
|
+
set(value) {
|
|
3772
|
+
this.__setAttr(key, value);
|
|
3773
|
+
if (this.leafer)
|
|
3774
|
+
this.leafer.updateCursor();
|
|
3775
|
+
}
|
|
3776
|
+
}));
|
|
3806
3777
|
}
|
|
3807
3778
|
function dataProcessor(processor) {
|
|
3808
3779
|
return (target, _key) => {
|
|
@@ -3865,7 +3836,7 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
3865
3836
|
Object.defineProperty(data, key, property);
|
|
3866
3837
|
}
|
|
3867
3838
|
|
|
3868
|
-
const debug$
|
|
3839
|
+
const debug$6 = new Debug('rewrite');
|
|
3869
3840
|
const list = [];
|
|
3870
3841
|
const excludeNames = ['destroy', 'constructor'];
|
|
3871
3842
|
function rewrite(method) {
|
|
@@ -3882,7 +3853,7 @@ function doRewrite(error) {
|
|
|
3882
3853
|
if (list.length) {
|
|
3883
3854
|
list.forEach(item => {
|
|
3884
3855
|
if (error)
|
|
3885
|
-
debug$
|
|
3856
|
+
debug$6.error(item.name, '需在Class上装饰@rewriteAble()');
|
|
3886
3857
|
item.run();
|
|
3887
3858
|
});
|
|
3888
3859
|
list.length = 0;
|
|
@@ -3918,7 +3889,7 @@ function registerUIEvent() {
|
|
|
3918
3889
|
};
|
|
3919
3890
|
}
|
|
3920
3891
|
|
|
3921
|
-
const { copy: copy$
|
|
3892
|
+
const { copy: copy$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3922
3893
|
const matrix = {};
|
|
3923
3894
|
const LeafHelper = {
|
|
3924
3895
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -3997,7 +3968,7 @@ const LeafHelper = {
|
|
|
3997
3968
|
L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
3998
3969
|
},
|
|
3999
3970
|
zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
|
|
4000
|
-
copy$
|
|
3971
|
+
copy$6(matrix, t.__localMatrix);
|
|
4001
3972
|
scaleOfOuter$3(matrix, origin, scaleX, scaleY);
|
|
4002
3973
|
moveByMatrix(t, matrix);
|
|
4003
3974
|
t.scaleResize(scaleX, scaleY, resize !== true);
|
|
@@ -4006,7 +3977,7 @@ const LeafHelper = {
|
|
|
4006
3977
|
L.rotateOfLocal(t, getTempLocal(t, origin), angle);
|
|
4007
3978
|
},
|
|
4008
3979
|
rotateOfLocal(t, origin, angle) {
|
|
4009
|
-
copy$
|
|
3980
|
+
copy$6(matrix, t.__localMatrix);
|
|
4010
3981
|
rotateOfOuter$3(matrix, origin, angle);
|
|
4011
3982
|
moveByMatrix(t, matrix);
|
|
4012
3983
|
t.rotation = MathHelper.formatRotation(t.rotation + angle);
|
|
@@ -4015,19 +3986,19 @@ const LeafHelper = {
|
|
|
4015
3986
|
L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
|
|
4016
3987
|
},
|
|
4017
3988
|
skewOfLocal(t, origin, skewX, skewY = 0, resize) {
|
|
4018
|
-
copy$
|
|
3989
|
+
copy$6(matrix, t.__localMatrix);
|
|
4019
3990
|
skewOfOuter(matrix, origin, skewX, skewY);
|
|
4020
3991
|
L.setTransform(t, matrix, resize);
|
|
4021
3992
|
},
|
|
4022
3993
|
transformWorld(t, transform, resize) {
|
|
4023
|
-
copy$
|
|
3994
|
+
copy$6(matrix, t.worldTransform);
|
|
4024
3995
|
multiplyParent$2(matrix, transform);
|
|
4025
3996
|
if (t.parent)
|
|
4026
3997
|
divideParent(matrix, t.parent.worldTransform);
|
|
4027
3998
|
L.setTransform(t, matrix, resize);
|
|
4028
3999
|
},
|
|
4029
4000
|
transform(t, transform, resize) {
|
|
4030
|
-
copy$
|
|
4001
|
+
copy$6(matrix, t.localTransform);
|
|
4031
4002
|
multiplyParent$2(matrix, transform);
|
|
4032
4003
|
L.setTransform(t, matrix, resize);
|
|
4033
4004
|
},
|
|
@@ -4041,7 +4012,7 @@ const LeafHelper = {
|
|
|
4041
4012
|
t.set(layout);
|
|
4042
4013
|
},
|
|
4043
4014
|
getRelativeWorld(t, relative, temp) {
|
|
4044
|
-
copy$
|
|
4015
|
+
copy$6(matrix, t.worldTransform);
|
|
4045
4016
|
divideParent(matrix, relative.worldTransform);
|
|
4046
4017
|
return temp ? matrix : Object.assign({}, matrix);
|
|
4047
4018
|
},
|
|
@@ -4183,7 +4154,7 @@ const { pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack, updateBoun
|
|
|
4183
4154
|
|
|
4184
4155
|
const WaitHelper = {
|
|
4185
4156
|
run(wait) {
|
|
4186
|
-
if (wait.length) {
|
|
4157
|
+
if (wait && wait.length) {
|
|
4187
4158
|
const len = wait.length;
|
|
4188
4159
|
for (let i = 0; i < len; i++) {
|
|
4189
4160
|
wait[i]();
|
|
@@ -4194,7 +4165,7 @@ const WaitHelper = {
|
|
|
4194
4165
|
};
|
|
4195
4166
|
|
|
4196
4167
|
const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
|
|
4197
|
-
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$
|
|
4168
|
+
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$5 } = BoundsHelper;
|
|
4198
4169
|
class LeafLayout {
|
|
4199
4170
|
get strokeBounds() { return this._strokeBounds || this.boxBounds; }
|
|
4200
4171
|
get renderBounds() { return this._renderBounds || this.boxBounds; }
|
|
@@ -4339,7 +4310,7 @@ class LeafLayout {
|
|
|
4339
4310
|
matrix = getRelativeWorld$1(leaf, relative, true);
|
|
4340
4311
|
}
|
|
4341
4312
|
const layoutBounds = MatrixHelper.getLayout(matrix);
|
|
4342
|
-
copy$
|
|
4313
|
+
copy$5(layoutBounds, bounds);
|
|
4343
4314
|
PointHelper.copy(layoutBounds, point);
|
|
4344
4315
|
if (unscale) {
|
|
4345
4316
|
const { scaleX, scaleY } = layoutBounds;
|
|
@@ -4733,10 +4704,16 @@ LeaferEvent.STOP = 'leafer.stop';
|
|
|
4733
4704
|
LeaferEvent.RESTART = 'leafer.restart';
|
|
4734
4705
|
LeaferEvent.END = 'leafer.end';
|
|
4735
4706
|
|
|
4707
|
+
const { isFinite } = Number;
|
|
4708
|
+
const debug$5 = Debug.get('setAttr');
|
|
4736
4709
|
const LeafDataProxy = {
|
|
4737
|
-
__setAttr(name, newValue) {
|
|
4710
|
+
__setAttr(name, newValue, checkFiniteNumber) {
|
|
4738
4711
|
if (this.leafer && this.leafer.created) {
|
|
4739
4712
|
const oldValue = this.__.__getInput(name);
|
|
4713
|
+
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
4714
|
+
debug$5.warn(this.innerName, name, newValue);
|
|
4715
|
+
newValue = undefined;
|
|
4716
|
+
}
|
|
4740
4717
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
4741
4718
|
this.__[name] = newValue;
|
|
4742
4719
|
if (this.__proxyData)
|
|
@@ -4751,12 +4728,17 @@ const LeafDataProxy = {
|
|
|
4751
4728
|
this.emitEvent(event);
|
|
4752
4729
|
}
|
|
4753
4730
|
this.leafer.emitEvent(event);
|
|
4731
|
+
return true;
|
|
4732
|
+
}
|
|
4733
|
+
else {
|
|
4734
|
+
return false;
|
|
4754
4735
|
}
|
|
4755
4736
|
}
|
|
4756
4737
|
else {
|
|
4757
4738
|
this.__[name] = newValue;
|
|
4758
4739
|
if (this.__proxyData)
|
|
4759
4740
|
this.setProxyAttr(name, newValue);
|
|
4741
|
+
return true;
|
|
4760
4742
|
}
|
|
4761
4743
|
},
|
|
4762
4744
|
__getAttr(name) {
|
|
@@ -4794,7 +4776,7 @@ const LeafMatrix = {
|
|
|
4794
4776
|
|
|
4795
4777
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2, hasParentAutoLayout } = LeafHelper;
|
|
4796
4778
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4797
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
4779
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4 } = BoundsHelper;
|
|
4798
4780
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4799
4781
|
const LeafBounds = {
|
|
4800
4782
|
__updateWorldBounds() {
|
|
@@ -4912,7 +4894,8 @@ const LeafBounds = {
|
|
|
4912
4894
|
copyAndSpread$1(this.__layout.strokeBounds, this.__layout.boxBounds, this.__layout.strokeSpread);
|
|
4913
4895
|
},
|
|
4914
4896
|
__updateRenderBounds() {
|
|
4915
|
-
|
|
4897
|
+
const { renderSpread, strokeBounds, renderBounds } = this.__layout;
|
|
4898
|
+
renderSpread > 0 ? copyAndSpread$1(renderBounds, strokeBounds, renderSpread) : copy$4(renderBounds, strokeBounds);
|
|
4916
4899
|
},
|
|
4917
4900
|
};
|
|
4918
4901
|
|
|
@@ -5098,7 +5081,7 @@ let Leaf = class Leaf {
|
|
|
5098
5081
|
toString() {
|
|
5099
5082
|
return JSON.stringify(this.toJSON());
|
|
5100
5083
|
}
|
|
5101
|
-
__setAttr(_attrName, _newValue) { }
|
|
5084
|
+
__setAttr(_attrName, _newValue) { return true; }
|
|
5102
5085
|
__getAttr(_attrName) { return undefined; }
|
|
5103
5086
|
setProxyAttr(_attrName, _newValue) { }
|
|
5104
5087
|
getProxyAttr(_attrName) { return undefined; }
|
|
@@ -5282,24 +5265,16 @@ let Leaf = class Leaf {
|
|
|
5282
5265
|
__scaleResize(_scaleX, _scaleY) { }
|
|
5283
5266
|
__hitWorld(_point) { return true; }
|
|
5284
5267
|
__hit(_local) { return true; }
|
|
5285
|
-
__hitFill(
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
}
|
|
5289
|
-
__hitStroke(inner, strokeWidth) {
|
|
5290
|
-
var _a;
|
|
5291
|
-
return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth);
|
|
5292
|
-
}
|
|
5293
|
-
__drawHitPath(canvas) {
|
|
5294
|
-
if (canvas)
|
|
5295
|
-
this.__drawRenderPath(canvas);
|
|
5296
|
-
}
|
|
5268
|
+
__hitFill(_inner) { return true; }
|
|
5269
|
+
__hitStroke(_inner, _strokeWidth) { return true; }
|
|
5270
|
+
__hitPixel(_inner) { return true; }
|
|
5271
|
+
__drawHitPath(_canvas) { }
|
|
5297
5272
|
__updateHitCanvas() { }
|
|
5298
5273
|
__render(_canvas, _options) { }
|
|
5299
5274
|
__drawFast(_canvas, _options) { }
|
|
5300
5275
|
__draw(_canvas, _options) { }
|
|
5301
5276
|
__clip(_canvas, _options) { }
|
|
5302
|
-
__renderShape(_canvas, _options) { }
|
|
5277
|
+
__renderShape(_canvas, _options, _ignoreFill, _ignoreStroke) { }
|
|
5303
5278
|
__updateWorldOpacity() { }
|
|
5304
5279
|
__updateChange() { }
|
|
5305
5280
|
__drawPath(_canvas) { }
|
|
@@ -5681,6 +5656,7 @@ function useCanvas(_canvasType, _power) {
|
|
|
5681
5656
|
},
|
|
5682
5657
|
canvasToBolb: (canvas, type, quality) => canvas.convertToBlob({ type: mineType(type), quality }),
|
|
5683
5658
|
canvasSaveAs: (_canvas, _filename, _quality) => new Promise((resolve) => resolve()),
|
|
5659
|
+
download(_url, _filename) { return undefined; },
|
|
5684
5660
|
loadImage(src) {
|
|
5685
5661
|
return new Promise((resolve, reject) => {
|
|
5686
5662
|
if (!src.startsWith('data:') && Platform.image.suffix)
|
|
@@ -5907,7 +5883,7 @@ class LayoutBlockData {
|
|
|
5907
5883
|
}
|
|
5908
5884
|
|
|
5909
5885
|
const { updateAllMatrix, updateAllChange } = LeafHelper;
|
|
5910
|
-
const debug$
|
|
5886
|
+
const debug$4 = Debug.get('Layouter');
|
|
5911
5887
|
class Layouter {
|
|
5912
5888
|
constructor(target, userConfig) {
|
|
5913
5889
|
this.totalTimes = 0;
|
|
@@ -5942,7 +5918,7 @@ class Layouter {
|
|
|
5942
5918
|
target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
|
|
5943
5919
|
}
|
|
5944
5920
|
catch (e) {
|
|
5945
|
-
debug$
|
|
5921
|
+
debug$4.error(e);
|
|
5946
5922
|
}
|
|
5947
5923
|
this.layoutedBlocks = null;
|
|
5948
5924
|
}
|
|
@@ -5956,9 +5932,9 @@ class Layouter {
|
|
|
5956
5932
|
}
|
|
5957
5933
|
layoutOnce() {
|
|
5958
5934
|
if (this.layouting)
|
|
5959
|
-
return debug$
|
|
5935
|
+
return debug$4.warn('layouting');
|
|
5960
5936
|
if (this.times > 3)
|
|
5961
|
-
return debug$
|
|
5937
|
+
return debug$4.warn('layout max times');
|
|
5962
5938
|
this.times++;
|
|
5963
5939
|
this.totalTimes++;
|
|
5964
5940
|
this.layouting = true;
|
|
@@ -6062,7 +6038,7 @@ class Layouter {
|
|
|
6062
6038
|
}
|
|
6063
6039
|
}
|
|
6064
6040
|
|
|
6065
|
-
const debug$
|
|
6041
|
+
const debug$3 = Debug.get('Renderer');
|
|
6066
6042
|
class Renderer {
|
|
6067
6043
|
get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
|
|
6068
6044
|
constructor(target, canvas, userConfig) {
|
|
@@ -6100,7 +6076,7 @@ class Renderer {
|
|
|
6100
6076
|
const { target } = this;
|
|
6101
6077
|
this.times = 0;
|
|
6102
6078
|
this.totalBounds = new Bounds();
|
|
6103
|
-
debug$
|
|
6079
|
+
debug$3.log(target.innerName, '--->');
|
|
6104
6080
|
try {
|
|
6105
6081
|
this.emitRender(RenderEvent.START);
|
|
6106
6082
|
this.renderOnce(callback);
|
|
@@ -6109,9 +6085,9 @@ class Renderer {
|
|
|
6109
6085
|
}
|
|
6110
6086
|
catch (e) {
|
|
6111
6087
|
this.rendering = false;
|
|
6112
|
-
debug$
|
|
6088
|
+
debug$3.error(e);
|
|
6113
6089
|
}
|
|
6114
|
-
debug$
|
|
6090
|
+
debug$3.log('-------------|');
|
|
6115
6091
|
}
|
|
6116
6092
|
renderAgain() {
|
|
6117
6093
|
if (this.rendering) {
|
|
@@ -6123,9 +6099,9 @@ class Renderer {
|
|
|
6123
6099
|
}
|
|
6124
6100
|
renderOnce(callback) {
|
|
6125
6101
|
if (this.rendering)
|
|
6126
|
-
return debug$
|
|
6102
|
+
return debug$3.warn('rendering');
|
|
6127
6103
|
if (this.times > 3)
|
|
6128
|
-
return debug$
|
|
6104
|
+
return debug$3.warn('render max times');
|
|
6129
6105
|
this.times++;
|
|
6130
6106
|
this.totalTimes++;
|
|
6131
6107
|
this.rendering = true;
|
|
@@ -6162,7 +6138,7 @@ class Renderer {
|
|
|
6162
6138
|
partRender() {
|
|
6163
6139
|
const { canvas, updateBlocks: list } = this;
|
|
6164
6140
|
if (!list)
|
|
6165
|
-
return debug$
|
|
6141
|
+
return debug$3.warn('PartRender: need update attr');
|
|
6166
6142
|
this.mergeBlocks();
|
|
6167
6143
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6168
6144
|
this.clipRender(block); });
|
|
@@ -6262,7 +6238,7 @@ class Renderer {
|
|
|
6262
6238
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
6263
6239
|
if (empty) {
|
|
6264
6240
|
if (!leaf.isLeafer)
|
|
6265
|
-
debug$
|
|
6241
|
+
debug$3.tip(leaf.innerName, ': empty');
|
|
6266
6242
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
6267
6243
|
}
|
|
6268
6244
|
return empty;
|
|
@@ -6314,51 +6290,42 @@ const Export = {};
|
|
|
6314
6290
|
const State = {};
|
|
6315
6291
|
|
|
6316
6292
|
function stateType(defaultValue) {
|
|
6317
|
-
return (
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
}
|
|
6325
|
-
});
|
|
6326
|
-
};
|
|
6293
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6294
|
+
set(value) {
|
|
6295
|
+
this.__setAttr(key, value);
|
|
6296
|
+
this.waitLeafer(() => { if (State.setStyle)
|
|
6297
|
+
State.setStyle(this, key + 'Style', value); });
|
|
6298
|
+
}
|
|
6299
|
+
}));
|
|
6327
6300
|
}
|
|
6328
6301
|
function arrowType(defaultValue) {
|
|
6329
|
-
return (
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
});
|
|
6338
|
-
};
|
|
6302
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6303
|
+
set(value) {
|
|
6304
|
+
this.__setAttr(key, value);
|
|
6305
|
+
const data = this.__;
|
|
6306
|
+
data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
|
|
6307
|
+
doStrokeType(this);
|
|
6308
|
+
}
|
|
6309
|
+
}));
|
|
6339
6310
|
}
|
|
6340
6311
|
function effectType(defaultValue) {
|
|
6341
|
-
return (
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
});
|
|
6350
|
-
};
|
|
6312
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6313
|
+
set(value) {
|
|
6314
|
+
this.__setAttr(key, value);
|
|
6315
|
+
if (value)
|
|
6316
|
+
this.__.__useEffect = true;
|
|
6317
|
+
this.__layout.renderChanged || this.__layout.renderChange();
|
|
6318
|
+
}
|
|
6319
|
+
}));
|
|
6351
6320
|
}
|
|
6352
6321
|
function resizeType(defaultValue) {
|
|
6353
|
-
return (
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
});
|
|
6361
|
-
};
|
|
6322
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6323
|
+
set(value) {
|
|
6324
|
+
this.__setAttr(key, value);
|
|
6325
|
+
this.__layout.boxChanged || this.__layout.boxChange();
|
|
6326
|
+
this.__updateSize();
|
|
6327
|
+
}
|
|
6328
|
+
}));
|
|
6362
6329
|
}
|
|
6363
6330
|
function zoomLayerType() {
|
|
6364
6331
|
return (target, key) => {
|
|
@@ -6373,12 +6340,13 @@ function zoomLayerType() {
|
|
|
6373
6340
|
|
|
6374
6341
|
const { parse } = PathConvert;
|
|
6375
6342
|
const emptyPaint = {};
|
|
6376
|
-
const debug$
|
|
6343
|
+
const debug$2 = Debug.get('UIData');
|
|
6377
6344
|
class UIData extends LeafData {
|
|
6378
6345
|
get __strokeWidth() {
|
|
6379
6346
|
const { strokeWidth, strokeWidthFixed } = this;
|
|
6380
6347
|
if (strokeWidthFixed) {
|
|
6381
|
-
|
|
6348
|
+
const ui = this.__leaf;
|
|
6349
|
+
let { scaleX } = ui.__nowWorld || ui.__world;
|
|
6382
6350
|
if (scaleX < 0)
|
|
6383
6351
|
scaleX = -scaleX;
|
|
6384
6352
|
return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
|
|
@@ -6400,7 +6368,7 @@ class UIData extends LeafData {
|
|
|
6400
6368
|
if (value < 0) {
|
|
6401
6369
|
this._width = -value;
|
|
6402
6370
|
this.__leaf.scaleX *= -1;
|
|
6403
|
-
debug$
|
|
6371
|
+
debug$2.warn('width < 0, instead -scaleX ', this);
|
|
6404
6372
|
}
|
|
6405
6373
|
else {
|
|
6406
6374
|
this._width = value;
|
|
@@ -6410,7 +6378,7 @@ class UIData extends LeafData {
|
|
|
6410
6378
|
if (value < 0) {
|
|
6411
6379
|
this._height = -value;
|
|
6412
6380
|
this.__leaf.scaleY *= -1;
|
|
6413
|
-
debug$
|
|
6381
|
+
debug$2.warn('height < 0, instead -scaleY', this);
|
|
6414
6382
|
}
|
|
6415
6383
|
else {
|
|
6416
6384
|
this._height = value;
|
|
@@ -6697,14 +6665,14 @@ const UIRender = {
|
|
|
6697
6665
|
}
|
|
6698
6666
|
}
|
|
6699
6667
|
},
|
|
6700
|
-
__renderShape(canvas, options) {
|
|
6668
|
+
__renderShape(canvas, options, ignoreFill, ignoreStroke) {
|
|
6701
6669
|
if (this.__worldOpacity) {
|
|
6702
6670
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
6703
6671
|
const { fill, stroke } = this.__;
|
|
6704
6672
|
this.__drawRenderPath(canvas);
|
|
6705
|
-
if (fill)
|
|
6673
|
+
if (fill && !ignoreFill)
|
|
6706
6674
|
this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
6707
|
-
if (stroke)
|
|
6675
|
+
if (stroke && !ignoreStroke)
|
|
6708
6676
|
this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
6709
6677
|
}
|
|
6710
6678
|
}
|
|
@@ -6802,10 +6770,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
6802
6770
|
__onUpdateSize() {
|
|
6803
6771
|
if (this.__.__input) {
|
|
6804
6772
|
const data = this.__;
|
|
6805
|
-
data.__needComputePaint = true;
|
|
6806
|
-
if (data.lazy && this.leafer && !this.leafer.canvas.bounds.hit(this.__world))
|
|
6807
|
-
return;
|
|
6808
|
-
data.__computePaint();
|
|
6773
|
+
(data.lazy && this.leafer && this.leafer.created && !this.leafer.lazyBounds.hit(this.__world)) ? data.__needComputePaint = true : data.__computePaint();
|
|
6809
6774
|
}
|
|
6810
6775
|
}
|
|
6811
6776
|
__updateRenderPath() {
|
|
@@ -6907,31 +6872,31 @@ __decorate([
|
|
|
6907
6872
|
eraserType(false)
|
|
6908
6873
|
], UI.prototype, "eraser", void 0);
|
|
6909
6874
|
__decorate([
|
|
6910
|
-
positionType(0)
|
|
6875
|
+
positionType(0, true)
|
|
6911
6876
|
], UI.prototype, "x", void 0);
|
|
6912
6877
|
__decorate([
|
|
6913
|
-
positionType(0)
|
|
6878
|
+
positionType(0, true)
|
|
6914
6879
|
], UI.prototype, "y", void 0);
|
|
6915
6880
|
__decorate([
|
|
6916
|
-
boundsType(100)
|
|
6881
|
+
boundsType(100, true)
|
|
6917
6882
|
], UI.prototype, "width", void 0);
|
|
6918
6883
|
__decorate([
|
|
6919
|
-
boundsType(100)
|
|
6884
|
+
boundsType(100, true)
|
|
6920
6885
|
], UI.prototype, "height", void 0);
|
|
6921
6886
|
__decorate([
|
|
6922
|
-
scaleType(1)
|
|
6887
|
+
scaleType(1, true)
|
|
6923
6888
|
], UI.prototype, "scaleX", void 0);
|
|
6924
6889
|
__decorate([
|
|
6925
|
-
scaleType(1)
|
|
6890
|
+
scaleType(1, true)
|
|
6926
6891
|
], UI.prototype, "scaleY", void 0);
|
|
6927
6892
|
__decorate([
|
|
6928
|
-
rotationType(0)
|
|
6893
|
+
rotationType(0, true)
|
|
6929
6894
|
], UI.prototype, "rotation", void 0);
|
|
6930
6895
|
__decorate([
|
|
6931
|
-
rotationType(0)
|
|
6896
|
+
rotationType(0, true)
|
|
6932
6897
|
], UI.prototype, "skewX", void 0);
|
|
6933
6898
|
__decorate([
|
|
6934
|
-
rotationType(0)
|
|
6899
|
+
rotationType(0, true)
|
|
6935
6900
|
], UI.prototype, "skewY", void 0);
|
|
6936
6901
|
__decorate([
|
|
6937
6902
|
autoLayoutType()
|
|
@@ -6945,6 +6910,9 @@ __decorate([
|
|
|
6945
6910
|
__decorate([
|
|
6946
6911
|
dataType('size')
|
|
6947
6912
|
], UI.prototype, "editSize", void 0);
|
|
6913
|
+
__decorate([
|
|
6914
|
+
dataType()
|
|
6915
|
+
], UI.prototype, "editorStyle", void 0);
|
|
6948
6916
|
__decorate([
|
|
6949
6917
|
hitType(true)
|
|
6950
6918
|
], UI.prototype, "hittable", void 0);
|
|
@@ -7011,6 +6979,9 @@ __decorate([
|
|
|
7011
6979
|
__decorate([
|
|
7012
6980
|
pathType()
|
|
7013
6981
|
], UI.prototype, "windingRule", void 0);
|
|
6982
|
+
__decorate([
|
|
6983
|
+
pathType(true)
|
|
6984
|
+
], UI.prototype, "closed", void 0);
|
|
7014
6985
|
__decorate([
|
|
7015
6986
|
arrowType('none')
|
|
7016
6987
|
], UI.prototype, "startArrow", void 0);
|
|
@@ -7130,14 +7101,17 @@ Group = __decorate([
|
|
|
7130
7101
|
registerUI()
|
|
7131
7102
|
], Group);
|
|
7132
7103
|
|
|
7133
|
-
|
|
7134
|
-
|
|
7104
|
+
var Leafer_1;
|
|
7105
|
+
const debug$1 = Debug.get('Leafer');
|
|
7106
|
+
let Leafer = Leafer_1 = class Leafer extends Group {
|
|
7107
|
+
static get version() { return '1.0.0-rc.20'; }
|
|
7135
7108
|
get __tag() { return 'Leafer'; }
|
|
7136
7109
|
get isApp() { return false; }
|
|
7137
7110
|
get app() { return this.parent || this; }
|
|
7138
7111
|
get isLeafer() { return true; }
|
|
7139
7112
|
get imageReady() { return this.viewReady && ImageManager.isComplete; }
|
|
7140
7113
|
get layoutLocked() { return !this.layouter.running; }
|
|
7114
|
+
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
7141
7115
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
7142
7116
|
constructor(userConfig, data) {
|
|
7143
7117
|
super(data);
|
|
@@ -7146,6 +7120,7 @@ let Leafer = class Leafer extends Group {
|
|
|
7146
7120
|
start: true,
|
|
7147
7121
|
hittable: true,
|
|
7148
7122
|
smooth: true,
|
|
7123
|
+
lazySpeard: 100,
|
|
7149
7124
|
zoom: {
|
|
7150
7125
|
min: 0.01,
|
|
7151
7126
|
max: 256
|
|
@@ -7166,6 +7141,7 @@ let Leafer = class Leafer extends Group {
|
|
|
7166
7141
|
this.userConfig = userConfig;
|
|
7167
7142
|
if (userConfig && (userConfig.view || userConfig.width))
|
|
7168
7143
|
this.init(userConfig);
|
|
7144
|
+
Leafer_1.list.add(this);
|
|
7169
7145
|
}
|
|
7170
7146
|
init(userConfig, parentApp) {
|
|
7171
7147
|
if (this.canvas)
|
|
@@ -7176,19 +7152,20 @@ let Leafer = class Leafer extends Group {
|
|
|
7176
7152
|
let start;
|
|
7177
7153
|
const { config } = this;
|
|
7178
7154
|
this.initType(config.type);
|
|
7179
|
-
this.canvas = Creator.canvas(config);
|
|
7180
|
-
this.__controllers.push(this.renderer = Creator.renderer(this,
|
|
7155
|
+
const canvas = this.canvas = Creator.canvas(config);
|
|
7156
|
+
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7181
7157
|
if (this.isApp)
|
|
7182
7158
|
this.__setApp();
|
|
7183
7159
|
this.__checkAutoLayout(config);
|
|
7184
|
-
this.
|
|
7160
|
+
this.updateLazyBounds();
|
|
7161
|
+
this.view = canvas.view;
|
|
7185
7162
|
if (parentApp) {
|
|
7186
7163
|
this.__bindApp(parentApp);
|
|
7187
7164
|
start = parentApp.running;
|
|
7188
7165
|
}
|
|
7189
7166
|
else {
|
|
7190
7167
|
this.selector = Creator.selector(this);
|
|
7191
|
-
this.interaction = Creator.interaction(this,
|
|
7168
|
+
this.interaction = Creator.interaction(this, canvas, this.selector, config);
|
|
7192
7169
|
if (this.interaction) {
|
|
7193
7170
|
this.__controllers.unshift(this.interaction);
|
|
7194
7171
|
this.hitCanvasManager = Creator.hitCanvasManager();
|
|
@@ -7198,23 +7175,17 @@ let Leafer = class Leafer extends Group {
|
|
|
7198
7175
|
}
|
|
7199
7176
|
this.hittable = config.hittable;
|
|
7200
7177
|
this.fill = config.fill;
|
|
7201
|
-
this.canvasManager.add(
|
|
7178
|
+
this.canvasManager.add(canvas);
|
|
7202
7179
|
this.__listenEvents();
|
|
7203
7180
|
if (start)
|
|
7204
7181
|
this.__startTimer = setTimeout(this.start.bind(this));
|
|
7182
|
+
WaitHelper.run(this.__initWait);
|
|
7205
7183
|
this.onInit();
|
|
7206
7184
|
}
|
|
7207
7185
|
onInit() { }
|
|
7208
7186
|
initType(_type) { }
|
|
7209
7187
|
set(data) {
|
|
7210
|
-
|
|
7211
|
-
setTimeout(() => {
|
|
7212
|
-
super.set(data);
|
|
7213
|
-
});
|
|
7214
|
-
}
|
|
7215
|
-
else {
|
|
7216
|
-
super.set(data);
|
|
7217
|
-
}
|
|
7188
|
+
this.waitInit(() => { super.set(data); });
|
|
7218
7189
|
}
|
|
7219
7190
|
start() {
|
|
7220
7191
|
clearTimeout(this.__startTimer);
|
|
@@ -7259,11 +7230,16 @@ let Leafer = class Leafer extends Group {
|
|
|
7259
7230
|
if (i)
|
|
7260
7231
|
cursor ? i.setCursor(cursor) : i.updateCursor();
|
|
7261
7232
|
}
|
|
7233
|
+
updateLazyBounds() {
|
|
7234
|
+
this.lazyBounds = this.canvas.bounds.clone().spread(this.config.lazySpeard);
|
|
7235
|
+
}
|
|
7262
7236
|
__doResize(size) {
|
|
7263
|
-
|
|
7237
|
+
const { canvas } = this;
|
|
7238
|
+
if (!canvas || canvas.isSameSize(size))
|
|
7264
7239
|
return;
|
|
7265
7240
|
const old = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
|
|
7266
|
-
|
|
7241
|
+
canvas.resize(size);
|
|
7242
|
+
this.updateLazyBounds();
|
|
7267
7243
|
this.__onResize(new ResizeEvent(size, old));
|
|
7268
7244
|
}
|
|
7269
7245
|
__onResize(event) {
|
|
@@ -7301,7 +7277,7 @@ let Leafer = class Leafer extends Group {
|
|
|
7301
7277
|
this.canvas.hittable = newValue;
|
|
7302
7278
|
}
|
|
7303
7279
|
}
|
|
7304
|
-
super.__setAttr(attrName, newValue);
|
|
7280
|
+
return super.__setAttr(attrName, newValue);
|
|
7305
7281
|
}
|
|
7306
7282
|
__getAttr(attrName) {
|
|
7307
7283
|
if (this.canvas && canvasSizeAttrs.includes(attrName))
|
|
@@ -7368,6 +7344,13 @@ let Leafer = class Leafer extends Group {
|
|
|
7368
7344
|
this.nextRender(() => this.interaction.updateCursor());
|
|
7369
7345
|
}
|
|
7370
7346
|
}
|
|
7347
|
+
waitInit(item, bind) {
|
|
7348
|
+
if (bind)
|
|
7349
|
+
item = item.bind(bind);
|
|
7350
|
+
if (!this.__initWait)
|
|
7351
|
+
this.__initWait = [];
|
|
7352
|
+
this.canvas ? item() : this.__initWait.push(item);
|
|
7353
|
+
}
|
|
7371
7354
|
waitReady(item, bind) {
|
|
7372
7355
|
if (bind)
|
|
7373
7356
|
item = item.bind(bind);
|
|
@@ -7407,14 +7390,8 @@ let Leafer = class Leafer extends Group {
|
|
|
7407
7390
|
}
|
|
7408
7391
|
}
|
|
7409
7392
|
zoom(_zoomType, _padding, _fixedScale) { return undefined; }
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
if (absScale < min)
|
|
7413
|
-
changeScale = min / scaleX;
|
|
7414
|
-
else if (absScale > max)
|
|
7415
|
-
changeScale = max / scaleX;
|
|
7416
|
-
return changeScale;
|
|
7417
|
-
}
|
|
7393
|
+
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
7394
|
+
getValidScale(changeScale) { return changeScale; }
|
|
7418
7395
|
__checkUpdateLayout() {
|
|
7419
7396
|
this.__layout.update();
|
|
7420
7397
|
}
|
|
@@ -7433,9 +7410,10 @@ let Leafer = class Leafer extends Group {
|
|
|
7433
7410
|
this.off_(this.__eventIds);
|
|
7434
7411
|
this.__eventIds.length = 0;
|
|
7435
7412
|
}
|
|
7436
|
-
destroy() {
|
|
7437
|
-
|
|
7413
|
+
destroy(sync) {
|
|
7414
|
+
const doDestory = () => {
|
|
7438
7415
|
if (!this.destroyed) {
|
|
7416
|
+
Leafer_1.list.remove(this);
|
|
7439
7417
|
try {
|
|
7440
7418
|
this.stop();
|
|
7441
7419
|
this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
|
|
@@ -7460,19 +7438,21 @@ let Leafer = class Leafer extends Group {
|
|
|
7460
7438
|
setTimeout(() => { ImageManager.clearRecycled(); }, 100);
|
|
7461
7439
|
}
|
|
7462
7440
|
catch (e) {
|
|
7463
|
-
debug.error(e);
|
|
7441
|
+
debug$1.error(e);
|
|
7464
7442
|
}
|
|
7465
7443
|
}
|
|
7466
|
-
}
|
|
7444
|
+
};
|
|
7445
|
+
sync ? doDestory() : setTimeout(doDestory);
|
|
7467
7446
|
}
|
|
7468
7447
|
};
|
|
7448
|
+
Leafer.list = new LeafList();
|
|
7469
7449
|
__decorate([
|
|
7470
7450
|
dataProcessor(LeaferData)
|
|
7471
7451
|
], Leafer.prototype, "__", void 0);
|
|
7472
7452
|
__decorate([
|
|
7473
7453
|
boundsType()
|
|
7474
7454
|
], Leafer.prototype, "pixelRatio", void 0);
|
|
7475
|
-
Leafer = __decorate([
|
|
7455
|
+
Leafer = Leafer_1 = __decorate([
|
|
7476
7456
|
registerUI()
|
|
7477
7457
|
], Leafer);
|
|
7478
7458
|
|
|
@@ -7505,11 +7485,9 @@ let Box = class Box extends Group {
|
|
|
7505
7485
|
__updateStrokeSpread() { return 0; }
|
|
7506
7486
|
__updateRectRenderSpread() { return 0; }
|
|
7507
7487
|
__updateRenderSpread() {
|
|
7508
|
-
|
|
7509
|
-
this.__.__drawAfterFill = this.__.overflow === 'hide';
|
|
7510
|
-
|
|
7511
|
-
width = this.__.__drawAfterFill ? 0 : 1;
|
|
7512
|
-
return width;
|
|
7488
|
+
const width = this.__updateRectRenderSpread();
|
|
7489
|
+
const hide = this.__.__drawAfterFill = this.__.overflow === 'hide';
|
|
7490
|
+
return (width || hide) ? width : -1;
|
|
7513
7491
|
}
|
|
7514
7492
|
__updateRectBoxBounds() { }
|
|
7515
7493
|
__updateBoxBounds() {
|
|
@@ -7703,7 +7681,7 @@ let Line = class Line extends UI {
|
|
|
7703
7681
|
__updatePath() {
|
|
7704
7682
|
const path = this.__.path = [];
|
|
7705
7683
|
if (this.__.points) {
|
|
7706
|
-
drawPoints$1(path, this.__.points,
|
|
7684
|
+
drawPoints$1(path, this.__.points, this.__.closed);
|
|
7707
7685
|
}
|
|
7708
7686
|
else {
|
|
7709
7687
|
moveTo$2(path, 0, 0);
|
|
@@ -7713,7 +7691,7 @@ let Line = class Line extends UI {
|
|
|
7713
7691
|
__updateRenderPath() {
|
|
7714
7692
|
const data = this.__;
|
|
7715
7693
|
if (!this.pathInputed && data.points && data.curve) {
|
|
7716
|
-
drawPoints$1(data.__pathForRender = [], data.points, data.curve,
|
|
7694
|
+
drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
|
|
7717
7695
|
if (data.__useArrow)
|
|
7718
7696
|
PathArrow.addArrows(this, false);
|
|
7719
7697
|
}
|
|
@@ -7745,6 +7723,9 @@ __decorate([
|
|
|
7745
7723
|
__decorate([
|
|
7746
7724
|
pathType(0)
|
|
7747
7725
|
], Line.prototype, "curve", void 0);
|
|
7726
|
+
__decorate([
|
|
7727
|
+
pathType(false)
|
|
7728
|
+
], Line.prototype, "closed", void 0);
|
|
7748
7729
|
Line = __decorate([
|
|
7749
7730
|
registerUI()
|
|
7750
7731
|
], Line);
|
|
@@ -7756,7 +7737,6 @@ let Polygon = class Polygon extends UI {
|
|
|
7756
7737
|
get __tag() { return 'Polygon'; }
|
|
7757
7738
|
constructor(data) {
|
|
7758
7739
|
super(data);
|
|
7759
|
-
this.pathClosed = true;
|
|
7760
7740
|
}
|
|
7761
7741
|
__updatePath() {
|
|
7762
7742
|
const path = this.__.path = [];
|
|
@@ -7926,6 +7906,9 @@ __decorate([
|
|
|
7926
7906
|
__decorate([
|
|
7927
7907
|
resizeType(true)
|
|
7928
7908
|
], Canvas.prototype, "smooth", void 0);
|
|
7909
|
+
__decorate([
|
|
7910
|
+
resizeType()
|
|
7911
|
+
], Canvas.prototype, "contextSettings", void 0);
|
|
7929
7912
|
__decorate([
|
|
7930
7913
|
hitType('all')
|
|
7931
7914
|
], Canvas.prototype, "hitFill", void 0);
|
|
@@ -8002,6 +7985,8 @@ let Text = class Text extends UI {
|
|
|
8002
7985
|
else {
|
|
8003
7986
|
super.__updateBoxBounds();
|
|
8004
7987
|
}
|
|
7988
|
+
if (italic)
|
|
7989
|
+
b.width += fontSize * 0.16;
|
|
8005
7990
|
const contentBounds = includes(b, bounds) ? b : bounds;
|
|
8006
7991
|
if (contentBounds !== layout.contentBounds) {
|
|
8007
7992
|
layout.contentBounds = contentBounds;
|
|
@@ -8139,6 +8124,7 @@ let Pen = class Pen extends Group {
|
|
|
8139
8124
|
drawEllipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) { return this; }
|
|
8140
8125
|
drawArc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) { return this; }
|
|
8141
8126
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8127
|
+
clearPath() { return this; }
|
|
8142
8128
|
paint() {
|
|
8143
8129
|
this.pathElement.forceUpdate('path');
|
|
8144
8130
|
}
|
|
@@ -8150,7 +8136,7 @@ __decorate([
|
|
|
8150
8136
|
penPathType()
|
|
8151
8137
|
], Pen.prototype, "path", void 0);
|
|
8152
8138
|
Pen = __decorate([
|
|
8153
|
-
useModule(PathCreator, ['beginPath', 'path']),
|
|
8139
|
+
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8154
8140
|
registerUI()
|
|
8155
8141
|
], Pen);
|
|
8156
8142
|
function penPathType() {
|
|
@@ -8161,6 +8147,8 @@ function penPathType() {
|
|
|
8161
8147
|
};
|
|
8162
8148
|
}
|
|
8163
8149
|
|
|
8150
|
+
const version = "1.0.0-rc.20";
|
|
8151
|
+
|
|
8164
8152
|
function fillText(ui, canvas) {
|
|
8165
8153
|
let row;
|
|
8166
8154
|
const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
|
|
@@ -8522,8 +8510,11 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
|
|
|
8522
8510
|
}
|
|
8523
8511
|
|
|
8524
8512
|
const { get: get$3, translate } = MatrixHelper;
|
|
8513
|
+
const tempBox = new Bounds();
|
|
8525
8514
|
function createData(leafPaint, image, paint, box) {
|
|
8526
8515
|
let { width, height } = image;
|
|
8516
|
+
if (paint.padding)
|
|
8517
|
+
box = tempBox.set(box).shrink(paint.padding);
|
|
8527
8518
|
const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
|
|
8528
8519
|
const sameBox = box.width === width && box.height === height;
|
|
8529
8520
|
if (blendMode)
|
|
@@ -8607,8 +8598,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
8607
8598
|
leafPaint.loadId = image.load(() => {
|
|
8608
8599
|
ignoreRender(ui, false);
|
|
8609
8600
|
if (!ui.destroyed) {
|
|
8610
|
-
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds))
|
|
8601
|
+
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
8602
|
+
if (image.hasOpacityPixel)
|
|
8603
|
+
ui.__layout.hitCanvasChanged = true;
|
|
8611
8604
|
ui.forceUpdate('surface');
|
|
8605
|
+
}
|
|
8612
8606
|
onLoadSuccess(ui, event);
|
|
8613
8607
|
}
|
|
8614
8608
|
leafPaint.loadId = null;
|
|
@@ -8662,7 +8656,7 @@ function ignoreRender(ui, value) {
|
|
|
8662
8656
|
const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
|
|
8663
8657
|
const { ceil, abs: abs$1 } = Math;
|
|
8664
8658
|
function createPattern(ui, paint, pixelRatio) {
|
|
8665
|
-
let { scaleX, scaleY } = ui.__nowWorld;
|
|
8659
|
+
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
8666
8660
|
const id = scaleX + '-' + scaleY;
|
|
8667
8661
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
8668
8662
|
scaleX = abs$1(scaleX);
|
|
@@ -8724,7 +8718,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
8724
8718
|
|
|
8725
8719
|
const { abs } = Math;
|
|
8726
8720
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
8727
|
-
const { scaleX, scaleY } = ui.__nowWorld;
|
|
8721
|
+
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
8728
8722
|
if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
|
|
8729
8723
|
return false;
|
|
8730
8724
|
}
|
|
@@ -9629,7 +9623,7 @@ const ExportModule = {
|
|
|
9629
9623
|
const scale = options.scale || 1;
|
|
9630
9624
|
const pixelRatio = options.pixelRatio || 1;
|
|
9631
9625
|
const screenshot = options.screenshot || leaf.isApp;
|
|
9632
|
-
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill :
|
|
9626
|
+
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
9633
9627
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
9634
9628
|
if (screenshot) {
|
|
9635
9629
|
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
@@ -9640,10 +9634,10 @@ const ExportModule = {
|
|
|
9640
9634
|
scaleY = worldTransform.scaleY;
|
|
9641
9635
|
switch (relative) {
|
|
9642
9636
|
case 'inner':
|
|
9643
|
-
matrix.set(worldTransform)
|
|
9637
|
+
matrix.set(worldTransform);
|
|
9644
9638
|
break;
|
|
9645
9639
|
case 'local':
|
|
9646
|
-
matrix.set(worldTransform).divide(leaf.localTransform)
|
|
9640
|
+
matrix.set(worldTransform).divide(leaf.localTransform);
|
|
9647
9641
|
scaleX /= leaf.scaleX;
|
|
9648
9642
|
scaleY /= leaf.scaleY;
|
|
9649
9643
|
break;
|
|
@@ -9654,7 +9648,7 @@ const ExportModule = {
|
|
|
9654
9648
|
case 'page':
|
|
9655
9649
|
relative = leaf.leafer;
|
|
9656
9650
|
default:
|
|
9657
|
-
matrix.set(worldTransform).divide(leaf.getTransform(relative))
|
|
9651
|
+
matrix.set(worldTransform).divide(leaf.getTransform(relative));
|
|
9658
9652
|
const l = relative.worldTransform;
|
|
9659
9653
|
scaleX /= scaleX / l.scaleX;
|
|
9660
9654
|
scaleY /= scaleY / l.scaleY;
|
|
@@ -9663,7 +9657,7 @@ const ExportModule = {
|
|
|
9663
9657
|
}
|
|
9664
9658
|
const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
|
|
9665
9659
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
|
|
9666
|
-
const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
9660
|
+
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
9667
9661
|
if (slice) {
|
|
9668
9662
|
leaf = leafer;
|
|
9669
9663
|
renderOptions.bounds = canvas.bounds;
|
|
@@ -9709,6 +9703,44 @@ function addTask(task) {
|
|
|
9709
9703
|
});
|
|
9710
9704
|
}
|
|
9711
9705
|
|
|
9706
|
+
const canvas = LeaferCanvasBase.prototype;
|
|
9707
|
+
const debug = Debug.get('@leafer-ui/export');
|
|
9708
|
+
canvas.export = function (filename, options) {
|
|
9709
|
+
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
9710
|
+
if (filename.includes('.')) {
|
|
9711
|
+
return this.saveAs(filename, quality);
|
|
9712
|
+
}
|
|
9713
|
+
else if (blob) {
|
|
9714
|
+
return this.toBlob(filename, quality);
|
|
9715
|
+
}
|
|
9716
|
+
else {
|
|
9717
|
+
return this.toDataURL(filename, quality);
|
|
9718
|
+
}
|
|
9719
|
+
};
|
|
9720
|
+
canvas.toBlob = function (type, quality) {
|
|
9721
|
+
return new Promise((resolve) => {
|
|
9722
|
+
Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
9723
|
+
resolve(blob);
|
|
9724
|
+
}).catch((e) => {
|
|
9725
|
+
debug.error(e);
|
|
9726
|
+
resolve(null);
|
|
9727
|
+
});
|
|
9728
|
+
});
|
|
9729
|
+
};
|
|
9730
|
+
canvas.toDataURL = function (type, quality) {
|
|
9731
|
+
return Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
9732
|
+
};
|
|
9733
|
+
canvas.saveAs = function (filename, quality) {
|
|
9734
|
+
return new Promise((resolve) => {
|
|
9735
|
+
Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
9736
|
+
resolve(true);
|
|
9737
|
+
}).catch((e) => {
|
|
9738
|
+
debug.error(e);
|
|
9739
|
+
resolve(false);
|
|
9740
|
+
});
|
|
9741
|
+
});
|
|
9742
|
+
};
|
|
9743
|
+
|
|
9712
9744
|
Object.assign(TextConvert, TextConvertModule);
|
|
9713
9745
|
Object.assign(ColorConvert, ColorConvertModule);
|
|
9714
9746
|
Object.assign(Paint, PaintModule);
|
|
@@ -9719,4 +9751,4 @@ Object.assign(Export, ExportModule);
|
|
|
9719
9751
|
|
|
9720
9752
|
useCanvas();
|
|
9721
9753
|
|
|
9722
|
-
export { AnimateEvent, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, arrowType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, useCanvas, useModule, zoomLayerType };
|
|
9754
|
+
export { AnimateEvent, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$2 as tempPoint, useCanvas, useModule, version, zoomLayerType };
|