@leafer-draw/miniapp 1.9.4 → 1.9.5
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/miniapp.cjs +24 -14
- package/dist/miniapp.esm.js +24 -14
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +93 -126
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/miniapp.module.js
CHANGED
|
@@ -136,6 +136,9 @@ class LeafData {
|
|
|
136
136
|
const {path: path} = this;
|
|
137
137
|
return path && path.length === 6 && path[0] === 1;
|
|
138
138
|
}
|
|
139
|
+
get __usePathBox() {
|
|
140
|
+
return this.__pathInputed;
|
|
141
|
+
}
|
|
139
142
|
get __blendMode() {
|
|
140
143
|
if (this.eraser && this.eraser !== "path") return "destination-out";
|
|
141
144
|
const {blendMode: blendMode} = this;
|
|
@@ -1134,13 +1137,13 @@ const AlignHelper = {
|
|
|
1134
1137
|
}
|
|
1135
1138
|
};
|
|
1136
1139
|
|
|
1137
|
-
const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$
|
|
1140
|
+
const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
|
|
1138
1141
|
|
|
1139
1142
|
const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
1140
1143
|
|
|
1141
1144
|
const {float: float, fourNumber: fourNumber} = MathHelper;
|
|
1142
1145
|
|
|
1143
|
-
const {floor: floor$2, ceil: ceil$
|
|
1146
|
+
const {floor: floor$2, ceil: ceil$2} = Math;
|
|
1144
1147
|
|
|
1145
1148
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
1146
1149
|
|
|
@@ -1269,7 +1272,7 @@ const BoundsHelper = {
|
|
|
1269
1272
|
point.x = t.x;
|
|
1270
1273
|
toOuterPoint$2(matrix, point, toPoint$4);
|
|
1271
1274
|
addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
|
|
1272
|
-
toBounds$
|
|
1275
|
+
toBounds$2(tempPointBounds$1, to);
|
|
1273
1276
|
}
|
|
1274
1277
|
},
|
|
1275
1278
|
toInnerOf(t, matrix, to) {
|
|
@@ -1307,8 +1310,8 @@ const BoundsHelper = {
|
|
|
1307
1310
|
const {x: x, y: y} = t;
|
|
1308
1311
|
t.x = floor$2(t.x);
|
|
1309
1312
|
t.y = floor$2(t.y);
|
|
1310
|
-
t.width = x > t.x ? ceil$
|
|
1311
|
-
t.height = y > t.y ? ceil$
|
|
1313
|
+
t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
|
|
1314
|
+
t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
|
|
1312
1315
|
},
|
|
1313
1316
|
unsign(t) {
|
|
1314
1317
|
if (t.width < 0) {
|
|
@@ -1368,7 +1371,7 @@ const BoundsHelper = {
|
|
|
1368
1371
|
},
|
|
1369
1372
|
setPoints(t, points) {
|
|
1370
1373
|
points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
|
|
1371
|
-
toBounds$
|
|
1374
|
+
toBounds$2(tempPointBounds$1, t);
|
|
1372
1375
|
},
|
|
1373
1376
|
setPoint(t, point) {
|
|
1374
1377
|
B.set(t, point.x, point.y);
|
|
@@ -2221,15 +2224,15 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2221
2224
|
DataHelper.copyAttrs(s, size, canvasSizeAttrs);
|
|
2222
2225
|
canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
|
|
2223
2226
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2224
|
-
|
|
2225
|
-
this.updateViewSize();
|
|
2226
|
-
this.smooth = this.config.smooth;
|
|
2227
|
-
}
|
|
2227
|
+
this.updateViewSize();
|
|
2228
2228
|
this.updateClientBounds();
|
|
2229
|
-
if (this.context
|
|
2230
|
-
this.
|
|
2231
|
-
this.
|
|
2232
|
-
|
|
2229
|
+
if (this.context) {
|
|
2230
|
+
this.smooth = this.config.smooth;
|
|
2231
|
+
if (!this.unreal && takeCanvas) {
|
|
2232
|
+
this.clearWorld(takeCanvas.bounds);
|
|
2233
|
+
this.copyWorld(takeCanvas);
|
|
2234
|
+
takeCanvas.recycle();
|
|
2235
|
+
}
|
|
2233
2236
|
}
|
|
2234
2237
|
}
|
|
2235
2238
|
updateViewSize() {}
|
|
@@ -2543,7 +2546,7 @@ const RectHelper = {
|
|
|
2543
2546
|
}
|
|
2544
2547
|
};
|
|
2545
2548
|
|
|
2546
|
-
const {sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
|
|
2549
|
+
const {sin: sin$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil$1, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
|
|
2547
2550
|
|
|
2548
2551
|
const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
|
|
2549
2552
|
|
|
@@ -2614,9 +2617,11 @@ const BezierHelper = {
|
|
|
2614
2617
|
const CBy = toY - y1;
|
|
2615
2618
|
let startRadian = atan2$1(BAy, BAx);
|
|
2616
2619
|
let endRadian = atan2$1(CBy, CBx);
|
|
2620
|
+
const lenBA = hypot(BAx, BAy);
|
|
2621
|
+
const lenCB = hypot(CBx, CBy);
|
|
2617
2622
|
let totalRadian = endRadian - startRadian;
|
|
2618
2623
|
if (totalRadian < 0) totalRadian += PI2;
|
|
2619
|
-
if (
|
|
2624
|
+
if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$2(totalRadian - PI$2) < 1e-12) {
|
|
2620
2625
|
if (data) data.push(L$6, x1, y1);
|
|
2621
2626
|
if (setPointBounds) {
|
|
2622
2627
|
setPoint$1(setPointBounds, fromX, fromY);
|
|
@@ -2649,7 +2654,7 @@ const BezierHelper = {
|
|
|
2649
2654
|
let totalRadian = endRadian - startRadian;
|
|
2650
2655
|
if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
|
|
2651
2656
|
if (anticlockwise) totalRadian -= PI2;
|
|
2652
|
-
const parts = ceil(abs$2(totalRadian / PI_2));
|
|
2657
|
+
const parts = ceil$1(abs$2(totalRadian / PI_2));
|
|
2653
2658
|
const partRadian = totalRadian / parts;
|
|
2654
2659
|
const partRadian4Sin = sin$3(partRadian / 4);
|
|
2655
2660
|
const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
|
|
@@ -3208,11 +3213,7 @@ class PathCreator {
|
|
|
3208
3213
|
this.set(path);
|
|
3209
3214
|
}
|
|
3210
3215
|
set(path) {
|
|
3211
|
-
|
|
3212
|
-
this.__path = isString(path) ? PathHelper.parse(path) : path;
|
|
3213
|
-
} else {
|
|
3214
|
-
this.__path = [];
|
|
3215
|
-
}
|
|
3216
|
+
this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
|
|
3216
3217
|
return this;
|
|
3217
3218
|
}
|
|
3218
3219
|
beginPath() {
|
|
@@ -3380,7 +3381,7 @@ const {M: M$1, L: L$2, C: C, Q: Q, Z: Z$1, N: N, D: D$1, X: X, G: G, F: F$1, O:
|
|
|
3380
3381
|
|
|
3381
3382
|
const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
|
|
3382
3383
|
|
|
3383
|
-
const {addPointBounds: addPointBounds, copy: copy$6, addPoint: addPoint, setPoint: setPoint, addBounds: addBounds, toBounds: toBounds$
|
|
3384
|
+
const {addPointBounds: addPointBounds, copy: copy$6, addPoint: addPoint, setPoint: setPoint, addBounds: addBounds, toBounds: toBounds$1} = TwoPointBoundsHelper;
|
|
3384
3385
|
|
|
3385
3386
|
const debug$9 = Debug.get("PathBounds");
|
|
3386
3387
|
|
|
@@ -3395,7 +3396,7 @@ const setEndPoint = {};
|
|
|
3395
3396
|
const PathBounds = {
|
|
3396
3397
|
toBounds(data, setBounds) {
|
|
3397
3398
|
PathBounds.toTwoPointBounds(data, setPointBounds);
|
|
3398
|
-
toBounds$
|
|
3399
|
+
toBounds$1(setPointBounds, setBounds);
|
|
3399
3400
|
},
|
|
3400
3401
|
toTwoPointBounds(data, setPointBounds) {
|
|
3401
3402
|
if (!data || !data.length) return setPoint(setPointBounds, 0, 0);
|
|
@@ -3582,14 +3583,18 @@ const PathCorner = {
|
|
|
3582
3583
|
}
|
|
3583
3584
|
};
|
|
3584
3585
|
|
|
3585
|
-
|
|
3586
|
+
function path(path) {
|
|
3587
|
+
return new PathCreator(path);
|
|
3588
|
+
}
|
|
3589
|
+
|
|
3590
|
+
const pen = path();
|
|
3591
|
+
|
|
3592
|
+
PathHelper.creator = path();
|
|
3586
3593
|
|
|
3587
3594
|
PathHelper.parse = PathConvert.parse;
|
|
3588
3595
|
|
|
3589
3596
|
PathHelper.convertToCanvasData = PathConvert.toCanvasData;
|
|
3590
3597
|
|
|
3591
|
-
const pen = new PathCreator;
|
|
3592
|
-
|
|
3593
3598
|
const {drawRoundRect: drawRoundRect} = RectHelper;
|
|
3594
3599
|
|
|
3595
3600
|
function roundRect(drawer) {
|
|
@@ -3954,7 +3959,7 @@ const ImageManager = {
|
|
|
3954
3959
|
return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
|
|
3955
3960
|
},
|
|
3956
3961
|
isFormat(format, config) {
|
|
3957
|
-
if (config.format
|
|
3962
|
+
if (config.format) return config.format === format;
|
|
3958
3963
|
const {url: url} = config;
|
|
3959
3964
|
if (url.startsWith("data:")) {
|
|
3960
3965
|
if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
|
|
@@ -4048,7 +4053,7 @@ class LeaferImage {
|
|
|
4048
4053
|
getFull(_filters) {
|
|
4049
4054
|
return this.view;
|
|
4050
4055
|
}
|
|
4051
|
-
getCanvas(width, height, opacity, _filters, xGap, yGap) {
|
|
4056
|
+
getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
|
|
4052
4057
|
width || (width = this.width);
|
|
4053
4058
|
height || (height = this.height);
|
|
4054
4059
|
if (this.cache) {
|
|
@@ -4064,6 +4069,7 @@ class LeaferImage {
|
|
|
4064
4069
|
const canvas = Platform.origin.createCanvas(max$1(floor$1(width + (xGap || 0)), 1), max$1(floor$1(height + (yGap || 0)), 1));
|
|
4065
4070
|
const ctx = canvas.getContext("2d");
|
|
4066
4071
|
if (opacity) ctx.globalAlpha = opacity;
|
|
4072
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
4067
4073
|
ctx.drawImage(this.view, 0, 0, width, height);
|
|
4068
4074
|
this.cache = this.use > 1 ? {
|
|
4069
4075
|
data: canvas,
|
|
@@ -4715,8 +4721,9 @@ const L = LeafHelper;
|
|
|
4715
4721
|
|
|
4716
4722
|
const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L;
|
|
4717
4723
|
|
|
4718
|
-
function getTempLocal(t,
|
|
4719
|
-
|
|
4724
|
+
function getTempLocal(t, worldPoint) {
|
|
4725
|
+
t.updateLayout();
|
|
4726
|
+
return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
|
|
4720
4727
|
}
|
|
4721
4728
|
|
|
4722
4729
|
const LeafBoundsHelper = {
|
|
@@ -5734,7 +5741,7 @@ const {updateBounds: updateBounds$1} = BranchHelper;
|
|
|
5734
5741
|
|
|
5735
5742
|
const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$3} = BoundsHelper;
|
|
5736
5743
|
|
|
5737
|
-
const {toBounds: toBounds
|
|
5744
|
+
const {toBounds: toBounds} = PathBounds;
|
|
5738
5745
|
|
|
5739
5746
|
const LeafBounds = {
|
|
5740
5747
|
__updateWorldBounds() {
|
|
@@ -5806,8 +5813,8 @@ const LeafBounds = {
|
|
|
5806
5813
|
__updateBoxBounds(_secondLayout, _bounds) {
|
|
5807
5814
|
const b = this.__layout.boxBounds;
|
|
5808
5815
|
const data = this.__;
|
|
5809
|
-
if (data.
|
|
5810
|
-
toBounds
|
|
5816
|
+
if (data.__usePathBox) {
|
|
5817
|
+
toBounds(data.path, b);
|
|
5811
5818
|
} else {
|
|
5812
5819
|
b.x = 0;
|
|
5813
5820
|
b.y = 0;
|
|
@@ -6742,7 +6749,7 @@ class LeafLevelList {
|
|
|
6742
6749
|
}
|
|
6743
6750
|
}
|
|
6744
6751
|
|
|
6745
|
-
const version = "1.9.
|
|
6752
|
+
const version = "1.9.5";
|
|
6746
6753
|
|
|
6747
6754
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6748
6755
|
get allowBackgroundColor() {
|
|
@@ -6796,6 +6803,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
6796
6803
|
this.view = Platform.origin.createCanvas(1, 1);
|
|
6797
6804
|
}
|
|
6798
6805
|
updateViewSize() {
|
|
6806
|
+
if (this.unreal) return;
|
|
6799
6807
|
const {width: width, height: height, pixelRatio: pixelRatio} = this;
|
|
6800
6808
|
this.view.width = Math.ceil(width * pixelRatio);
|
|
6801
6809
|
this.view.height = Math.ceil(height * pixelRatio);
|
|
@@ -6807,6 +6815,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
6807
6815
|
});
|
|
6808
6816
|
}
|
|
6809
6817
|
startAutoLayout(autoBounds, listener) {
|
|
6818
|
+
if (this.resizeListener) return;
|
|
6810
6819
|
this.resizeListener = listener;
|
|
6811
6820
|
if (autoBounds) {
|
|
6812
6821
|
this.checkSize = this.checkSize.bind(this);
|
|
@@ -7316,7 +7325,7 @@ class Renderer {
|
|
|
7316
7325
|
this.times = 0;
|
|
7317
7326
|
this.config = {
|
|
7318
7327
|
usePartRender: true,
|
|
7319
|
-
maxFPS:
|
|
7328
|
+
maxFPS: 120
|
|
7320
7329
|
};
|
|
7321
7330
|
this.target = target;
|
|
7322
7331
|
this.canvas = canvas;
|
|
@@ -7471,11 +7480,15 @@ class Renderer {
|
|
|
7471
7480
|
if (this.requestTime || !target) return;
|
|
7472
7481
|
if (target.parentApp) return target.parentApp.requestRender(false);
|
|
7473
7482
|
const requestTime = this.requestTime = Date.now();
|
|
7474
|
-
|
|
7475
|
-
|
|
7483
|
+
const render = () => {
|
|
7484
|
+
const nowFPS = 1e3 / (Date.now() - requestTime);
|
|
7485
|
+
const {maxFPS: maxFPS} = this.config;
|
|
7486
|
+
if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
|
|
7487
|
+
this.FPS = Math.min(120, Math.ceil(nowFPS));
|
|
7476
7488
|
this.requestTime = 0;
|
|
7477
7489
|
this.checkRender();
|
|
7478
|
-
}
|
|
7490
|
+
};
|
|
7491
|
+
Platform.requestRender(render);
|
|
7479
7492
|
}
|
|
7480
7493
|
__onResize(e) {
|
|
7481
7494
|
if (this.canvas.unreal) return;
|
|
@@ -7518,7 +7531,8 @@ class Renderer {
|
|
|
7518
7531
|
if (this.target) {
|
|
7519
7532
|
this.stop();
|
|
7520
7533
|
this.__removeListenEvents();
|
|
7521
|
-
this.
|
|
7534
|
+
this.config = {};
|
|
7535
|
+
this.target = this.canvas = null;
|
|
7522
7536
|
}
|
|
7523
7537
|
}
|
|
7524
7538
|
}
|
|
@@ -7826,7 +7840,11 @@ class LeaferData extends GroupData {
|
|
|
7826
7840
|
|
|
7827
7841
|
class FrameData extends BoxData {}
|
|
7828
7842
|
|
|
7829
|
-
class LineData extends UIData {
|
|
7843
|
+
class LineData extends UIData {
|
|
7844
|
+
get __usePathBox() {
|
|
7845
|
+
return this.points || this.__pathInputed;
|
|
7846
|
+
}
|
|
7847
|
+
}
|
|
7830
7848
|
|
|
7831
7849
|
class RectData extends UIData {
|
|
7832
7850
|
get __boxStroke() {
|
|
@@ -7840,7 +7858,7 @@ class EllipseData extends UIData {
|
|
|
7840
7858
|
}
|
|
7841
7859
|
}
|
|
7842
7860
|
|
|
7843
|
-
class PolygonData extends
|
|
7861
|
+
class PolygonData extends LineData {}
|
|
7844
7862
|
|
|
7845
7863
|
class StarData extends UIData {}
|
|
7846
7864
|
|
|
@@ -8150,20 +8168,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8150
8168
|
if (!path) this.__drawPathByBox(pen);
|
|
8151
8169
|
return pen;
|
|
8152
8170
|
}
|
|
8153
|
-
constructor(data) {
|
|
8154
|
-
super(data);
|
|
8155
|
-
}
|
|
8156
8171
|
reset(_data) {}
|
|
8157
|
-
set(data,
|
|
8158
|
-
if (data)
|
|
8159
|
-
if (transition) {
|
|
8160
|
-
if (transition === "temp") {
|
|
8161
|
-
this.lockNormalStyle = true;
|
|
8162
|
-
Object.assign(this, data);
|
|
8163
|
-
this.lockNormalStyle = false;
|
|
8164
|
-
} else this.animate(data, transition);
|
|
8165
|
-
} else Object.assign(this, data);
|
|
8166
|
-
}
|
|
8172
|
+
set(data, _transition) {
|
|
8173
|
+
if (data) Object.assign(this, data);
|
|
8167
8174
|
}
|
|
8168
8175
|
get(name) {
|
|
8169
8176
|
return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
@@ -8209,7 +8216,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8209
8216
|
const data = this.__;
|
|
8210
8217
|
if (data.path) {
|
|
8211
8218
|
data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
|
|
8212
|
-
if (data.__useArrow) PathArrow.addArrows(this
|
|
8219
|
+
if (data.__useArrow) PathArrow.addArrows(this);
|
|
8213
8220
|
} else data.__pathForRender && (data.__pathForRender = undefined);
|
|
8214
8221
|
}
|
|
8215
8222
|
__drawRenderPath(canvas) {
|
|
@@ -8233,7 +8240,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8233
8240
|
drawImagePlaceholder(canvas, _image) {
|
|
8234
8241
|
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
8235
8242
|
}
|
|
8236
|
-
animate(
|
|
8243
|
+
animate(keyframe, _options, _type, _isTemp) {
|
|
8244
|
+
this.set(keyframe);
|
|
8237
8245
|
return Plugin.need("animate");
|
|
8238
8246
|
}
|
|
8239
8247
|
killAnimate(_type, _nextStyle) {}
|
|
@@ -8422,9 +8430,6 @@ let Group = class Group extends UI {
|
|
|
8422
8430
|
get isBranch() {
|
|
8423
8431
|
return true;
|
|
8424
8432
|
}
|
|
8425
|
-
constructor(data) {
|
|
8426
|
-
super(data);
|
|
8427
|
-
}
|
|
8428
8433
|
reset(data) {
|
|
8429
8434
|
this.__setBranch();
|
|
8430
8435
|
super.reset(data);
|
|
@@ -8549,7 +8554,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8549
8554
|
const canvas = this.canvas = Creator.canvas(config);
|
|
8550
8555
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
8551
8556
|
if (this.isApp) this.__setApp();
|
|
8552
|
-
this.__checkAutoLayout(
|
|
8557
|
+
this.__checkAutoLayout();
|
|
8553
8558
|
this.view = canvas.view;
|
|
8554
8559
|
if (!parentApp) {
|
|
8555
8560
|
this.selector = Creator.selector(this);
|
|
@@ -8648,7 +8653,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8648
8653
|
this.leafer = leafer;
|
|
8649
8654
|
this.__level = 1;
|
|
8650
8655
|
}
|
|
8651
|
-
__checkAutoLayout(
|
|
8656
|
+
__checkAutoLayout() {
|
|
8657
|
+
const {config: config, parentApp: parentApp} = this;
|
|
8652
8658
|
if (!parentApp) {
|
|
8653
8659
|
if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
|
|
8654
8660
|
this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
|
|
@@ -8674,9 +8680,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8674
8680
|
return super.__getAttr(attrName);
|
|
8675
8681
|
}
|
|
8676
8682
|
__changeCanvasSize(attrName, newValue) {
|
|
8677
|
-
const
|
|
8678
|
-
data
|
|
8679
|
-
|
|
8683
|
+
const {config: config, canvas: canvas} = this;
|
|
8684
|
+
const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
|
|
8685
|
+
data[attrName] = config[attrName] = newValue;
|
|
8686
|
+
config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
|
|
8680
8687
|
this.__doResize(data);
|
|
8681
8688
|
}
|
|
8682
8689
|
__changeFill(newValue) {
|
|
@@ -8823,9 +8830,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8823
8830
|
if (!this.parent) {
|
|
8824
8831
|
if (this.selector) this.selector.destroy();
|
|
8825
8832
|
if (this.hitCanvasManager) this.hitCanvasManager.destroy();
|
|
8826
|
-
this.canvasManager.destroy();
|
|
8833
|
+
if (this.canvasManager) this.canvasManager.destroy();
|
|
8827
8834
|
}
|
|
8828
|
-
this.canvas.destroy();
|
|
8835
|
+
if (this.canvas) this.canvas.destroy();
|
|
8829
8836
|
this.config.view = this.view = this.parentApp = null;
|
|
8830
8837
|
if (this.userConfig) this.userConfig.view = null;
|
|
8831
8838
|
super.destroy();
|
|
@@ -8853,9 +8860,6 @@ let Rect = class Rect extends UI {
|
|
|
8853
8860
|
get __tag() {
|
|
8854
8861
|
return "Rect";
|
|
8855
8862
|
}
|
|
8856
|
-
constructor(data) {
|
|
8857
|
-
super(data);
|
|
8858
|
-
}
|
|
8859
8863
|
};
|
|
8860
8864
|
|
|
8861
8865
|
__decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
|
|
@@ -8987,9 +8991,6 @@ let Frame = class Frame extends Box {
|
|
|
8987
8991
|
get isFrame() {
|
|
8988
8992
|
return true;
|
|
8989
8993
|
}
|
|
8990
|
-
constructor(data) {
|
|
8991
|
-
super(data);
|
|
8992
|
-
}
|
|
8993
8994
|
};
|
|
8994
8995
|
|
|
8995
8996
|
__decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
|
|
@@ -9006,9 +9007,6 @@ let Ellipse = class Ellipse extends UI {
|
|
|
9006
9007
|
get __tag() {
|
|
9007
9008
|
return "Ellipse";
|
|
9008
9009
|
}
|
|
9009
|
-
constructor(data) {
|
|
9010
|
-
super(data);
|
|
9011
|
-
}
|
|
9012
9010
|
__updatePath() {
|
|
9013
9011
|
const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
|
|
9014
9012
|
const rx = width / 2, ry = height / 2;
|
|
@@ -9052,8 +9050,6 @@ const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathComma
|
|
|
9052
9050
|
|
|
9053
9051
|
const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
|
|
9054
9052
|
|
|
9055
|
-
const {toBounds: toBounds} = PathBounds;
|
|
9056
|
-
|
|
9057
9053
|
let Line = class Line extends UI {
|
|
9058
9054
|
get __tag() {
|
|
9059
9055
|
return "Line";
|
|
@@ -9070,31 +9066,16 @@ let Line = class Line extends UI {
|
|
|
9070
9066
|
this.rotation = getAngle$1(defaultPoint, value);
|
|
9071
9067
|
if (this.height) this.height = 0;
|
|
9072
9068
|
}
|
|
9073
|
-
constructor(data) {
|
|
9074
|
-
super(data);
|
|
9075
|
-
}
|
|
9076
9069
|
__updatePath() {
|
|
9077
9070
|
const data = this.__;
|
|
9078
9071
|
const path = data.path = [];
|
|
9079
9072
|
if (data.points) {
|
|
9080
|
-
drawPoints$1(path, data.points,
|
|
9073
|
+
drawPoints$1(path, data.points, data.curve, data.closed);
|
|
9081
9074
|
} else {
|
|
9082
9075
|
moveTo$2(path, 0, 0);
|
|
9083
9076
|
lineTo$2(path, this.width, 0);
|
|
9084
9077
|
}
|
|
9085
9078
|
}
|
|
9086
|
-
__updateRenderPath() {
|
|
9087
|
-
const data = this.__;
|
|
9088
|
-
if (!this.pathInputed && data.points && data.curve) {
|
|
9089
|
-
drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
|
|
9090
|
-
if (data.__useArrow) PathArrow.addArrows(this, false);
|
|
9091
|
-
} else super.__updateRenderPath();
|
|
9092
|
-
}
|
|
9093
|
-
__updateBoxBounds() {
|
|
9094
|
-
if (this.points) {
|
|
9095
|
-
toBounds(this.__.__pathForRender, this.__layout.boxBounds);
|
|
9096
|
-
} else super.__updateBoxBounds();
|
|
9097
|
-
}
|
|
9098
9079
|
};
|
|
9099
9080
|
|
|
9100
9081
|
__decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
|
|
@@ -9121,15 +9102,13 @@ let Polygon = class Polygon extends UI {
|
|
|
9121
9102
|
get __tag() {
|
|
9122
9103
|
return "Polygon";
|
|
9123
9104
|
}
|
|
9124
|
-
constructor(data) {
|
|
9125
|
-
super(data);
|
|
9126
|
-
}
|
|
9127
9105
|
__updatePath() {
|
|
9128
|
-
const
|
|
9129
|
-
|
|
9130
|
-
|
|
9106
|
+
const data = this.__;
|
|
9107
|
+
const path = data.path = [];
|
|
9108
|
+
if (data.points) {
|
|
9109
|
+
drawPoints(path, data.points, data.curve, true);
|
|
9131
9110
|
} else {
|
|
9132
|
-
const {width: width, height: height, sides: sides} =
|
|
9111
|
+
const {width: width, height: height, sides: sides} = data;
|
|
9133
9112
|
const rx = width / 2, ry = height / 2;
|
|
9134
9113
|
moveTo$1(path, rx, 0);
|
|
9135
9114
|
for (let i = 1; i < sides; i++) {
|
|
@@ -9164,9 +9143,6 @@ let Star = class Star extends UI {
|
|
|
9164
9143
|
get __tag() {
|
|
9165
9144
|
return "Star";
|
|
9166
9145
|
}
|
|
9167
|
-
constructor(data) {
|
|
9168
|
-
super(data);
|
|
9169
|
-
}
|
|
9170
9146
|
__updatePath() {
|
|
9171
9147
|
const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
|
|
9172
9148
|
const rx = width / 2, ry = height / 2;
|
|
@@ -9199,9 +9175,6 @@ let Image = class Image extends Rect {
|
|
|
9199
9175
|
const {fill: fill} = this.__;
|
|
9200
9176
|
return isArray(fill) && fill[0].image;
|
|
9201
9177
|
}
|
|
9202
|
-
constructor(data) {
|
|
9203
|
-
super(data);
|
|
9204
|
-
}
|
|
9205
9178
|
};
|
|
9206
9179
|
|
|
9207
9180
|
__decorate([ dataProcessor(ImageData) ], Image.prototype, "__", void 0);
|
|
@@ -9301,9 +9274,6 @@ let Text = class Text extends UI {
|
|
|
9301
9274
|
this.updateLayout();
|
|
9302
9275
|
return this.__.__textDrawData;
|
|
9303
9276
|
}
|
|
9304
|
-
constructor(data) {
|
|
9305
|
-
super(data);
|
|
9306
|
-
}
|
|
9307
9277
|
__updateTextDrawData() {
|
|
9308
9278
|
const data = this.__;
|
|
9309
9279
|
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
@@ -9436,9 +9406,6 @@ let Path = class Path extends UI {
|
|
|
9436
9406
|
get __tag() {
|
|
9437
9407
|
return "Path";
|
|
9438
9408
|
}
|
|
9439
|
-
constructor(data) {
|
|
9440
|
-
super(data);
|
|
9441
|
-
}
|
|
9442
9409
|
};
|
|
9443
9410
|
|
|
9444
9411
|
__decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
|
|
@@ -9451,9 +9418,6 @@ let Pen = class Pen extends Group {
|
|
|
9451
9418
|
get __tag() {
|
|
9452
9419
|
return "Pen";
|
|
9453
9420
|
}
|
|
9454
|
-
constructor(data) {
|
|
9455
|
-
super(data);
|
|
9456
|
-
}
|
|
9457
9421
|
setStyle(data) {
|
|
9458
9422
|
const path = this.pathElement = new Path(data);
|
|
9459
9423
|
this.pathStyle = data;
|
|
@@ -10149,7 +10113,7 @@ function ignoreRender(ui, value) {
|
|
|
10149
10113
|
|
|
10150
10114
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
10151
10115
|
|
|
10152
|
-
const {floor: floor, max: max, abs: abs} = Math;
|
|
10116
|
+
const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
|
|
10153
10117
|
|
|
10154
10118
|
function createPattern(ui, paint, pixelRatio) {
|
|
10155
10119
|
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
@@ -10159,8 +10123,6 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
10159
10123
|
let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
|
|
10160
10124
|
scaleX *= pixelRatio;
|
|
10161
10125
|
scaleY *= pixelRatio;
|
|
10162
|
-
const xGap = gap && gap.x * scaleX;
|
|
10163
|
-
const yGap = gap && gap.y * scaleY;
|
|
10164
10126
|
if (sx) {
|
|
10165
10127
|
sx = abs(sx);
|
|
10166
10128
|
sy = abs(sy);
|
|
@@ -10177,7 +10139,10 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
10177
10139
|
if (size > Platform.image.maxCacheSize) return false;
|
|
10178
10140
|
}
|
|
10179
10141
|
let maxSize = Platform.image.maxPatternSize;
|
|
10180
|
-
if (
|
|
10142
|
+
if (image.isSVG) {
|
|
10143
|
+
const ws = width / image.width;
|
|
10144
|
+
if (ws > 1) imageScale = ws / ceil(ws);
|
|
10145
|
+
} else {
|
|
10181
10146
|
const imageSize = image.width * image.height;
|
|
10182
10147
|
if (maxSize > imageSize) maxSize = imageSize;
|
|
10183
10148
|
}
|
|
@@ -10192,18 +10157,20 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
10192
10157
|
scaleX /= sx;
|
|
10193
10158
|
scaleY /= sy;
|
|
10194
10159
|
}
|
|
10160
|
+
const xGap = gap && gap.x * scaleX;
|
|
10161
|
+
const yGap = gap && gap.y * scaleY;
|
|
10195
10162
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10163
|
+
const canvasWidth = width + (xGap || 0);
|
|
10164
|
+
const canvasHeight = height + (yGap || 0);
|
|
10165
|
+
scaleX /= canvasWidth / max(floor(canvasWidth), 1);
|
|
10166
|
+
scaleY /= canvasHeight / max(floor(canvasHeight), 1);
|
|
10196
10167
|
if (!imageMatrix) {
|
|
10197
10168
|
imageMatrix = get$1();
|
|
10198
10169
|
if (transform) copy$1(imageMatrix, transform);
|
|
10199
10170
|
}
|
|
10200
10171
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10201
10172
|
}
|
|
10202
|
-
|
|
10203
|
-
const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
|
|
10204
|
-
scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
|
|
10205
|
-
}
|
|
10206
|
-
const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
|
|
10173
|
+
const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
10207
10174
|
const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10208
10175
|
paint.style = pattern;
|
|
10209
10176
|
paint.patternId = id;
|
|
@@ -11153,4 +11120,4 @@ try {
|
|
|
11153
11120
|
if (wx) useCanvas("miniapp", wx);
|
|
11154
11121
|
} catch (_a) {}
|
|
11155
11122
|
|
|
11156
|
-
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
11123
|
+
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
|