leafer-game 2.2.2 → 2.2.4
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/web.js +102 -57
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +102 -57
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +12 -12
package/dist/web.module.js
CHANGED
|
@@ -292,7 +292,7 @@ const FourNumberHelper = {
|
|
|
292
292
|
return to;
|
|
293
293
|
},
|
|
294
294
|
setTemp(top, right, bottom, left) {
|
|
295
|
-
return set$
|
|
295
|
+
return set$4(tempFour, top, right, bottom, left);
|
|
296
296
|
},
|
|
297
297
|
toTempAB(a, b, change) {
|
|
298
298
|
tempTo = change ? isNumber(a) ? b : a : [];
|
|
@@ -332,22 +332,22 @@ const FourNumberHelper = {
|
|
|
332
332
|
max(t, other, change) {
|
|
333
333
|
if (isNumber(t) && isNumber(other)) return max$5(t, other);
|
|
334
334
|
toTempAB(t, other, change);
|
|
335
|
-
return set$
|
|
335
|
+
return set$4(tempTo, max$5(tempA[0], tempB[0]), max$5(tempA[1], tempB[1]), max$5(tempA[2], tempB[2]), max$5(tempA[3], tempB[3]));
|
|
336
336
|
},
|
|
337
337
|
add(t, other, change) {
|
|
338
338
|
if (isNumber(t) && isNumber(other)) return t + other;
|
|
339
339
|
toTempAB(t, other, change);
|
|
340
|
-
return set$
|
|
340
|
+
return set$4(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
|
|
341
341
|
},
|
|
342
342
|
swapAndScale(t, scaleX, scaleY, change) {
|
|
343
343
|
if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [ t * scaleY, t * scaleX ];
|
|
344
344
|
const to = change ? t : [];
|
|
345
345
|
const [top, right, bottom, left] = t.length === 4 ? t : get$5(t);
|
|
346
|
-
return set$
|
|
346
|
+
return set$4(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
|
|
347
347
|
}
|
|
348
348
|
};
|
|
349
349
|
|
|
350
|
-
const {set: set$
|
|
350
|
+
const {set: set$4, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
|
|
351
351
|
|
|
352
352
|
const {round: round$6, pow: pow$2, max: max$4, floor: floor$3, PI: PI$4} = Math;
|
|
353
353
|
|
|
@@ -874,7 +874,7 @@ const PointHelper = {
|
|
|
874
874
|
return y1 + (y2 - y1) / 2;
|
|
875
875
|
},
|
|
876
876
|
getDistance(t, point) {
|
|
877
|
-
return getDistanceFrom(t.x, t.y, point.x, point.y);
|
|
877
|
+
return getDistanceFrom$1(t.x, t.y, point.x, point.y);
|
|
878
878
|
},
|
|
879
879
|
getDistanceFrom(x1, y1, x2, y2) {
|
|
880
880
|
const x = abs$7(x2 - x1);
|
|
@@ -882,7 +882,7 @@ const PointHelper = {
|
|
|
882
882
|
return sqrt$4(x * x + y * y);
|
|
883
883
|
},
|
|
884
884
|
getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
|
|
885
|
-
return min$2(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3));
|
|
885
|
+
return min$2(getDistanceFrom$1(x1, y1, x2, y2), getDistanceFrom$1(x2, y2, x3, y3));
|
|
886
886
|
},
|
|
887
887
|
getAngle(t, to, radiusX, radiusY) {
|
|
888
888
|
return getAtan2(t, to, radiusX, radiusY) / OneRadian;
|
|
@@ -925,7 +925,7 @@ const PointHelper = {
|
|
|
925
925
|
|
|
926
926
|
const P$5 = PointHelper;
|
|
927
927
|
|
|
928
|
-
const {getDistanceFrom: getDistanceFrom, copy: copy$9, setRadius: setRadius, getAtan2: getAtan2} = P$5;
|
|
928
|
+
const {getDistanceFrom: getDistanceFrom$1, copy: copy$9, setRadius: setRadius, getAtan2: getAtan2} = P$5;
|
|
929
929
|
|
|
930
930
|
class Point {
|
|
931
931
|
constructor(x, y) {
|
|
@@ -2711,7 +2711,7 @@ const {sin: sin$4, cos: cos$4, hypot: hypot, atan2: atan2$1, ceil: ceil$1, abs:
|
|
|
2711
2711
|
|
|
2712
2712
|
const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
|
|
2713
2713
|
|
|
2714
|
-
const {set: set$
|
|
2714
|
+
const {set: set$3, toNumberPoints: toNumberPoints} = PointHelper;
|
|
2715
2715
|
|
|
2716
2716
|
const {M: M$6, L: L$7, C: C$5, Q: Q$4, Z: Z$6} = PathCommandMap;
|
|
2717
2717
|
|
|
@@ -2790,8 +2790,8 @@ const BezierHelper = {
|
|
|
2790
2790
|
setPoint$1(setPointBounds, fromX, fromY);
|
|
2791
2791
|
addPoint$1(setPointBounds, x1, y1);
|
|
2792
2792
|
}
|
|
2793
|
-
if (setStartPoint) set$
|
|
2794
|
-
if (setEndPoint) set$
|
|
2793
|
+
if (setStartPoint) set$3(setStartPoint, fromX, fromY);
|
|
2794
|
+
if (setEndPoint) set$3(setEndPoint, x1, y1);
|
|
2795
2795
|
return;
|
|
2796
2796
|
}
|
|
2797
2797
|
const anticlockwise = BAx * CBy - CBx * BAy < 0;
|
|
@@ -2816,7 +2816,10 @@ const BezierHelper = {
|
|
|
2816
2816
|
if (endRadian < 0) endRadian += PI2;
|
|
2817
2817
|
let totalRadian = endRadian - startRadian;
|
|
2818
2818
|
if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
|
|
2819
|
-
if (anticlockwise)
|
|
2819
|
+
if (anticlockwise) {
|
|
2820
|
+
const closedAngle = abs$6(endAngle - startAngle) === 360;
|
|
2821
|
+
if (closedAngle) totalRadian = -PI2; else totalRadian -= PI2;
|
|
2822
|
+
}
|
|
2820
2823
|
const parts = ceil$1(abs$6(totalRadian / PI_2));
|
|
2821
2824
|
const partRadian = totalRadian / parts;
|
|
2822
2825
|
const partRadian4Sin = sin$4(partRadian / 4);
|
|
@@ -2831,7 +2834,7 @@ const BezierHelper = {
|
|
|
2831
2834
|
let fromX = cx + x, fromY = cy + y;
|
|
2832
2835
|
if (data) data.push(data.length ? L$7 : M$6, fromX, fromY);
|
|
2833
2836
|
if (setPointBounds) setPoint$1(setPointBounds, fromX, fromY);
|
|
2834
|
-
if (setStartPoint) set$
|
|
2837
|
+
if (setStartPoint) set$3(setStartPoint, fromX, fromY);
|
|
2835
2838
|
for (let i = 0; i < parts; i++) {
|
|
2836
2839
|
endCos = cos$4(endRadian);
|
|
2837
2840
|
endSin = sin$4(endRadian);
|
|
@@ -2850,7 +2853,7 @@ const BezierHelper = {
|
|
|
2850
2853
|
startRadian = endRadian;
|
|
2851
2854
|
endRadian += partRadian;
|
|
2852
2855
|
}
|
|
2853
|
-
if (setEndPoint) set$
|
|
2856
|
+
if (setEndPoint) set$3(setEndPoint, cx + x, cy + y);
|
|
2854
2857
|
},
|
|
2855
2858
|
quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
|
|
2856
2859
|
data.push(C$5, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
|
|
@@ -4168,7 +4171,7 @@ const ImageManager = {
|
|
|
4168
4171
|
patternTasker: Resource.queue,
|
|
4169
4172
|
get(config, type) {
|
|
4170
4173
|
let image = Resource.get(config.url);
|
|
4171
|
-
if (!image) Resource.set(config.url, image = type
|
|
4174
|
+
if (!image) Resource.set(config.url, image = Creator[type || "image"](config));
|
|
4172
4175
|
image.use++;
|
|
4173
4176
|
return image;
|
|
4174
4177
|
},
|
|
@@ -6340,6 +6343,9 @@ let Leaf = class Leaf {
|
|
|
6340
6343
|
get isLeafer() {
|
|
6341
6344
|
return false;
|
|
6342
6345
|
}
|
|
6346
|
+
get isFrame() {
|
|
6347
|
+
return false;
|
|
6348
|
+
}
|
|
6343
6349
|
get isBranch() {
|
|
6344
6350
|
return false;
|
|
6345
6351
|
}
|
|
@@ -6481,6 +6487,16 @@ let Leaf = class Leaf {
|
|
|
6481
6487
|
}
|
|
6482
6488
|
}
|
|
6483
6489
|
}
|
|
6490
|
+
__bindFrame(frame) {
|
|
6491
|
+
if (this.isFrame && frame !== null) frame = this;
|
|
6492
|
+
this.frame = frame;
|
|
6493
|
+
if (this.isBranch) {
|
|
6494
|
+
const {children: children} = this;
|
|
6495
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
6496
|
+
children[i].__bindFrame(frame);
|
|
6497
|
+
}
|
|
6498
|
+
}
|
|
6499
|
+
}
|
|
6484
6500
|
setAttr(name, value) {
|
|
6485
6501
|
this[name] = value;
|
|
6486
6502
|
}
|
|
@@ -6789,6 +6805,7 @@ let Branch = class Branch extends Leaf {
|
|
|
6789
6805
|
childLayout.boxChanged || childLayout.boxChange();
|
|
6790
6806
|
childLayout.matrixChanged || childLayout.matrixChange();
|
|
6791
6807
|
if (child.__bubbleMap) child.__emitLifeEvent(ChildEvent.ADD);
|
|
6808
|
+
if (this.isFrame) child.__bindFrame(this);
|
|
6792
6809
|
if (this.leafer) {
|
|
6793
6810
|
child.__bindLeafer(this.leafer);
|
|
6794
6811
|
if (this.leafer.created) this.__emitChildEvent(ChildEvent.ADD, child);
|
|
@@ -6848,6 +6865,7 @@ let Branch = class Branch extends Leaf {
|
|
|
6848
6865
|
if (this.leafer.hitCanvasManager) this.leafer.hitCanvasManager.clear();
|
|
6849
6866
|
}
|
|
6850
6867
|
}
|
|
6868
|
+
if (this.isFrame) child.__bindFrame(null);
|
|
6851
6869
|
}
|
|
6852
6870
|
__emitChildEvent(type, child) {
|
|
6853
6871
|
const event = new ChildEvent(type, child, this);
|
|
@@ -7005,7 +7023,7 @@ class LeafLevelList {
|
|
|
7005
7023
|
}
|
|
7006
7024
|
}
|
|
7007
7025
|
|
|
7008
|
-
const version = "2.2.
|
|
7026
|
+
const version = "2.2.4";
|
|
7009
7027
|
|
|
7010
7028
|
const debug$5 = Debug.get("LeaferCanvas");
|
|
7011
7029
|
|
|
@@ -8652,9 +8670,6 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8652
8670
|
get app() {
|
|
8653
8671
|
return this.leafer && this.leafer.app;
|
|
8654
8672
|
}
|
|
8655
|
-
get isFrame() {
|
|
8656
|
-
return false;
|
|
8657
|
-
}
|
|
8658
8673
|
set strokeWidthFixed(value) {
|
|
8659
8674
|
this.strokeScaleFixed = value;
|
|
8660
8675
|
}
|
|
@@ -9523,7 +9538,7 @@ __decorate([ affectRenderBoundsType("hide") ], Frame.prototype, "overflow", void
|
|
|
9523
9538
|
|
|
9524
9539
|
Frame = __decorate([ registerUI() ], Frame);
|
|
9525
9540
|
|
|
9526
|
-
const {moveTo: moveTo$3, closePath: closePath$2, ellipse: ellipse} = PathCommandDataHelper, {tempPoint: tempPoint$1, set: set$
|
|
9541
|
+
const {moveTo: moveTo$3, closePath: closePath$2, ellipse: ellipse} = PathCommandDataHelper, {tempPoint: tempPoint$1, set: set$2, rotate: rotate$2} = PointHelper, {abs: abs$4} = Math, tempCenter = {};
|
|
9527
9542
|
|
|
9528
9543
|
let Ellipse = class Ellipse extends UI {
|
|
9529
9544
|
get __tag() {
|
|
@@ -9538,34 +9553,28 @@ let Ellipse = class Ellipse extends UI {
|
|
|
9538
9553
|
if (hasAngle) closedAngle = abs$4(endAngle - startAngle) === 360;
|
|
9539
9554
|
if (innerRadius) {
|
|
9540
9555
|
const drawInnerEllipse = innerRadius < 1 || closed;
|
|
9541
|
-
|
|
9556
|
+
const innerRx = rx * innerRadius, innerRy = ry * innerRadius;
|
|
9542
9557
|
if (hasAngle) {
|
|
9558
|
+
ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle);
|
|
9543
9559
|
if (drawInnerEllipse) {
|
|
9544
|
-
ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle);
|
|
9545
9560
|
if (closedAngle) {
|
|
9546
|
-
|
|
9547
|
-
set$1(tempCenter, rx, ry);
|
|
9561
|
+
closePath$2(path);
|
|
9562
|
+
set$2(tempPoint$1, rx + innerRx, ry), set$2(tempCenter, rx, ry);
|
|
9548
9563
|
rotate$2(tempPoint$1, endAngle, tempCenter, rx, ry);
|
|
9549
9564
|
moveTo$3(path, tempPoint$1.x, tempPoint$1.y);
|
|
9550
9565
|
}
|
|
9551
|
-
|
|
9552
|
-
outerEndAngle = startAngle;
|
|
9553
|
-
outerAnticlockwise = true;
|
|
9566
|
+
ellipse(path, rx, ry, innerRx, innerRy, 0, endAngle, startAngle, true);
|
|
9554
9567
|
} else {
|
|
9555
9568
|
if (!closedAngle) open = true;
|
|
9556
9569
|
}
|
|
9557
9570
|
} else {
|
|
9571
|
+
ellipse(path, rx, ry, rx, ry);
|
|
9558
9572
|
if (drawInnerEllipse) {
|
|
9559
|
-
ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius);
|
|
9560
9573
|
closePath$2(path);
|
|
9561
|
-
moveTo$3(path,
|
|
9562
|
-
|
|
9563
|
-
outerAnticlockwise = true;
|
|
9564
|
-
} else {
|
|
9565
|
-
outerEndAngle = 360;
|
|
9574
|
+
moveTo$3(path, rx + innerRx, ry);
|
|
9575
|
+
ellipse(path, rx, ry, innerRx, innerRy, 0, 360, 0, true);
|
|
9566
9576
|
}
|
|
9567
9577
|
}
|
|
9568
|
-
ellipse(path, rx, ry, rx, ry, 0, outerStartAngle, outerEndAngle, outerAnticlockwise);
|
|
9569
9578
|
} else {
|
|
9570
9579
|
if (hasAngle) {
|
|
9571
9580
|
if (!closedAngle) {
|
|
@@ -9674,7 +9683,7 @@ Star = __decorate([ registerUI() ], Star);
|
|
|
9674
9683
|
|
|
9675
9684
|
const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
|
|
9676
9685
|
|
|
9677
|
-
const {rotate: rotate$1, getAngle: getAngle$
|
|
9686
|
+
const {rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$3, defaultPoint: defaultPoint} = PointHelper;
|
|
9678
9687
|
|
|
9679
9688
|
let Line = class Line extends UI {
|
|
9680
9689
|
get __tag() {
|
|
@@ -9692,7 +9701,7 @@ let Line = class Line extends UI {
|
|
|
9692
9701
|
}
|
|
9693
9702
|
set toPoint(value) {
|
|
9694
9703
|
this.width = getDistance$3(defaultPoint, value);
|
|
9695
|
-
this.rotation = getAngle$
|
|
9704
|
+
this.rotation = getAngle$2(defaultPoint, value);
|
|
9696
9705
|
if (this.height) this.height = 0;
|
|
9697
9706
|
}
|
|
9698
9707
|
__updatePath() {
|
|
@@ -11465,7 +11474,8 @@ ui$5.__hit = function(inner, forceHitFill) {
|
|
|
11465
11474
|
const {hitFill: hitFill} = data;
|
|
11466
11475
|
const needHitFillPath = (data.fill || data.__isCanvas) && (hitFill === "path" || hitFill === "pixel" && !(data.__isAlphaPixelFill || data.__isCanvas)) || hitFill === "all" || forceHitFill;
|
|
11467
11476
|
if (needHitFillPath && this.__hitFill(inner)) return true;
|
|
11468
|
-
const {hitStroke: hitStroke,
|
|
11477
|
+
const {hitStroke: hitStroke, strokeScaleFixed: strokeScaleFixed} = data;
|
|
11478
|
+
const strokeWidth = data.__maxStrokeWidth * (strokeScaleFixed ? this.getRenderScaleData(true, strokeScaleFixed, false).scaleX : 1);
|
|
11469
11479
|
const needHitStrokePath = data.stroke && (hitStroke === "path" || hitStroke === "pixel" && !data.__isAlphaPixelStroke) || hitStroke === "all";
|
|
11470
11480
|
if (!needHitFillPath && !needHitStrokePath) return false;
|
|
11471
11481
|
const radiusWidth = inner.radiusX * 2;
|
|
@@ -12460,7 +12470,7 @@ function getGapValue(gap, size, totalSize, rows) {
|
|
|
12460
12470
|
|
|
12461
12471
|
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
12462
12472
|
|
|
12463
|
-
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
12473
|
+
const {get: get$2, set: set$1, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
12464
12474
|
|
|
12465
12475
|
function stretchMode(data, box, scaleX, scaleY) {
|
|
12466
12476
|
const transform = get$2(), {x: x, y: y} = box;
|
|
@@ -12485,7 +12495,7 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, c
|
|
|
12485
12495
|
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
12486
12496
|
if (clipScaleX) {
|
|
12487
12497
|
if (rotation || skew) {
|
|
12488
|
-
set(tempMatrix$1);
|
|
12498
|
+
set$1(tempMatrix$1);
|
|
12489
12499
|
scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
|
|
12490
12500
|
multiplyParent(transform, tempMatrix$1);
|
|
12491
12501
|
} else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
|
|
@@ -12736,7 +12746,7 @@ function applyStops(data, gradient, stops, opacity) {
|
|
|
12736
12746
|
}
|
|
12737
12747
|
}
|
|
12738
12748
|
|
|
12739
|
-
const {getAngle: getAngle, getDistance: getDistance$2} = PointHelper;
|
|
12749
|
+
const {getAngle: getAngle$1, getDistance: getDistance$2} = PointHelper;
|
|
12740
12750
|
|
|
12741
12751
|
const {get: get, rotateOfOuter: rotateOfOuter, scaleOfOuter: scaleOfOuter} = MatrixHelper;
|
|
12742
12752
|
|
|
@@ -12765,7 +12775,7 @@ function getTransform(box, from, to, stretch, rotate90) {
|
|
|
12765
12775
|
let transform;
|
|
12766
12776
|
const {width: width, height: height} = box;
|
|
12767
12777
|
if (width !== height || stretch) {
|
|
12768
|
-
const angle = getAngle(from, to);
|
|
12778
|
+
const angle = getAngle$1(from, to);
|
|
12769
12779
|
transform = get();
|
|
12770
12780
|
if (rotate90) {
|
|
12771
12781
|
scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
|
|
@@ -15252,7 +15262,7 @@ const HighBezierHelper = {
|
|
|
15252
15262
|
|
|
15253
15263
|
const {getDistance: getDistance} = HighBezierHelper;
|
|
15254
15264
|
|
|
15255
|
-
const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float} = MathHelper;
|
|
15265
|
+
const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float} = MathHelper, {set: set, getAngle: getAngle, getDistanceFrom: getDistanceFrom, getDistancePoint: getDistancePoint} = PointHelper;
|
|
15256
15266
|
|
|
15257
15267
|
const tempPoint = {}, tempFrom = {};
|
|
15258
15268
|
|
|
@@ -15290,16 +15300,19 @@ const HighCurveHelper = {
|
|
|
15290
15300
|
},
|
|
15291
15301
|
getMotionPathData(data) {
|
|
15292
15302
|
let total = 0, distance, segments = [];
|
|
15293
|
-
let i = 0, x = 0, y = 0, toX, toY, command, closed;
|
|
15303
|
+
let i = 0, x = 0, y = 0, startX = 0, startY = 0, toX, toY, command, closed;
|
|
15294
15304
|
const len = data.length;
|
|
15295
15305
|
while (i < len) {
|
|
15296
15306
|
command = data[i];
|
|
15297
15307
|
switch (command) {
|
|
15298
15308
|
case M:
|
|
15309
|
+
startX = data[i + 1];
|
|
15310
|
+
startY = data[i + 2];
|
|
15311
|
+
|
|
15299
15312
|
case L:
|
|
15300
15313
|
toX = data[i + 1];
|
|
15301
15314
|
toY = data[i + 2];
|
|
15302
|
-
distance = command === L && i > 0 ?
|
|
15315
|
+
distance = command === L && i > 0 ? getDistanceFrom(x, y, toX, toY) : 0;
|
|
15303
15316
|
x = toX;
|
|
15304
15317
|
y = toY;
|
|
15305
15318
|
i += 3;
|
|
@@ -15316,7 +15329,9 @@ const HighCurveHelper = {
|
|
|
15316
15329
|
|
|
15317
15330
|
case Z:
|
|
15318
15331
|
closed = true;
|
|
15332
|
+
distance = getDistanceFrom(x, y, startX, startY);
|
|
15319
15333
|
i += 1;
|
|
15334
|
+
break;
|
|
15320
15335
|
|
|
15321
15336
|
default:
|
|
15322
15337
|
distance = 0;
|
|
@@ -15337,25 +15352,26 @@ const HighCurveHelper = {
|
|
|
15337
15352
|
if (offsetX) motionDistance += offsetX;
|
|
15338
15353
|
if (motionDistance > total) motionDistance = motionDistance % total;
|
|
15339
15354
|
let nowDistance = 0, distance, to = {};
|
|
15340
|
-
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
15355
|
+
let i = 0, index = 0, x = 0, y = 0, startX = 0, startY = 0, toX, toY, command;
|
|
15341
15356
|
let x1, y1, x2, y2, t;
|
|
15342
15357
|
const len = data.length;
|
|
15343
15358
|
while (i < len) {
|
|
15344
15359
|
command = data[i];
|
|
15345
15360
|
switch (command) {
|
|
15346
15361
|
case M:
|
|
15362
|
+
startX = data[i + 1];
|
|
15363
|
+
startY = data[i + 2];
|
|
15364
|
+
|
|
15347
15365
|
case L:
|
|
15348
15366
|
toX = data[i + 1];
|
|
15349
15367
|
toY = data[i + 2];
|
|
15350
15368
|
distance = segments[index];
|
|
15351
15369
|
if (nowDistance + distance >= motionDistance || !distanceData.total) {
|
|
15352
|
-
to
|
|
15353
|
-
to.y = toY;
|
|
15370
|
+
set(to, toX, toY);
|
|
15354
15371
|
if (i) {
|
|
15355
|
-
tempFrom
|
|
15356
|
-
tempFrom
|
|
15357
|
-
|
|
15358
|
-
to.rotation = PointHelper.getAngle(tempFrom, to);
|
|
15372
|
+
set(tempFrom, x, y);
|
|
15373
|
+
getDistancePoint(tempFrom, to, motionDistance - nowDistance, true);
|
|
15374
|
+
to.rotation = getAngle(tempFrom, to);
|
|
15359
15375
|
return to;
|
|
15360
15376
|
} else {
|
|
15361
15377
|
const nextPoint = HighCurveHelper.getDistancePoint(distanceData, motionPrecision, motionPrecision, offsetX);
|
|
@@ -15385,7 +15401,19 @@ const HighCurveHelper = {
|
|
|
15385
15401
|
break;
|
|
15386
15402
|
|
|
15387
15403
|
case Z:
|
|
15404
|
+
toX = startX;
|
|
15405
|
+
toY = startY;
|
|
15406
|
+
distance = segments[index];
|
|
15407
|
+
if (nowDistance + distance >= motionDistance) {
|
|
15408
|
+
set(tempFrom, x, y), set(to, toX, toY);
|
|
15409
|
+
getDistancePoint(tempFrom, to, motionDistance - nowDistance, true);
|
|
15410
|
+
to.rotation = getAngle(tempFrom, to);
|
|
15411
|
+
return to;
|
|
15412
|
+
}
|
|
15413
|
+
x = toX;
|
|
15414
|
+
y = toY;
|
|
15388
15415
|
i += 1;
|
|
15416
|
+
break;
|
|
15389
15417
|
|
|
15390
15418
|
default:
|
|
15391
15419
|
distance = 0;
|
|
@@ -15399,26 +15427,27 @@ const HighCurveHelper = {
|
|
|
15399
15427
|
const {segments: segments, data: data} = distanceData, path = [];
|
|
15400
15428
|
motionDistance = UnitConvert.number(motionDistance, distanceData.total);
|
|
15401
15429
|
let total = 0, distance, cutDistance, to = {};
|
|
15402
|
-
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
15430
|
+
let i = 0, index = 0, x = 0, y = 0, startX = 0, startY = 0, toX, toY, command;
|
|
15403
15431
|
let x1, y1, x2, y2, t;
|
|
15404
15432
|
const len = data.length;
|
|
15405
15433
|
while (i < len) {
|
|
15406
15434
|
command = data[i];
|
|
15407
15435
|
switch (command) {
|
|
15408
15436
|
case M:
|
|
15437
|
+
startX = data[i + 1];
|
|
15438
|
+
startY = data[i + 2];
|
|
15439
|
+
|
|
15409
15440
|
case L:
|
|
15410
15441
|
toX = data[i + 1];
|
|
15411
15442
|
toY = data[i + 2];
|
|
15412
15443
|
distance = segments[index];
|
|
15413
15444
|
if (total + distance > motionDistance || !distanceData.total) {
|
|
15414
15445
|
if (!i) x = toX, y = toY;
|
|
15415
|
-
tempFrom
|
|
15416
|
-
|
|
15417
|
-
to.x = toX;
|
|
15418
|
-
to.y = toY;
|
|
15446
|
+
set(tempFrom, x, y);
|
|
15447
|
+
set(to, toX, toY);
|
|
15419
15448
|
cutDistance = float(motionDistance - total);
|
|
15420
15449
|
if (cutDistance) {
|
|
15421
|
-
|
|
15450
|
+
getDistancePoint(tempFrom, to, cutDistance, true);
|
|
15422
15451
|
path.push(command, to.x, to.y);
|
|
15423
15452
|
}
|
|
15424
15453
|
return path;
|
|
@@ -15449,8 +15478,24 @@ const HighCurveHelper = {
|
|
|
15449
15478
|
break;
|
|
15450
15479
|
|
|
15451
15480
|
case Z:
|
|
15481
|
+
toX = startX;
|
|
15482
|
+
toY = startY;
|
|
15483
|
+
distance = segments[index];
|
|
15484
|
+
if (total + distance > motionDistance) {
|
|
15485
|
+
set(tempFrom, x, y);
|
|
15486
|
+
set(to, toX, toY);
|
|
15487
|
+
cutDistance = float(motionDistance - total);
|
|
15488
|
+
if (cutDistance) {
|
|
15489
|
+
getDistancePoint(tempFrom, to, cutDistance, true);
|
|
15490
|
+
path.push(L, to.x, to.y);
|
|
15491
|
+
}
|
|
15492
|
+
return path;
|
|
15493
|
+
}
|
|
15494
|
+
x = toX;
|
|
15495
|
+
y = toY;
|
|
15452
15496
|
i += 1;
|
|
15453
15497
|
path.push(command);
|
|
15498
|
+
break;
|
|
15454
15499
|
|
|
15455
15500
|
default:
|
|
15456
15501
|
distance = 0;
|