@leafer/core 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/lib/core.cjs +289 -308
- package/lib/core.esm.js +284 -309
- package/lib/core.esm.min.js +1 -1
- package/lib/core.min.cjs +1 -1
- package/package.json +18 -18
package/lib/core.esm.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$3, cos: cos$3, 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$7(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$7(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$7(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$7, 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$6(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 = t.x + t.width;
|
|
896
917
|
bottom = 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 = right > boundsRight ? right : boundsRight;
|
|
900
925
|
bottom = bottom > boundsBottom ? bottom : 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$6(t, bounds);
|
|
924
949
|
}
|
|
925
950
|
else {
|
|
926
951
|
add(t, bounds);
|
|
@@ -934,6 +959,9 @@ const BoundsHelper = {
|
|
|
934
959
|
points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
|
|
935
960
|
toBounds$2(tempPointBounds$1, t);
|
|
936
961
|
},
|
|
962
|
+
addPoint(t, point) {
|
|
963
|
+
add(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, copy: copy$
|
|
1026
|
+
const { add, copy: copy$6 } = 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 = new Bounds();
|
|
1118
1151
|
|
|
1119
1152
|
class AutoBounds {
|
|
1120
1153
|
constructor(top, right, bottom, left, width, height) {
|
|
@@ -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.prototype, "strokeText", null);
|
|
1890
1894
|
|
|
1891
|
-
const { copy: copy$
|
|
1892
|
-
const temp = new Bounds();
|
|
1895
|
+
const { copy: copy$5 } = MatrixHelper;
|
|
1893
1896
|
const minSize = { width: 1, height: 1, pixelRatio: 1 };
|
|
1894
|
-
const debug$5 = Debug.get('LeaferCanvasBase');
|
|
1895
1897
|
const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
|
|
1896
1898
|
class LeaferCanvasBase extends Canvas {
|
|
1897
1899
|
get width() { return this.size.width; }
|
|
@@ -1918,44 +1920,15 @@ class LeaferCanvasBase extends Canvas {
|
|
|
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$5.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$5.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 {
|
|
|
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 {
|
|
|
2088
2057
|
if (blendMode)
|
|
2089
2058
|
this.blendMode = blendMode;
|
|
2090
2059
|
this.fillStyle = color;
|
|
2091
|
-
|
|
2092
|
-
this.fillRect(
|
|
2060
|
+
tempBounds.set(bounds).scale(this.pixelRatio);
|
|
2061
|
+
this.fillRect(tempBounds.x, tempBounds.y, tempBounds.width, tempBounds.height);
|
|
2093
2062
|
if (blendMode)
|
|
2094
2063
|
this.blendMode = 'source-over';
|
|
2095
2064
|
}
|
|
@@ -2097,23 +2066,23 @@ class LeaferCanvasBase extends Canvas {
|
|
|
2097
2066
|
if (blendMode)
|
|
2098
2067
|
this.blendMode = blendMode;
|
|
2099
2068
|
this.strokeStyle = color;
|
|
2100
|
-
|
|
2101
|
-
this.strokeRect(
|
|
2069
|
+
tempBounds.set(bounds).scale(this.pixelRatio);
|
|
2070
|
+
this.strokeRect(tempBounds.x, tempBounds.y, tempBounds.width, tempBounds.height);
|
|
2102
2071
|
if (blendMode)
|
|
2103
2072
|
this.blendMode = 'source-over';
|
|
2104
2073
|
}
|
|
2105
2074
|
clearWorld(bounds, ceilPixel) {
|
|
2106
|
-
|
|
2075
|
+
tempBounds.set(bounds).scale(this.pixelRatio);
|
|
2107
2076
|
if (ceilPixel)
|
|
2108
|
-
|
|
2109
|
-
this.clearRect(
|
|
2077
|
+
tempBounds.ceil();
|
|
2078
|
+
this.clearRect(tempBounds.x, tempBounds.y, tempBounds.width, tempBounds.height);
|
|
2110
2079
|
}
|
|
2111
2080
|
clipWorld(bounds, ceilPixel) {
|
|
2112
2081
|
this.beginPath();
|
|
2113
|
-
|
|
2082
|
+
tempBounds.set(bounds).scale(this.pixelRatio);
|
|
2114
2083
|
if (ceilPixel)
|
|
2115
|
-
|
|
2116
|
-
this.rect(
|
|
2084
|
+
tempBounds.ceil();
|
|
2085
|
+
this.rect(tempBounds.x, tempBounds.y, tempBounds.width, tempBounds.height);
|
|
2117
2086
|
this.clip();
|
|
2118
2087
|
}
|
|
2119
2088
|
clear() {
|
|
@@ -2127,7 +2096,7 @@ class LeaferCanvasBase extends Canvas {
|
|
|
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$5(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$1, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$3, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2502
2471
|
const { ellipticalArc } = EllipseHelper;
|
|
2503
|
-
const debug$
|
|
2472
|
+
const debug$5 = 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$3(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$5.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 } = 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$4 = 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$4.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 } = BezierHelper;
|
|
2998
|
-
const { addPointBounds, copy: copy$
|
|
2999
|
-
const debug$
|
|
2968
|
+
const { addPointBounds, copy: copy$4, addPoint, setPoint, addBounds, toBounds: toBounds$1 } = TwoPointBoundsHelper;
|
|
2969
|
+
const debug$3 = 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(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$4(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$4(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$4(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$3.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$2 = 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$2.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 = new Debug('rewrite');
|
|
3839
|
+
const debug$1 = 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.error(item.name, '需在Class上装饰@rewriteAble()');
|
|
3856
|
+
debug$1.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$3, toInnerPoint: toInnerPoint$1, scaleOfOuter, rotateOfOuter, 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$3(matrix, t.__localMatrix);
|
|
4001
3972
|
scaleOfOuter(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$3(matrix, t.__localMatrix);
|
|
4010
3981
|
rotateOfOuter(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$3(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$3(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$3(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$3(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, pushAllBranchStack, updateBoundsByBranchStack } = Br
|
|
|
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$2 } = 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$2(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 = 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.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, updateAllMatrix, hasParentAutoLayout } = LeafHelper;
|
|
4796
4778
|
const { updateBounds } = BranchHelper;
|
|
4797
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread } = BoundsHelper;
|
|
4779
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread, copy: copy$1 } = BoundsHelper;
|
|
4798
4780
|
const { toBounds } = PathBounds;
|
|
4799
4781
|
const LeafBounds = {
|
|
4800
4782
|
__updateWorldBounds() {
|
|
@@ -4912,7 +4894,8 @@ const LeafBounds = {
|
|
|
4912
4894
|
copyAndSpread(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(renderBounds, strokeBounds, renderSpread) : copy$1(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) { }
|
|
@@ -5638,4 +5613,4 @@ class LeafLevelList {
|
|
|
5638
5613
|
}
|
|
5639
5614
|
}
|
|
5640
5615
|
|
|
5641
|
-
export { AnimateEvent, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, FileHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useModule };
|
|
5616
|
+
export { AnimateEvent, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, FileHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, useModule };
|