@leafer-draw/worker 1.12.0 → 1.12.2
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.cjs +5 -3
- package/dist/worker.esm.js +5 -3
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +94 -34
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +95 -34
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/worker.module.js
CHANGED
|
@@ -461,7 +461,7 @@ function getMatrixData() {
|
|
|
461
461
|
|
|
462
462
|
const {sin: sin$5, cos: cos$5, acos: acos, sqrt: sqrt$3} = Math;
|
|
463
463
|
|
|
464
|
-
const {float: float$
|
|
464
|
+
const {float: float$2} = MathHelper;
|
|
465
465
|
|
|
466
466
|
const tempPoint$3 = {};
|
|
467
467
|
|
|
@@ -712,12 +712,12 @@ const MatrixHelper = {
|
|
|
712
712
|
const cosR = c / scaleY;
|
|
713
713
|
rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
|
|
714
714
|
}
|
|
715
|
-
const cosR = float$
|
|
715
|
+
const cosR = float$2(cos$5(rotation));
|
|
716
716
|
const sinR = sin$5(rotation);
|
|
717
|
-
scaleX = float$
|
|
718
|
-
skewX = cosR ? float$
|
|
719
|
-
skewY = cosR ? float$
|
|
720
|
-
rotation = float$
|
|
717
|
+
scaleX = float$2(scaleX), scaleY = float$2(scaleY);
|
|
718
|
+
skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
|
|
719
|
+
skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
|
|
720
|
+
rotation = float$2(rotation / OneRadian);
|
|
721
721
|
} else {
|
|
722
722
|
scaleX = a;
|
|
723
723
|
scaleY = d;
|
|
@@ -761,6 +761,8 @@ const MatrixHelper = {
|
|
|
761
761
|
|
|
762
762
|
const M$6 = MatrixHelper;
|
|
763
763
|
|
|
764
|
+
const {float: float$1} = MathHelper;
|
|
765
|
+
|
|
764
766
|
const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
|
|
765
767
|
|
|
766
768
|
const {sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2} = Math;
|
|
@@ -828,6 +830,11 @@ const PointHelper = {
|
|
|
828
830
|
P$5.toInnerRadiusPointOf(t, matrix, temp);
|
|
829
831
|
return temp;
|
|
830
832
|
},
|
|
833
|
+
copyRadiusPoint(t, point, x, y) {
|
|
834
|
+
copy$9(t, point);
|
|
835
|
+
setRadius(t, x, y);
|
|
836
|
+
return t;
|
|
837
|
+
},
|
|
831
838
|
toInnerRadiusPointOf(t, matrix, to) {
|
|
832
839
|
to || (to = t);
|
|
833
840
|
toInnerPoint$2(matrix, t, to);
|
|
@@ -895,7 +902,7 @@ const PointHelper = {
|
|
|
895
902
|
return points;
|
|
896
903
|
},
|
|
897
904
|
isSame(t, point) {
|
|
898
|
-
return t.x === point.x && t.y === point.y;
|
|
905
|
+
return float$1(t.x) === float$1(point.x) && float$1(t.y) === float$1(point.y);
|
|
899
906
|
},
|
|
900
907
|
reset(t) {
|
|
901
908
|
P$5.reset(t);
|
|
@@ -904,7 +911,7 @@ const PointHelper = {
|
|
|
904
911
|
|
|
905
912
|
const P$5 = PointHelper;
|
|
906
913
|
|
|
907
|
-
const {getDistanceFrom: getDistanceFrom, copy: copy$9, getAtan2: getAtan2} = P$5;
|
|
914
|
+
const {getDistanceFrom: getDistanceFrom, copy: copy$9, setRadius: setRadius, getAtan2: getAtan2} = P$5;
|
|
908
915
|
|
|
909
916
|
class Point {
|
|
910
917
|
constructor(x, y) {
|
|
@@ -2407,7 +2414,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2407
2414
|
const {pixelRatio: pixelRatio} = this;
|
|
2408
2415
|
this.filter = `blur(${blur * pixelRatio}px)`;
|
|
2409
2416
|
}
|
|
2410
|
-
copyWorld(canvas, from, to, blendMode, ceilPixel
|
|
2417
|
+
copyWorld(canvas, from, to, blendMode, ceilPixel) {
|
|
2411
2418
|
if (blendMode) this.blendMode = blendMode;
|
|
2412
2419
|
if (from) {
|
|
2413
2420
|
this.setTempPixelBounds(from, ceilPixel);
|
|
@@ -2418,7 +2425,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2418
2425
|
}
|
|
2419
2426
|
if (blendMode) this.blendMode = "source-over";
|
|
2420
2427
|
}
|
|
2421
|
-
copyWorldToInner(canvas, fromWorld, toInnerBounds, blendMode, ceilPixel
|
|
2428
|
+
copyWorldToInner(canvas, fromWorld, toInnerBounds, blendMode, ceilPixel) {
|
|
2422
2429
|
if (fromWorld.b || fromWorld.c) {
|
|
2423
2430
|
this.save();
|
|
2424
2431
|
this.resetTransform();
|
|
@@ -2431,7 +2438,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2431
2438
|
if (blendMode) this.blendMode = "source-over";
|
|
2432
2439
|
}
|
|
2433
2440
|
}
|
|
2434
|
-
copyWorldByReset(canvas, from, to, blendMode, onlyResetTransform, ceilPixel
|
|
2441
|
+
copyWorldByReset(canvas, from, to, blendMode, onlyResetTransform, ceilPixel) {
|
|
2435
2442
|
this.resetTransform();
|
|
2436
2443
|
this.copyWorld(canvas, from, to, blendMode, ceilPixel);
|
|
2437
2444
|
if (!onlyResetTransform) this.useWorldTransform();
|
|
@@ -2658,7 +2665,7 @@ const BezierHelper = {
|
|
|
2658
2665
|
data.push(M$5, points[0], points[1]);
|
|
2659
2666
|
if (curve && points.length > 5) {
|
|
2660
2667
|
let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
|
|
2661
|
-
let ba, cb, d, len = points.length;
|
|
2668
|
+
let baX, baY, ba, cb, d, len = points.length;
|
|
2662
2669
|
const t = curve === true ? .5 : curve;
|
|
2663
2670
|
if (close) {
|
|
2664
2671
|
points = [ points[len - 2], points[len - 1], ...points, points[0], points[1], points[2], points[3] ];
|
|
@@ -2671,7 +2678,9 @@ const BezierHelper = {
|
|
|
2671
2678
|
bY = points[i + 1];
|
|
2672
2679
|
cX = points[i + 2];
|
|
2673
2680
|
cY = points[i + 3];
|
|
2674
|
-
|
|
2681
|
+
baX = bX - aX;
|
|
2682
|
+
baY = bY - aY;
|
|
2683
|
+
ba = sqrt$1(pow(baX, 2) + pow(baY, 2));
|
|
2675
2684
|
cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
|
|
2676
2685
|
if (!ba && !cb) continue;
|
|
2677
2686
|
d = ba + cb;
|
|
@@ -2684,7 +2693,7 @@ const BezierHelper = {
|
|
|
2684
2693
|
if (i === 2) {
|
|
2685
2694
|
if (!close) data.push(Q$4, c1X, c1Y, bX, bY);
|
|
2686
2695
|
} else {
|
|
2687
|
-
data.push(C$4, c2X, c2Y, c1X, c1Y, bX, bY);
|
|
2696
|
+
if (baX || baY) data.push(C$4, c2X, c2Y, c1X, c1Y, bX, bY);
|
|
2688
2697
|
}
|
|
2689
2698
|
c2X = bX + cb * cX;
|
|
2690
2699
|
c2Y = bY + cb * cY;
|
|
@@ -3269,6 +3278,7 @@ const PathCommandDataHelper = {
|
|
|
3269
3278
|
}
|
|
3270
3279
|
},
|
|
3271
3280
|
ellipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
3281
|
+
if (radiusX === radiusY) return arc$2(data, x, y, radiusX, startAngle, endAngle, anticlockwise);
|
|
3272
3282
|
if (isNull(rotation)) {
|
|
3273
3283
|
data.push(F$3, x, y, radiusX, radiusY);
|
|
3274
3284
|
} else {
|
|
@@ -3281,6 +3291,7 @@ const PathCommandDataHelper = {
|
|
|
3281
3291
|
if (isNull(startAngle)) {
|
|
3282
3292
|
data.push(P$2, x, y, radius);
|
|
3283
3293
|
} else {
|
|
3294
|
+
if (isNull(startAngle)) startAngle = 0;
|
|
3284
3295
|
if (isNull(endAngle)) endAngle = 360;
|
|
3285
3296
|
data.push(O$2, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
|
|
3286
3297
|
}
|
|
@@ -3631,6 +3642,7 @@ const PathCorner = {
|
|
|
3631
3642
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3632
3643
|
let command, lastCommand, commandLen;
|
|
3633
3644
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3645
|
+
if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
|
|
3634
3646
|
const len = data.length;
|
|
3635
3647
|
const smooth = [];
|
|
3636
3648
|
while (i < len) {
|
|
@@ -4046,7 +4058,9 @@ const R = Resource;
|
|
|
4046
4058
|
const ImageManager = {
|
|
4047
4059
|
maxRecycled: 10,
|
|
4048
4060
|
recycledList: [],
|
|
4049
|
-
patternTasker: new TaskProcessor
|
|
4061
|
+
patternTasker: new TaskProcessor({
|
|
4062
|
+
parallel: 1
|
|
4063
|
+
}),
|
|
4050
4064
|
get(config) {
|
|
4051
4065
|
let image = Resource.get(config.url);
|
|
4052
4066
|
if (!image) Resource.set(config.url, image = Creator.image(config));
|
|
@@ -4951,10 +4965,53 @@ const BranchHelper = {
|
|
|
4951
4965
|
if (exclude && exclude === branch) continue;
|
|
4952
4966
|
updateBounds$3(branch);
|
|
4953
4967
|
}
|
|
4968
|
+
},
|
|
4969
|
+
move(branch, x, y) {
|
|
4970
|
+
let w;
|
|
4971
|
+
const {children: children} = branch;
|
|
4972
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
4973
|
+
branch = children[i];
|
|
4974
|
+
w = branch.__world;
|
|
4975
|
+
w.e += x;
|
|
4976
|
+
w.f += y;
|
|
4977
|
+
w.x += x;
|
|
4978
|
+
w.y += y;
|
|
4979
|
+
if (branch.isBranch) move$3(branch, x, y);
|
|
4980
|
+
}
|
|
4981
|
+
},
|
|
4982
|
+
scale(branch, x, y, scaleX, scaleY, a, b) {
|
|
4983
|
+
let w;
|
|
4984
|
+
const {children: children} = branch;
|
|
4985
|
+
const changeScaleX = scaleX - 1;
|
|
4986
|
+
const changeScaleY = scaleY - 1;
|
|
4987
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
4988
|
+
branch = children[i];
|
|
4989
|
+
w = branch.__world;
|
|
4990
|
+
w.a *= scaleX;
|
|
4991
|
+
w.d *= scaleY;
|
|
4992
|
+
if (w.b || w.c) {
|
|
4993
|
+
w.b *= scaleX;
|
|
4994
|
+
w.c *= scaleY;
|
|
4995
|
+
}
|
|
4996
|
+
if (w.e === w.x && w.f === w.y) {
|
|
4997
|
+
w.x = w.e += (w.e - a) * changeScaleX + x;
|
|
4998
|
+
w.y = w.f += (w.f - b) * changeScaleY + y;
|
|
4999
|
+
} else {
|
|
5000
|
+
w.e += (w.e - a) * changeScaleX + x;
|
|
5001
|
+
w.f += (w.f - b) * changeScaleY + y;
|
|
5002
|
+
w.x += (w.x - a) * changeScaleX + x;
|
|
5003
|
+
w.y += (w.y - b) * changeScaleY + y;
|
|
5004
|
+
}
|
|
5005
|
+
w.width *= scaleX;
|
|
5006
|
+
w.height *= scaleY;
|
|
5007
|
+
w.scaleX *= scaleX;
|
|
5008
|
+
w.scaleY *= scaleY;
|
|
5009
|
+
if (branch.isBranch) scale$1(branch, x, y, scaleX, scaleY, a, b);
|
|
5010
|
+
}
|
|
4954
5011
|
}
|
|
4955
5012
|
};
|
|
4956
5013
|
|
|
4957
|
-
const {pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack: pushAllBranchStack, updateBoundsByBranchStack: updateBoundsByBranchStack} = BranchHelper;
|
|
5014
|
+
const {pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack: pushAllBranchStack, updateBoundsByBranchStack: updateBoundsByBranchStack, move: move$3, scale: scale$1} = BranchHelper;
|
|
4958
5015
|
|
|
4959
5016
|
const WaitHelper = {
|
|
4960
5017
|
run(wait) {
|
|
@@ -6518,10 +6575,10 @@ let Leaf = class Leaf {
|
|
|
6518
6575
|
hit(_world, _hitRadius) {
|
|
6519
6576
|
return true;
|
|
6520
6577
|
}
|
|
6521
|
-
__hitWorld(_point) {
|
|
6578
|
+
__hitWorld(_point, _forceHitFill) {
|
|
6522
6579
|
return true;
|
|
6523
6580
|
}
|
|
6524
|
-
__hit(_local) {
|
|
6581
|
+
__hit(_local, _forceHitFill) {
|
|
6525
6582
|
return true;
|
|
6526
6583
|
}
|
|
6527
6584
|
__hitFill(_inner) {
|
|
@@ -6880,7 +6937,7 @@ class LeafLevelList {
|
|
|
6880
6937
|
}
|
|
6881
6938
|
}
|
|
6882
6939
|
|
|
6883
|
-
const version = "1.12.
|
|
6940
|
+
const version = "1.12.2";
|
|
6884
6941
|
|
|
6885
6942
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6886
6943
|
get allowBackgroundColor() {
|
|
@@ -8044,7 +8101,7 @@ const UIRender = {
|
|
|
8044
8101
|
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8045
8102
|
}
|
|
8046
8103
|
} else {
|
|
8047
|
-
if (data.
|
|
8104
|
+
if (data.__pathForRender) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
|
|
8048
8105
|
}
|
|
8049
8106
|
},
|
|
8050
8107
|
__drawShape(canvas, options) {
|
|
@@ -8168,7 +8225,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8168
8225
|
getPath(curve, pathForRender) {
|
|
8169
8226
|
this.__layout.update();
|
|
8170
8227
|
let path = pathForRender ? this.__.__pathForRender : this.__.path;
|
|
8171
|
-
if (!path) pen.set(path = []), this.__drawPathByBox(pen);
|
|
8228
|
+
if (!path) pen.set(path = []), this.__drawPathByBox(pen, !pathForRender);
|
|
8172
8229
|
return curve ? PathConvert.toCanvasData(path, true) : path;
|
|
8173
8230
|
}
|
|
8174
8231
|
getPathString(curve, pathForRender, floatLength) {
|
|
@@ -8196,17 +8253,18 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8196
8253
|
}
|
|
8197
8254
|
__drawPath(canvas) {
|
|
8198
8255
|
canvas.beginPath();
|
|
8199
|
-
this.__drawPathByData(canvas, this.__.path);
|
|
8256
|
+
this.__drawPathByData(canvas, this.__.path, true);
|
|
8200
8257
|
}
|
|
8201
|
-
__drawPathByData(drawer, data) {
|
|
8202
|
-
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
|
|
8258
|
+
__drawPathByData(drawer, data, ignoreCornerRadius) {
|
|
8259
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, ignoreCornerRadius);
|
|
8203
8260
|
}
|
|
8204
|
-
__drawPathByBox(drawer) {
|
|
8261
|
+
__drawPathByBox(drawer, ignoreCornerRadius) {
|
|
8205
8262
|
const {x: x, y: y, width: width, height: height} = this.__layout.boxBounds;
|
|
8206
|
-
if (this.__.cornerRadius) {
|
|
8263
|
+
if (this.__.cornerRadius && !ignoreCornerRadius) {
|
|
8207
8264
|
const {cornerRadius: cornerRadius} = this.__;
|
|
8208
8265
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
8209
8266
|
} else drawer.rect(x, y, width, height);
|
|
8267
|
+
drawer.closePath();
|
|
8210
8268
|
}
|
|
8211
8269
|
drawImagePlaceholder(_paint, canvas, renderOptions) {
|
|
8212
8270
|
Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
|
|
@@ -8475,6 +8533,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8475
8533
|
get layoutLocked() {
|
|
8476
8534
|
return !this.layouter.running;
|
|
8477
8535
|
}
|
|
8536
|
+
get view() {
|
|
8537
|
+
return this.canvas && this.canvas.view;
|
|
8538
|
+
}
|
|
8478
8539
|
get FPS() {
|
|
8479
8540
|
return this.renderer ? this.renderer.FPS : 60;
|
|
8480
8541
|
}
|
|
@@ -8526,7 +8587,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8526
8587
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
8527
8588
|
if (this.isApp) this.__setApp();
|
|
8528
8589
|
this.__checkAutoLayout();
|
|
8529
|
-
this.view = canvas.view;
|
|
8530
8590
|
if (!parentApp) {
|
|
8531
8591
|
this.selector = Creator.selector(this);
|
|
8532
8592
|
this.interaction = Creator.interaction(this, canvas, this.selector, config);
|
|
@@ -8806,7 +8866,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8806
8866
|
if (this.canvasManager) this.canvasManager.destroy();
|
|
8807
8867
|
}
|
|
8808
8868
|
if (this.canvas) this.canvas.destroy();
|
|
8809
|
-
this.config.view = this.
|
|
8869
|
+
this.config.view = this.parentApp = null;
|
|
8810
8870
|
if (this.userConfig) this.userConfig.view = null;
|
|
8811
8871
|
super.destroy();
|
|
8812
8872
|
setTimeout(() => {
|
|
@@ -8990,7 +9050,6 @@ let Ellipse = class Ellipse extends UI {
|
|
|
8990
9050
|
if (startAngle || endAngle) {
|
|
8991
9051
|
if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
|
|
8992
9052
|
ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true);
|
|
8993
|
-
if (innerRadius < 1) closePath$2(path);
|
|
8994
9053
|
} else {
|
|
8995
9054
|
if (innerRadius < 1) {
|
|
8996
9055
|
ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius);
|
|
@@ -8998,16 +9057,16 @@ let Ellipse = class Ellipse extends UI {
|
|
|
8998
9057
|
}
|
|
8999
9058
|
ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
|
|
9000
9059
|
}
|
|
9001
|
-
if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
|
|
9002
9060
|
} else {
|
|
9003
9061
|
if (startAngle || endAngle) {
|
|
9004
9062
|
moveTo$3(path, rx, ry);
|
|
9005
9063
|
ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle, false);
|
|
9006
|
-
closePath$2(path);
|
|
9007
9064
|
} else {
|
|
9008
9065
|
ellipse(path, rx, ry, rx, ry);
|
|
9009
9066
|
}
|
|
9010
9067
|
}
|
|
9068
|
+
closePath$2(path);
|
|
9069
|
+
if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
|
|
9011
9070
|
}
|
|
9012
9071
|
};
|
|
9013
9072
|
|
|
@@ -10108,10 +10167,12 @@ const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
|
10108
10167
|
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
10109
10168
|
if (!paint.patternTask) {
|
|
10110
10169
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
10111
|
-
paint
|
|
10112
|
-
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
10170
|
+
PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
10113
10171
|
ui.forceUpdate("surface");
|
|
10114
|
-
}),
|
|
10172
|
+
}), 0, () => {
|
|
10173
|
+
paint.patternTask = null;
|
|
10174
|
+
return canvas.bounds.hit(ui.__nowWorld);
|
|
10175
|
+
});
|
|
10115
10176
|
}
|
|
10116
10177
|
}
|
|
10117
10178
|
|