@leafer/worker 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/worker.js +138 -134
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +141 -137
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +22 -22
package/dist/worker.js
CHANGED
|
@@ -119,6 +119,9 @@ var LeaferUI = function(exports) {
|
|
|
119
119
|
const {path: path} = this;
|
|
120
120
|
return path && path.length === 6 && path[0] === 1;
|
|
121
121
|
}
|
|
122
|
+
get __usePathBox() {
|
|
123
|
+
return this.__pathInputed;
|
|
124
|
+
}
|
|
122
125
|
get __blendMode() {
|
|
123
126
|
if (this.eraser && this.eraser !== "path") return "destination-out";
|
|
124
127
|
const {blendMode: blendMode} = this;
|
|
@@ -1080,10 +1083,10 @@ var LeaferUI = function(exports) {
|
|
|
1080
1083
|
toPoint$6(align, box, to, onlyBoxSize, content, onlyContentSize);
|
|
1081
1084
|
}
|
|
1082
1085
|
};
|
|
1083
|
-
const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPoint$3, toBounds: toBounds$
|
|
1086
|
+
const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPoint$3, toBounds: toBounds$3} = TwoPointBoundsHelper;
|
|
1084
1087
|
const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
1085
1088
|
const {float: float$1, fourNumber: fourNumber$1} = MathHelper;
|
|
1086
|
-
const {floor: floor$3, ceil: ceil$
|
|
1089
|
+
const {floor: floor$3, ceil: ceil$3} = Math;
|
|
1087
1090
|
let right$4, bottom$3, boundsRight, boundsBottom;
|
|
1088
1091
|
const point$2 = {};
|
|
1089
1092
|
const toPoint$5 = {};
|
|
@@ -1207,7 +1210,7 @@ var LeaferUI = function(exports) {
|
|
|
1207
1210
|
point$2.x = t.x;
|
|
1208
1211
|
toOuterPoint$2(matrix, point$2, toPoint$5);
|
|
1209
1212
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
1210
|
-
toBounds$
|
|
1213
|
+
toBounds$3(tempPointBounds$1, to);
|
|
1211
1214
|
}
|
|
1212
1215
|
},
|
|
1213
1216
|
toInnerOf(t, matrix, to) {
|
|
@@ -1245,8 +1248,8 @@ var LeaferUI = function(exports) {
|
|
|
1245
1248
|
const {x: x, y: y} = t;
|
|
1246
1249
|
t.x = floor$3(t.x);
|
|
1247
1250
|
t.y = floor$3(t.y);
|
|
1248
|
-
t.width = x > t.x ? ceil$
|
|
1249
|
-
t.height = y > t.y ? ceil$
|
|
1251
|
+
t.width = x > t.x ? ceil$3(t.width + x - t.x) : ceil$3(t.width);
|
|
1252
|
+
t.height = y > t.y ? ceil$3(t.height + y - t.y) : ceil$3(t.height);
|
|
1250
1253
|
},
|
|
1251
1254
|
unsign(t) {
|
|
1252
1255
|
if (t.width < 0) {
|
|
@@ -1306,7 +1309,7 @@ var LeaferUI = function(exports) {
|
|
|
1306
1309
|
},
|
|
1307
1310
|
setPoints(t, points) {
|
|
1308
1311
|
points.forEach((point, index) => index === 0 ? setPoint$5(tempPointBounds$1, point.x, point.y) : addPoint$3(tempPointBounds$1, point.x, point.y));
|
|
1309
|
-
toBounds$
|
|
1312
|
+
toBounds$3(tempPointBounds$1, t);
|
|
1310
1313
|
},
|
|
1311
1314
|
setPoint(t, point) {
|
|
1312
1315
|
B.set(t, point.x, point.y);
|
|
@@ -2063,15 +2066,15 @@ var LeaferUI = function(exports) {
|
|
|
2063
2066
|
DataHelper.copyAttrs(s, size, canvasSizeAttrs);
|
|
2064
2067
|
canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
|
|
2065
2068
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2066
|
-
|
|
2067
|
-
this.updateViewSize();
|
|
2068
|
-
this.smooth = this.config.smooth;
|
|
2069
|
-
}
|
|
2069
|
+
this.updateViewSize();
|
|
2070
2070
|
this.updateClientBounds();
|
|
2071
|
-
if (this.context
|
|
2072
|
-
this.
|
|
2073
|
-
this.
|
|
2074
|
-
|
|
2071
|
+
if (this.context) {
|
|
2072
|
+
this.smooth = this.config.smooth;
|
|
2073
|
+
if (!this.unreal && takeCanvas) {
|
|
2074
|
+
this.clearWorld(takeCanvas.bounds);
|
|
2075
|
+
this.copyWorld(takeCanvas);
|
|
2076
|
+
takeCanvas.recycle();
|
|
2077
|
+
}
|
|
2075
2078
|
}
|
|
2076
2079
|
}
|
|
2077
2080
|
updateViewSize() {}
|
|
@@ -2372,7 +2375,7 @@ var LeaferUI = function(exports) {
|
|
|
2372
2375
|
data[0] ? drawer.arcTo(x, y, right, y, data[0]) : drawer.lineTo(x, y);
|
|
2373
2376
|
}
|
|
2374
2377
|
};
|
|
2375
|
-
const {sin: sin$4, cos: cos$4, atan2: atan2$1, ceil: ceil$
|
|
2378
|
+
const {sin: sin$4, cos: cos$4, hypot: hypot, atan2: atan2$1, ceil: ceil$2, abs: abs$6, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
|
|
2376
2379
|
const {setPoint: setPoint$4, addPoint: addPoint$2} = TwoPointBoundsHelper;
|
|
2377
2380
|
const {set: set, toNumberPoints: toNumberPoints$1} = PointHelper;
|
|
2378
2381
|
const {M: M$9, L: L$a, C: C$8, Q: Q$7, Z: Z$8} = PathCommandMap;
|
|
@@ -2438,9 +2441,11 @@ var LeaferUI = function(exports) {
|
|
|
2438
2441
|
const CBy = toY - y1;
|
|
2439
2442
|
let startRadian = atan2$1(BAy, BAx);
|
|
2440
2443
|
let endRadian = atan2$1(CBy, CBx);
|
|
2444
|
+
const lenBA = hypot(BAx, BAy);
|
|
2445
|
+
const lenCB = hypot(CBx, CBy);
|
|
2441
2446
|
let totalRadian = endRadian - startRadian;
|
|
2442
2447
|
if (totalRadian < 0) totalRadian += PI2;
|
|
2443
|
-
if (
|
|
2448
|
+
if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$6(totalRadian - PI$3) < 1e-12) {
|
|
2444
2449
|
if (data) data.push(L$a, x1, y1);
|
|
2445
2450
|
if (setPointBounds) {
|
|
2446
2451
|
setPoint$4(setPointBounds, fromX, fromY);
|
|
@@ -2473,7 +2478,7 @@ var LeaferUI = function(exports) {
|
|
|
2473
2478
|
let totalRadian = endRadian - startRadian;
|
|
2474
2479
|
if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
|
|
2475
2480
|
if (anticlockwise) totalRadian -= PI2;
|
|
2476
|
-
const parts = ceil$
|
|
2481
|
+
const parts = ceil$2(abs$6(totalRadian / PI_2));
|
|
2477
2482
|
const partRadian = totalRadian / parts;
|
|
2478
2483
|
const partRadian4Sin = sin$4(partRadian / 4);
|
|
2479
2484
|
const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
|
|
@@ -3013,11 +3018,7 @@ var LeaferUI = function(exports) {
|
|
|
3013
3018
|
this.set(path);
|
|
3014
3019
|
}
|
|
3015
3020
|
set(path) {
|
|
3016
|
-
|
|
3017
|
-
this.__path = isString(path) ? PathHelper.parse(path) : path;
|
|
3018
|
-
} else {
|
|
3019
|
-
this.__path = [];
|
|
3020
|
-
}
|
|
3021
|
+
this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
|
|
3021
3022
|
return this;
|
|
3022
3023
|
}
|
|
3023
3024
|
beginPath() {
|
|
@@ -3179,7 +3180,7 @@ var LeaferUI = function(exports) {
|
|
|
3179
3180
|
};
|
|
3180
3181
|
const {M: M$5, L: L$6, C: C$4, Q: Q$3, Z: Z$4, N: N$2, D: D$3, X: X$2, G: G$2, F: F$3, O: O$3, P: P$2, U: U$2} = PathCommandMap;
|
|
3181
3182
|
const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
|
|
3182
|
-
const {addPointBounds: addPointBounds, copy: copy$a, addPoint: addPoint$1, setPoint: setPoint$3, addBounds: addBounds, toBounds: toBounds$
|
|
3183
|
+
const {addPointBounds: addPointBounds, copy: copy$a, addPoint: addPoint$1, setPoint: setPoint$3, addBounds: addBounds, toBounds: toBounds$2} = TwoPointBoundsHelper;
|
|
3183
3184
|
const debug$d = Debug.get("PathBounds");
|
|
3184
3185
|
let radius, radiusX, radiusY;
|
|
3185
3186
|
const tempPointBounds = {};
|
|
@@ -3188,7 +3189,7 @@ var LeaferUI = function(exports) {
|
|
|
3188
3189
|
const PathBounds = {
|
|
3189
3190
|
toBounds(data, setBounds) {
|
|
3190
3191
|
PathBounds.toTwoPointBounds(data, setPointBounds);
|
|
3191
|
-
toBounds$
|
|
3192
|
+
toBounds$2(setPointBounds, setBounds);
|
|
3192
3193
|
},
|
|
3193
3194
|
toTwoPointBounds(data, setPointBounds) {
|
|
3194
3195
|
if (!data || !data.length) return setPoint$3(setPointBounds, 0, 0);
|
|
@@ -3370,10 +3371,13 @@ var LeaferUI = function(exports) {
|
|
|
3370
3371
|
return smooth;
|
|
3371
3372
|
}
|
|
3372
3373
|
};
|
|
3373
|
-
|
|
3374
|
+
function path(path) {
|
|
3375
|
+
return new PathCreator(path);
|
|
3376
|
+
}
|
|
3377
|
+
const pen = path();
|
|
3378
|
+
PathHelper.creator = path();
|
|
3374
3379
|
PathHelper.parse = PathConvert.parse;
|
|
3375
3380
|
PathHelper.convertToCanvasData = PathConvert.toCanvasData;
|
|
3376
|
-
const pen = new PathCreator;
|
|
3377
3381
|
const {drawRoundRect: drawRoundRect} = RectHelper;
|
|
3378
3382
|
function roundRect(drawer) {
|
|
3379
3383
|
if (drawer && !drawer.roundRect) {
|
|
@@ -3726,7 +3730,7 @@ var LeaferUI = function(exports) {
|
|
|
3726
3730
|
return FileHelper.alphaPixelTypes.some(item => I$1.isFormat(item, config));
|
|
3727
3731
|
},
|
|
3728
3732
|
isFormat(format, config) {
|
|
3729
|
-
if (config.format
|
|
3733
|
+
if (config.format) return config.format === format;
|
|
3730
3734
|
const {url: url} = config;
|
|
3731
3735
|
if (url.startsWith("data:")) {
|
|
3732
3736
|
if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
|
|
@@ -3816,7 +3820,7 @@ var LeaferUI = function(exports) {
|
|
|
3816
3820
|
getFull(_filters) {
|
|
3817
3821
|
return this.view;
|
|
3818
3822
|
}
|
|
3819
|
-
getCanvas(width, height, opacity, _filters, xGap, yGap) {
|
|
3823
|
+
getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
|
|
3820
3824
|
width || (width = this.width);
|
|
3821
3825
|
height || (height = this.height);
|
|
3822
3826
|
if (this.cache) {
|
|
@@ -3832,6 +3836,7 @@ var LeaferUI = function(exports) {
|
|
|
3832
3836
|
const canvas = Platform.origin.createCanvas(max$2(floor$2(width + (xGap || 0)), 1), max$2(floor$2(height + (yGap || 0)), 1));
|
|
3833
3837
|
const ctx = canvas.getContext("2d");
|
|
3834
3838
|
if (opacity) ctx.globalAlpha = opacity;
|
|
3839
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
3835
3840
|
ctx.drawImage(this.view, 0, 0, width, height);
|
|
3836
3841
|
this.cache = this.use > 1 ? {
|
|
3837
3842
|
data: canvas,
|
|
@@ -4431,8 +4436,9 @@ var LeaferUI = function(exports) {
|
|
|
4431
4436
|
};
|
|
4432
4437
|
const L$4 = LeafHelper;
|
|
4433
4438
|
const {updateAllMatrix: updateAllMatrix$4, updateMatrix: updateMatrix$4, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L$4;
|
|
4434
|
-
function getTempLocal(t,
|
|
4435
|
-
|
|
4439
|
+
function getTempLocal(t, worldPoint) {
|
|
4440
|
+
t.updateLayout();
|
|
4441
|
+
return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
|
|
4436
4442
|
}
|
|
4437
4443
|
const LeafBoundsHelper = {
|
|
4438
4444
|
worldBounds(target) {
|
|
@@ -5357,7 +5363,7 @@ var LeaferUI = function(exports) {
|
|
|
5357
5363
|
const {updateMatrix: updateMatrix$3, updateAllMatrix: updateAllMatrix$3} = LeafHelper;
|
|
5358
5364
|
const {updateBounds: updateBounds$2} = BranchHelper;
|
|
5359
5365
|
const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$7} = BoundsHelper;
|
|
5360
|
-
const {toBounds: toBounds$
|
|
5366
|
+
const {toBounds: toBounds$1} = PathBounds;
|
|
5361
5367
|
const LeafBounds = {
|
|
5362
5368
|
__updateWorldBounds() {
|
|
5363
5369
|
const layout = this.__layout;
|
|
@@ -5428,8 +5434,8 @@ var LeaferUI = function(exports) {
|
|
|
5428
5434
|
__updateBoxBounds(_secondLayout, _bounds) {
|
|
5429
5435
|
const b = this.__layout.boxBounds;
|
|
5430
5436
|
const data = this.__;
|
|
5431
|
-
if (data.
|
|
5432
|
-
toBounds$
|
|
5437
|
+
if (data.__usePathBox) {
|
|
5438
|
+
toBounds$1(data.path, b);
|
|
5433
5439
|
} else {
|
|
5434
5440
|
b.x = 0;
|
|
5435
5441
|
b.y = 0;
|
|
@@ -6344,7 +6350,7 @@ var LeaferUI = function(exports) {
|
|
|
6344
6350
|
this.levelMap = null;
|
|
6345
6351
|
}
|
|
6346
6352
|
}
|
|
6347
|
-
const version = "1.9.
|
|
6353
|
+
const version = "1.9.5";
|
|
6348
6354
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6349
6355
|
get allowBackgroundColor() {
|
|
6350
6356
|
return true;
|
|
@@ -6740,7 +6746,7 @@ var LeaferUI = function(exports) {
|
|
|
6740
6746
|
this.times = 0;
|
|
6741
6747
|
this.config = {
|
|
6742
6748
|
usePartRender: true,
|
|
6743
|
-
maxFPS:
|
|
6749
|
+
maxFPS: 120
|
|
6744
6750
|
};
|
|
6745
6751
|
this.target = target;
|
|
6746
6752
|
this.canvas = canvas;
|
|
@@ -6895,11 +6901,15 @@ var LeaferUI = function(exports) {
|
|
|
6895
6901
|
if (this.requestTime || !target) return;
|
|
6896
6902
|
if (target.parentApp) return target.parentApp.requestRender(false);
|
|
6897
6903
|
const requestTime = this.requestTime = Date.now();
|
|
6898
|
-
|
|
6899
|
-
|
|
6904
|
+
const render = () => {
|
|
6905
|
+
const nowFPS = 1e3 / (Date.now() - requestTime);
|
|
6906
|
+
const {maxFPS: maxFPS} = this.config;
|
|
6907
|
+
if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
|
|
6908
|
+
this.FPS = Math.min(120, Math.ceil(nowFPS));
|
|
6900
6909
|
this.requestTime = 0;
|
|
6901
6910
|
this.checkRender();
|
|
6902
|
-
}
|
|
6911
|
+
};
|
|
6912
|
+
Platform.requestRender(render);
|
|
6903
6913
|
}
|
|
6904
6914
|
__onResize(e) {
|
|
6905
6915
|
if (this.canvas.unreal) return;
|
|
@@ -6942,7 +6952,8 @@ var LeaferUI = function(exports) {
|
|
|
6942
6952
|
if (this.target) {
|
|
6943
6953
|
this.stop();
|
|
6944
6954
|
this.__removeListenEvents();
|
|
6945
|
-
this.
|
|
6955
|
+
this.config = {};
|
|
6956
|
+
this.target = this.canvas = null;
|
|
6946
6957
|
}
|
|
6947
6958
|
}
|
|
6948
6959
|
}
|
|
@@ -7399,7 +7410,11 @@ var LeaferUI = function(exports) {
|
|
|
7399
7410
|
}
|
|
7400
7411
|
}
|
|
7401
7412
|
class FrameData extends BoxData {}
|
|
7402
|
-
class LineData extends UIData {
|
|
7413
|
+
class LineData extends UIData {
|
|
7414
|
+
get __usePathBox() {
|
|
7415
|
+
return this.points || this.__pathInputed;
|
|
7416
|
+
}
|
|
7417
|
+
}
|
|
7403
7418
|
class RectData extends UIData {
|
|
7404
7419
|
get __boxStroke() {
|
|
7405
7420
|
return !this.__pathInputed;
|
|
@@ -7410,7 +7425,7 @@ var LeaferUI = function(exports) {
|
|
|
7410
7425
|
return !this.__pathInputed;
|
|
7411
7426
|
}
|
|
7412
7427
|
}
|
|
7413
|
-
class PolygonData extends
|
|
7428
|
+
class PolygonData extends LineData {}
|
|
7414
7429
|
class StarData extends UIData {}
|
|
7415
7430
|
class PathData extends UIData {
|
|
7416
7431
|
get __pathInputed() {
|
|
@@ -7704,20 +7719,9 @@ var LeaferUI = function(exports) {
|
|
|
7704
7719
|
if (!path) this.__drawPathByBox(pen);
|
|
7705
7720
|
return pen;
|
|
7706
7721
|
}
|
|
7707
|
-
constructor(data) {
|
|
7708
|
-
super(data);
|
|
7709
|
-
}
|
|
7710
7722
|
reset(_data) {}
|
|
7711
|
-
set(data,
|
|
7712
|
-
if (data)
|
|
7713
|
-
if (transition) {
|
|
7714
|
-
if (transition === "temp") {
|
|
7715
|
-
this.lockNormalStyle = true;
|
|
7716
|
-
Object.assign(this, data);
|
|
7717
|
-
this.lockNormalStyle = false;
|
|
7718
|
-
} else this.animate(data, transition);
|
|
7719
|
-
} else Object.assign(this, data);
|
|
7720
|
-
}
|
|
7723
|
+
set(data, _transition) {
|
|
7724
|
+
if (data) Object.assign(this, data);
|
|
7721
7725
|
}
|
|
7722
7726
|
get(name) {
|
|
7723
7727
|
return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
@@ -7763,7 +7767,7 @@ var LeaferUI = function(exports) {
|
|
|
7763
7767
|
const data = this.__;
|
|
7764
7768
|
if (data.path) {
|
|
7765
7769
|
data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
|
|
7766
|
-
if (data.__useArrow) PathArrow.addArrows(this
|
|
7770
|
+
if (data.__useArrow) PathArrow.addArrows(this);
|
|
7767
7771
|
} else data.__pathForRender && (data.__pathForRender = undefined);
|
|
7768
7772
|
}
|
|
7769
7773
|
__drawRenderPath(canvas) {
|
|
@@ -7787,7 +7791,8 @@ var LeaferUI = function(exports) {
|
|
|
7787
7791
|
drawImagePlaceholder(canvas, _image) {
|
|
7788
7792
|
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
7789
7793
|
}
|
|
7790
|
-
animate(
|
|
7794
|
+
animate(keyframe, _options, _type, _isTemp) {
|
|
7795
|
+
this.set(keyframe);
|
|
7791
7796
|
return Plugin.need("animate");
|
|
7792
7797
|
}
|
|
7793
7798
|
killAnimate(_type, _nextStyle) {}
|
|
@@ -7901,9 +7906,6 @@ var LeaferUI = function(exports) {
|
|
|
7901
7906
|
get isBranch() {
|
|
7902
7907
|
return true;
|
|
7903
7908
|
}
|
|
7904
|
-
constructor(data) {
|
|
7905
|
-
super(data);
|
|
7906
|
-
}
|
|
7907
7909
|
reset(data) {
|
|
7908
7910
|
this.__setBranch();
|
|
7909
7911
|
super.reset(data);
|
|
@@ -8021,7 +8023,7 @@ var LeaferUI = function(exports) {
|
|
|
8021
8023
|
const canvas = this.canvas = Creator.canvas(config);
|
|
8022
8024
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
8023
8025
|
if (this.isApp) this.__setApp();
|
|
8024
|
-
this.__checkAutoLayout(
|
|
8026
|
+
this.__checkAutoLayout();
|
|
8025
8027
|
this.view = canvas.view;
|
|
8026
8028
|
if (!parentApp) {
|
|
8027
8029
|
this.selector = Creator.selector(this);
|
|
@@ -8120,7 +8122,8 @@ var LeaferUI = function(exports) {
|
|
|
8120
8122
|
this.leafer = leafer;
|
|
8121
8123
|
this.__level = 1;
|
|
8122
8124
|
}
|
|
8123
|
-
__checkAutoLayout(
|
|
8125
|
+
__checkAutoLayout() {
|
|
8126
|
+
const {config: config, parentApp: parentApp} = this;
|
|
8124
8127
|
if (!parentApp) {
|
|
8125
8128
|
if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
|
|
8126
8129
|
this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
|
|
@@ -8146,9 +8149,10 @@ var LeaferUI = function(exports) {
|
|
|
8146
8149
|
return super.__getAttr(attrName);
|
|
8147
8150
|
}
|
|
8148
8151
|
__changeCanvasSize(attrName, newValue) {
|
|
8149
|
-
const
|
|
8150
|
-
data
|
|
8151
|
-
|
|
8152
|
+
const {config: config, canvas: canvas} = this;
|
|
8153
|
+
const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
|
|
8154
|
+
data[attrName] = config[attrName] = newValue;
|
|
8155
|
+
config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
|
|
8152
8156
|
this.__doResize(data);
|
|
8153
8157
|
}
|
|
8154
8158
|
__changeFill(newValue) {
|
|
@@ -8295,9 +8299,9 @@ var LeaferUI = function(exports) {
|
|
|
8295
8299
|
if (!this.parent) {
|
|
8296
8300
|
if (this.selector) this.selector.destroy();
|
|
8297
8301
|
if (this.hitCanvasManager) this.hitCanvasManager.destroy();
|
|
8298
|
-
this.canvasManager.destroy();
|
|
8302
|
+
if (this.canvasManager) this.canvasManager.destroy();
|
|
8299
8303
|
}
|
|
8300
|
-
this.canvas.destroy();
|
|
8304
|
+
if (this.canvas) this.canvas.destroy();
|
|
8301
8305
|
this.config.view = this.view = this.parentApp = null;
|
|
8302
8306
|
if (this.userConfig) this.userConfig.view = null;
|
|
8303
8307
|
super.destroy();
|
|
@@ -8320,9 +8324,6 @@ var LeaferUI = function(exports) {
|
|
|
8320
8324
|
get __tag() {
|
|
8321
8325
|
return "Rect";
|
|
8322
8326
|
}
|
|
8323
|
-
constructor(data) {
|
|
8324
|
-
super(data);
|
|
8325
|
-
}
|
|
8326
8327
|
};
|
|
8327
8328
|
__decorate([ dataProcessor(RectData) ], exports.Rect.prototype, "__", void 0);
|
|
8328
8329
|
exports.Rect = __decorate([ useModule(RectRender), rewriteAble(), registerUI() ], exports.Rect);
|
|
@@ -8434,9 +8435,6 @@ var LeaferUI = function(exports) {
|
|
|
8434
8435
|
get isFrame() {
|
|
8435
8436
|
return true;
|
|
8436
8437
|
}
|
|
8437
|
-
constructor(data) {
|
|
8438
|
-
super(data);
|
|
8439
|
-
}
|
|
8440
8438
|
};
|
|
8441
8439
|
__decorate([ dataProcessor(FrameData) ], exports.Frame.prototype, "__", void 0);
|
|
8442
8440
|
__decorate([ surfaceType("#FFFFFF") ], exports.Frame.prototype, "fill", void 0);
|
|
@@ -8447,9 +8445,6 @@ var LeaferUI = function(exports) {
|
|
|
8447
8445
|
get __tag() {
|
|
8448
8446
|
return "Ellipse";
|
|
8449
8447
|
}
|
|
8450
|
-
constructor(data) {
|
|
8451
|
-
super(data);
|
|
8452
|
-
}
|
|
8453
8448
|
__updatePath() {
|
|
8454
8449
|
const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
|
|
8455
8450
|
const rx = width / 2, ry = height / 2;
|
|
@@ -8485,7 +8480,6 @@ var LeaferUI = function(exports) {
|
|
|
8485
8480
|
exports.Ellipse = __decorate([ registerUI() ], exports.Ellipse);
|
|
8486
8481
|
const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
|
|
8487
8482
|
const {rotate: rotate$3, getAngle: getAngle$2, getDistance: getDistance$3, defaultPoint: defaultPoint} = PointHelper;
|
|
8488
|
-
const {toBounds: toBounds$1} = PathBounds;
|
|
8489
8483
|
exports.Line = class Line extends exports.UI {
|
|
8490
8484
|
get __tag() {
|
|
8491
8485
|
return "Line";
|
|
@@ -8502,31 +8496,16 @@ var LeaferUI = function(exports) {
|
|
|
8502
8496
|
this.rotation = getAngle$2(defaultPoint, value);
|
|
8503
8497
|
if (this.height) this.height = 0;
|
|
8504
8498
|
}
|
|
8505
|
-
constructor(data) {
|
|
8506
|
-
super(data);
|
|
8507
|
-
}
|
|
8508
8499
|
__updatePath() {
|
|
8509
8500
|
const data = this.__;
|
|
8510
8501
|
const path = data.path = [];
|
|
8511
8502
|
if (data.points) {
|
|
8512
|
-
drawPoints$1(path, data.points,
|
|
8503
|
+
drawPoints$1(path, data.points, data.curve, data.closed);
|
|
8513
8504
|
} else {
|
|
8514
8505
|
moveTo$2(path, 0, 0);
|
|
8515
8506
|
lineTo$2(path, this.width, 0);
|
|
8516
8507
|
}
|
|
8517
8508
|
}
|
|
8518
|
-
__updateRenderPath() {
|
|
8519
|
-
const data = this.__;
|
|
8520
|
-
if (!this.pathInputed && data.points && data.curve) {
|
|
8521
|
-
drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
|
|
8522
|
-
if (data.__useArrow) PathArrow.addArrows(this, false);
|
|
8523
|
-
} else super.__updateRenderPath();
|
|
8524
|
-
}
|
|
8525
|
-
__updateBoxBounds() {
|
|
8526
|
-
if (this.points) {
|
|
8527
|
-
toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
|
|
8528
|
-
} else super.__updateBoxBounds();
|
|
8529
|
-
}
|
|
8530
8509
|
};
|
|
8531
8510
|
__decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
|
|
8532
8511
|
__decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
|
|
@@ -8542,15 +8521,13 @@ var LeaferUI = function(exports) {
|
|
|
8542
8521
|
get __tag() {
|
|
8543
8522
|
return "Polygon";
|
|
8544
8523
|
}
|
|
8545
|
-
constructor(data) {
|
|
8546
|
-
super(data);
|
|
8547
|
-
}
|
|
8548
8524
|
__updatePath() {
|
|
8549
|
-
const
|
|
8550
|
-
|
|
8551
|
-
|
|
8525
|
+
const data = this.__;
|
|
8526
|
+
const path = data.path = [];
|
|
8527
|
+
if (data.points) {
|
|
8528
|
+
drawPoints(path, data.points, data.curve, true);
|
|
8552
8529
|
} else {
|
|
8553
|
-
const {width: width, height: height, sides: sides} =
|
|
8530
|
+
const {width: width, height: height, sides: sides} = data;
|
|
8554
8531
|
const rx = width / 2, ry = height / 2;
|
|
8555
8532
|
moveTo$1(path, rx, 0);
|
|
8556
8533
|
for (let i = 1; i < sides; i++) {
|
|
@@ -8575,9 +8552,6 @@ var LeaferUI = function(exports) {
|
|
|
8575
8552
|
get __tag() {
|
|
8576
8553
|
return "Star";
|
|
8577
8554
|
}
|
|
8578
|
-
constructor(data) {
|
|
8579
|
-
super(data);
|
|
8580
|
-
}
|
|
8581
8555
|
__updatePath() {
|
|
8582
8556
|
const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
|
|
8583
8557
|
const rx = width / 2, ry = height / 2;
|
|
@@ -8605,9 +8579,6 @@ var LeaferUI = function(exports) {
|
|
|
8605
8579
|
const {fill: fill} = this.__;
|
|
8606
8580
|
return isArray(fill) && fill[0].image;
|
|
8607
8581
|
}
|
|
8608
|
-
constructor(data) {
|
|
8609
|
-
super(data);
|
|
8610
|
-
}
|
|
8611
8582
|
};
|
|
8612
8583
|
__decorate([ dataProcessor(ImageData) ], exports.Image.prototype, "__", void 0);
|
|
8613
8584
|
__decorate([ boundsType("") ], exports.Image.prototype, "url", void 0);
|
|
@@ -8692,9 +8663,6 @@ var LeaferUI = function(exports) {
|
|
|
8692
8663
|
this.updateLayout();
|
|
8693
8664
|
return this.__.__textDrawData;
|
|
8694
8665
|
}
|
|
8695
|
-
constructor(data) {
|
|
8696
|
-
super(data);
|
|
8697
|
-
}
|
|
8698
8666
|
__updateTextDrawData() {
|
|
8699
8667
|
const data = this.__;
|
|
8700
8668
|
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
@@ -8798,9 +8766,6 @@ var LeaferUI = function(exports) {
|
|
|
8798
8766
|
get __tag() {
|
|
8799
8767
|
return "Path";
|
|
8800
8768
|
}
|
|
8801
|
-
constructor(data) {
|
|
8802
|
-
super(data);
|
|
8803
|
-
}
|
|
8804
8769
|
};
|
|
8805
8770
|
__decorate([ dataProcessor(PathData) ], exports.Path.prototype, "__", void 0);
|
|
8806
8771
|
__decorate([ affectStrokeBoundsType("center") ], exports.Path.prototype, "strokeAlign", void 0);
|
|
@@ -8809,9 +8774,6 @@ var LeaferUI = function(exports) {
|
|
|
8809
8774
|
get __tag() {
|
|
8810
8775
|
return "Pen";
|
|
8811
8776
|
}
|
|
8812
|
-
constructor(data) {
|
|
8813
|
-
super(data);
|
|
8814
|
-
}
|
|
8815
8777
|
setStyle(data) {
|
|
8816
8778
|
const path = this.pathElement = new exports.Path(data);
|
|
8817
8779
|
this.pathStyle = data;
|
|
@@ -10730,7 +10692,7 @@ var LeaferUI = function(exports) {
|
|
|
10730
10692
|
if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
|
|
10731
10693
|
}
|
|
10732
10694
|
const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
|
|
10733
|
-
const {floor: floor$1, max: max$1, abs: abs$4} = Math;
|
|
10695
|
+
const {floor: floor$1, ceil: ceil$1, max: max$1, abs: abs$4} = Math;
|
|
10734
10696
|
function createPattern(ui, paint, pixelRatio) {
|
|
10735
10697
|
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
10736
10698
|
const id = scaleX + "-" + scaleY + "-" + pixelRatio;
|
|
@@ -10739,8 +10701,6 @@ var LeaferUI = function(exports) {
|
|
|
10739
10701
|
let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
|
|
10740
10702
|
scaleX *= pixelRatio;
|
|
10741
10703
|
scaleY *= pixelRatio;
|
|
10742
|
-
const xGap = gap && gap.x * scaleX;
|
|
10743
|
-
const yGap = gap && gap.y * scaleY;
|
|
10744
10704
|
if (sx) {
|
|
10745
10705
|
sx = abs$4(sx);
|
|
10746
10706
|
sy = abs$4(sy);
|
|
@@ -10757,7 +10717,10 @@ var LeaferUI = function(exports) {
|
|
|
10757
10717
|
if (size > Platform.image.maxCacheSize) return false;
|
|
10758
10718
|
}
|
|
10759
10719
|
let maxSize = Platform.image.maxPatternSize;
|
|
10760
|
-
if (
|
|
10720
|
+
if (image.isSVG) {
|
|
10721
|
+
const ws = width / image.width;
|
|
10722
|
+
if (ws > 1) imageScale = ws / ceil$1(ws);
|
|
10723
|
+
} else {
|
|
10761
10724
|
const imageSize = image.width * image.height;
|
|
10762
10725
|
if (maxSize > imageSize) maxSize = imageSize;
|
|
10763
10726
|
}
|
|
@@ -10772,18 +10735,20 @@ var LeaferUI = function(exports) {
|
|
|
10772
10735
|
scaleX /= sx;
|
|
10773
10736
|
scaleY /= sy;
|
|
10774
10737
|
}
|
|
10738
|
+
const xGap = gap && gap.x * scaleX;
|
|
10739
|
+
const yGap = gap && gap.y * scaleY;
|
|
10775
10740
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10741
|
+
const canvasWidth = width + (xGap || 0);
|
|
10742
|
+
const canvasHeight = height + (yGap || 0);
|
|
10743
|
+
scaleX /= canvasWidth / max$1(floor$1(canvasWidth), 1);
|
|
10744
|
+
scaleY /= canvasHeight / max$1(floor$1(canvasHeight), 1);
|
|
10776
10745
|
if (!imageMatrix) {
|
|
10777
10746
|
imageMatrix = get$1();
|
|
10778
10747
|
if (transform) copy$4(imageMatrix, transform);
|
|
10779
10748
|
}
|
|
10780
10749
|
scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10781
10750
|
}
|
|
10782
|
-
|
|
10783
|
-
const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
|
|
10784
|
-
scale$2(imageMatrix, canvasWidth / max$1(floor$1(canvasWidth), 1), canvasHeight / max$1(floor$1(canvasHeight), 1));
|
|
10785
|
-
}
|
|
10786
|
-
const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
|
|
10751
|
+
const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
|
|
10787
10752
|
const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10788
10753
|
paint.style = pattern;
|
|
10789
10754
|
paint.patternId = id;
|
|
@@ -14508,7 +14473,8 @@ var LeaferUI = function(exports) {
|
|
|
14508
14473
|
if (zoom) {
|
|
14509
14474
|
zoomSpeed = within$2(zoomSpeed, 0, 1);
|
|
14510
14475
|
const min = event.deltaY ? config.delta.y : config.delta.x;
|
|
14511
|
-
|
|
14476
|
+
const absScale = within$2(1 - abs$2(delta) / (min * 4) * zoomSpeed, .5, 2);
|
|
14477
|
+
scale = delta > 0 ? absScale : 1 / absScale;
|
|
14512
14478
|
}
|
|
14513
14479
|
return scale;
|
|
14514
14480
|
}
|
|
@@ -15021,6 +14987,9 @@ var LeaferUI = function(exports) {
|
|
|
15021
14987
|
super(data);
|
|
15022
14988
|
this.__.__useArrow = true;
|
|
15023
14989
|
}
|
|
14990
|
+
static registerArrow(name, data) {
|
|
14991
|
+
PathArrow.register(name, data);
|
|
14992
|
+
}
|
|
15024
14993
|
};
|
|
15025
14994
|
__decorate([ dataProcessor(ArrowData) ], exports.Arrow.prototype, "__", void 0);
|
|
15026
14995
|
__decorate([ arrowType("angle") ], exports.Arrow.prototype, "endArrow", void 0);
|
|
@@ -15172,9 +15141,18 @@ var LeaferUI = function(exports) {
|
|
|
15172
15141
|
"diamond-line": diamondLine,
|
|
15173
15142
|
mark: mark
|
|
15174
15143
|
};
|
|
15175
|
-
function getArrowPath(ui, arrow, from, to,
|
|
15144
|
+
function getArrowPath(ui, arrow, from, to, size, connectOffset, hasDashPattern) {
|
|
15145
|
+
let pathData, scale;
|
|
15176
15146
|
const {strokeCap: strokeCap, strokeJoin: strokeJoin} = ui.__;
|
|
15177
|
-
|
|
15147
|
+
if (isObject(arrow)) {
|
|
15148
|
+
if (arrow.type) {
|
|
15149
|
+
scale = arrow.scale;
|
|
15150
|
+
pathData = arrows[arrow.type];
|
|
15151
|
+
} else pathData = arrow;
|
|
15152
|
+
} else {
|
|
15153
|
+
pathData = arrows[arrow];
|
|
15154
|
+
}
|
|
15155
|
+
const {offset: offset, connect: connect, path: path, dashPath: dashPath} = pathData;
|
|
15178
15156
|
let connectX = connect ? connect.x : 0;
|
|
15179
15157
|
let offsetX = offset ? offset.x : 0;
|
|
15180
15158
|
const data = [ ...path ];
|
|
@@ -15183,9 +15161,10 @@ var LeaferUI = function(exports) {
|
|
|
15183
15161
|
if (offset) {
|
|
15184
15162
|
if (strokeJoin === "round" && offset.roundJoin) offsetX += offset.roundJoin; else if (strokeJoin === "bevel" && offset.bevelJoin) offsetX += offset.bevelJoin;
|
|
15185
15163
|
}
|
|
15164
|
+
if (scale) layout$2(data, 0, 0, scale, scale);
|
|
15186
15165
|
if (offsetX) layout$2(data, offsetX, 0);
|
|
15187
|
-
layout$2(data, to.x, to.y,
|
|
15188
|
-
connectOffset.x = (connectX + offsetX) *
|
|
15166
|
+
layout$2(data, to.x, to.y, size, size, getAngle(from, to));
|
|
15167
|
+
connectOffset.x = (connectX + offsetX) * size;
|
|
15189
15168
|
return data;
|
|
15190
15169
|
}
|
|
15191
15170
|
const {M: M$1, L: L$1, C: C$1, Q: Q, Z: Z$1, N: N, D: D, X: X, G: G, F: F, O: O, P: P, U: U} = PathCommandMap;
|
|
@@ -15195,8 +15174,9 @@ var LeaferUI = function(exports) {
|
|
|
15195
15174
|
const last = {}, now = {};
|
|
15196
15175
|
const PathArrowModule = {
|
|
15197
15176
|
list: arrows,
|
|
15198
|
-
addArrows(ui
|
|
15199
|
-
const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data} = ui.__;
|
|
15177
|
+
addArrows(ui) {
|
|
15178
|
+
const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data, cornerRadius: cornerRadius} = ui.__;
|
|
15179
|
+
const clonePathForArrow = !cornerRadius;
|
|
15200
15180
|
let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== "none";
|
|
15201
15181
|
while (i < len) {
|
|
15202
15182
|
command = data[i];
|
|
@@ -15211,12 +15191,12 @@ var LeaferUI = function(exports) {
|
|
|
15211
15191
|
break;
|
|
15212
15192
|
|
|
15213
15193
|
case C$1:
|
|
15214
|
-
if (count === 1 || i + 7
|
|
15194
|
+
if (count === 1 || i + 7 >= len - 3) copyPoints(data, last, now, i + 3);
|
|
15215
15195
|
i += 7;
|
|
15216
15196
|
break;
|
|
15217
15197
|
|
|
15218
15198
|
case Q:
|
|
15219
|
-
if (count === 1 || i + 5
|
|
15199
|
+
if (count === 1 || i + 5 >= len - 3) copyPoints(data, last, now, i + 1);
|
|
15220
15200
|
i += 5;
|
|
15221
15201
|
break;
|
|
15222
15202
|
|
|
@@ -15252,7 +15232,13 @@ var LeaferUI = function(exports) {
|
|
|
15252
15232
|
break;
|
|
15253
15233
|
|
|
15254
15234
|
case U:
|
|
15255
|
-
if (count === 1 || i + 6
|
|
15235
|
+
if (count === 1 || i + 6 >= len - 3) {
|
|
15236
|
+
copyPoints(data, last, now, i + 1);
|
|
15237
|
+
if (i + 6 !== len) {
|
|
15238
|
+
now.x -= (now.x - last.x) / 10;
|
|
15239
|
+
now.y -= (now.y - last.y) / 10;
|
|
15240
|
+
}
|
|
15241
|
+
}
|
|
15256
15242
|
i += 6;
|
|
15257
15243
|
break;
|
|
15258
15244
|
}
|
|
@@ -15260,7 +15246,7 @@ var LeaferUI = function(exports) {
|
|
|
15260
15246
|
if (count === 1 && command !== M$1) return;
|
|
15261
15247
|
if (count === 2 && useStartArrow) copy(second, command === L$1 ? now : last);
|
|
15262
15248
|
if (i === len) {
|
|
15263
|
-
const path = ui.__.__pathForRender =
|
|
15249
|
+
const path = ui.__.__pathForRender = clonePathForArrow ? [ ...data ] : data;
|
|
15264
15250
|
const pathForArrow = ui.__.__pathForArrow = [];
|
|
15265
15251
|
if (useStartArrow) {
|
|
15266
15252
|
const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
|
|
@@ -15301,6 +15287,12 @@ var LeaferUI = function(exports) {
|
|
|
15301
15287
|
copy(last, now);
|
|
15302
15288
|
}
|
|
15303
15289
|
}
|
|
15290
|
+
},
|
|
15291
|
+
register(name, data) {
|
|
15292
|
+
this.list[name] = data;
|
|
15293
|
+
},
|
|
15294
|
+
get(name) {
|
|
15295
|
+
return this.list[name];
|
|
15304
15296
|
}
|
|
15305
15297
|
};
|
|
15306
15298
|
function copyPoints(data, from, to, startIndex) {
|
|
@@ -16727,6 +16719,17 @@ var LeaferUI = function(exports) {
|
|
|
16727
16719
|
exports.UI.addAttr("animationOut", undefined, dataType);
|
|
16728
16720
|
exports.UI.addAttr("transition", true, dataType);
|
|
16729
16721
|
exports.UI.addAttr("transitionOut", undefined, dataType);
|
|
16722
|
+
ui$3.set = function(data, transition) {
|
|
16723
|
+
if (data) {
|
|
16724
|
+
if (transition) {
|
|
16725
|
+
if (transition === "temp") {
|
|
16726
|
+
this.lockNormalStyle = true;
|
|
16727
|
+
Object.assign(this, data);
|
|
16728
|
+
this.lockNormalStyle = false;
|
|
16729
|
+
} else this.animate(data, transition);
|
|
16730
|
+
} else Object.assign(this, data);
|
|
16731
|
+
}
|
|
16732
|
+
};
|
|
16730
16733
|
ui$3.animate = function(keyframe, options, kill, isTemp) {
|
|
16731
16734
|
if (isUndefined(keyframe)) return this.__animate;
|
|
16732
16735
|
const isAnimationList = isArray(keyframe) && !options && kill;
|
|
@@ -18118,6 +18121,7 @@ var LeaferUI = function(exports) {
|
|
|
18118
18121
|
exports.motionPathType = motionPathType;
|
|
18119
18122
|
exports.naturalBoundsType = naturalBoundsType;
|
|
18120
18123
|
exports.opacityType = opacityType;
|
|
18124
|
+
exports.path = path;
|
|
18121
18125
|
exports.pathInputType = pathInputType;
|
|
18122
18126
|
exports.pathType = pathType;
|
|
18123
18127
|
exports.pen = pen;
|