leafer-game 2.2.3 → 2.2.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/web.js CHANGED
@@ -268,7 +268,7 @@ var LeaferUI = function(exports) {
268
268
  return to;
269
269
  },
270
270
  setTemp(top, right, bottom, left) {
271
- return set$3(tempFour, top, right, bottom, left);
271
+ return set$4(tempFour, top, right, bottom, left);
272
272
  },
273
273
  toTempAB(a, b, change) {
274
274
  tempTo = change ? isNumber(a) ? b : a : [];
@@ -308,21 +308,21 @@ var LeaferUI = function(exports) {
308
308
  max(t, other, change) {
309
309
  if (isNumber(t) && isNumber(other)) return max$5(t, other);
310
310
  toTempAB(t, other, change);
311
- return set$3(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]));
311
+ 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]));
312
312
  },
313
313
  add(t, other, change) {
314
314
  if (isNumber(t) && isNumber(other)) return t + other;
315
315
  toTempAB(t, other, change);
316
- return set$3(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
316
+ return set$4(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
317
317
  },
318
318
  swapAndScale(t, scaleX, scaleY, change) {
319
319
  if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [ t * scaleY, t * scaleX ];
320
320
  const to = change ? t : [];
321
321
  const [top, right, bottom, left] = t.length === 4 ? t : get$5(t);
322
- return set$3(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
322
+ return set$4(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
323
323
  }
324
324
  };
325
- const {set: set$3, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
325
+ const {set: set$4, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
326
326
  const {round: round$6, pow: pow$2, max: max$4, floor: floor$3, PI: PI$4} = Math;
327
327
  const tempScaleData$1 = {};
328
328
  const MathHelper = {
@@ -829,7 +829,7 @@ var LeaferUI = function(exports) {
829
829
  return y1 + (y2 - y1) / 2;
830
830
  },
831
831
  getDistance(t, point) {
832
- return getDistanceFrom(t.x, t.y, point.x, point.y);
832
+ return getDistanceFrom$1(t.x, t.y, point.x, point.y);
833
833
  },
834
834
  getDistanceFrom(x1, y1, x2, y2) {
835
835
  const x = abs$7(x2 - x1);
@@ -837,7 +837,7 @@ var LeaferUI = function(exports) {
837
837
  return sqrt$4(x * x + y * y);
838
838
  },
839
839
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
840
- return min$2(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3));
840
+ return min$2(getDistanceFrom$1(x1, y1, x2, y2), getDistanceFrom$1(x2, y2, x3, y3));
841
841
  },
842
842
  getAngle(t, to, radiusX, radiusY) {
843
843
  return getAtan2(t, to, radiusX, radiusY) / OneRadian;
@@ -878,7 +878,7 @@ var LeaferUI = function(exports) {
878
878
  }
879
879
  };
880
880
  const P$5 = PointHelper;
881
- const {getDistanceFrom: getDistanceFrom, copy: copy$9, setRadius: setRadius, getAtan2: getAtan2} = P$5;
881
+ const {getDistanceFrom: getDistanceFrom$1, copy: copy$9, setRadius: setRadius, getAtan2: getAtan2} = P$5;
882
882
  class Point {
883
883
  constructor(x, y) {
884
884
  this.set(x, y);
@@ -2527,7 +2527,7 @@ var LeaferUI = function(exports) {
2527
2527
  };
2528
2528
  const {sin: sin$4, cos: cos$4, hypot: hypot, atan2: atan2$1, ceil: ceil$1, abs: abs$6, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
2529
2529
  const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
2530
- const {set: set$2, toNumberPoints: toNumberPoints} = PointHelper;
2530
+ const {set: set$3, toNumberPoints: toNumberPoints} = PointHelper;
2531
2531
  const {M: M$6, L: L$7, C: C$5, Q: Q$4, Z: Z$6} = PathCommandMap;
2532
2532
  const tempPoint$4 = {};
2533
2533
  const BezierHelper = {
@@ -2603,8 +2603,8 @@ var LeaferUI = function(exports) {
2603
2603
  setPoint$1(setPointBounds, fromX, fromY);
2604
2604
  addPoint$1(setPointBounds, x1, y1);
2605
2605
  }
2606
- if (setStartPoint) set$2(setStartPoint, fromX, fromY);
2607
- if (setEndPoint) set$2(setEndPoint, x1, y1);
2606
+ if (setStartPoint) set$3(setStartPoint, fromX, fromY);
2607
+ if (setEndPoint) set$3(setEndPoint, x1, y1);
2608
2608
  return;
2609
2609
  }
2610
2610
  const anticlockwise = BAx * CBy - CBx * BAy < 0;
@@ -2629,7 +2629,10 @@ var LeaferUI = function(exports) {
2629
2629
  if (endRadian < 0) endRadian += PI2;
2630
2630
  let totalRadian = endRadian - startRadian;
2631
2631
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2632
- if (anticlockwise) totalRadian -= PI2;
2632
+ if (anticlockwise) {
2633
+ const closedAngle = abs$6(endAngle - startAngle) === 360;
2634
+ if (closedAngle) totalRadian = -PI2; else totalRadian -= PI2;
2635
+ }
2633
2636
  const parts = ceil$1(abs$6(totalRadian / PI_2));
2634
2637
  const partRadian = totalRadian / parts;
2635
2638
  const partRadian4Sin = sin$4(partRadian / 4);
@@ -2644,7 +2647,7 @@ var LeaferUI = function(exports) {
2644
2647
  let fromX = cx + x, fromY = cy + y;
2645
2648
  if (data) data.push(data.length ? L$7 : M$6, fromX, fromY);
2646
2649
  if (setPointBounds) setPoint$1(setPointBounds, fromX, fromY);
2647
- if (setStartPoint) set$2(setStartPoint, fromX, fromY);
2650
+ if (setStartPoint) set$3(setStartPoint, fromX, fromY);
2648
2651
  for (let i = 0; i < parts; i++) {
2649
2652
  endCos = cos$4(endRadian);
2650
2653
  endSin = sin$4(endRadian);
@@ -2663,7 +2666,7 @@ var LeaferUI = function(exports) {
2663
2666
  startRadian = endRadian;
2664
2667
  endRadian += partRadian;
2665
2668
  }
2666
- if (setEndPoint) set$2(setEndPoint, cx + x, cy + y);
2669
+ if (setEndPoint) set$3(setEndPoint, cx + x, cy + y);
2667
2670
  },
2668
2671
  quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
2669
2672
  data.push(C$5, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
@@ -4477,7 +4480,7 @@ var LeaferUI = function(exports) {
4477
4480
  if (!excludeNames.includes(name) && (!exclude || !exclude.includes(name))) {
4478
4481
  if (module.prototype) {
4479
4482
  const d = getDescriptor(module.prototype, name);
4480
- if (d.writable) target.prototype[name] = module.prototype[name];
4483
+ if (d) Object.defineProperty(target.prototype, name, d);
4481
4484
  } else {
4482
4485
  target.prototype[name] = module[name];
4483
4486
  }
@@ -6389,11 +6392,11 @@ var LeaferUI = function(exports) {
6389
6392
  childLayout.boxChanged || childLayout.boxChange();
6390
6393
  childLayout.matrixChanged || childLayout.matrixChange();
6391
6394
  if (child.__bubbleMap) child.__emitLifeEvent(ChildEvent.ADD);
6395
+ if (this.isFrame) child.__bindFrame(this);
6392
6396
  if (this.leafer) {
6393
6397
  child.__bindLeafer(this.leafer);
6394
6398
  if (this.leafer.created) this.__emitChildEvent(ChildEvent.ADD, child);
6395
6399
  }
6396
- if (this.isFrame) child.__bindFrame(this);
6397
6400
  this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
6398
6401
  }
6399
6402
  addMany(...children) {
@@ -6603,7 +6606,7 @@ var LeaferUI = function(exports) {
6603
6606
  this.levelMap = null;
6604
6607
  }
6605
6608
  }
6606
- const version = "2.2.3";
6609
+ const version = "2.2.5";
6607
6610
  const debug$5 = Debug.get("LeaferCanvas");
6608
6611
  class LeaferCanvas extends LeaferCanvasBase {
6609
6612
  set zIndex(zIndex) {
@@ -7579,7 +7582,7 @@ var LeaferUI = function(exports) {
7579
7582
  if (child.__hitWorld(point, onlyHitMask && child.mask === "path" ? true : undefined)) {
7580
7583
  const {parent: parent, mask: mask} = child;
7581
7584
  if (parent && parent.__hasMask && mask && !(mask === "clipping" || mask === "clipping-path")) {
7582
- if (!parent.children.some(item => !item.mask && item.__hitWorld(point))) return;
7585
+ if (!parent.children.some(item => !item.mask && this.isHitLeaf(item, point))) return;
7583
7586
  }
7584
7587
  const leaf = proxy || child, {hitThrough: hitThrough} = child, {findList: findList} = this;
7585
7588
  if (hitThrough) {
@@ -7589,6 +7592,15 @@ var LeaferUI = function(exports) {
7589
7592
  findList.add(leaf);
7590
7593
  }
7591
7594
  }
7595
+ isHitLeaf(leaf, point) {
7596
+ if (leaf.isBranch) {
7597
+ const {findList: findList} = this, old = findList.length;
7598
+ this.eachFind([ leaf ], false);
7599
+ const count = findList.length - old;
7600
+ for (let i = 0; i < count; i++) findList.remove(findList.indexAt(findList.length - 1));
7601
+ return !!count;
7602
+ } else return leaf.__hitWorld(point);
7603
+ }
7592
7604
  clear() {
7593
7605
  this.point = null;
7594
7606
  this.findList = null;
@@ -8924,7 +8936,7 @@ var LeaferUI = function(exports) {
8924
8936
  __decorate([ surfaceType("#FFFFFF") ], exports.Frame.prototype, "fill", void 0);
8925
8937
  __decorate([ affectRenderBoundsType("hide") ], exports.Frame.prototype, "overflow", void 0);
8926
8938
  exports.Frame = __decorate([ registerUI() ], exports.Frame);
8927
- const {moveTo: moveTo$3, closePath: closePath$2, ellipse: ellipse} = PathCommandDataHelper, {tempPoint: tempPoint$1, set: set$1, rotate: rotate$2} = PointHelper, {abs: abs$4} = Math, tempCenter = {};
8939
+ 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 = {};
8928
8940
  exports.Ellipse = class Ellipse extends exports.UI {
8929
8941
  get __tag() {
8930
8942
  return "Ellipse";
@@ -8938,34 +8950,28 @@ var LeaferUI = function(exports) {
8938
8950
  if (hasAngle) closedAngle = abs$4(endAngle - startAngle) === 360;
8939
8951
  if (innerRadius) {
8940
8952
  const drawInnerEllipse = innerRadius < 1 || closed;
8941
- let outerStartAngle = startAngle, outerEndAngle = endAngle, outerAnticlockwise;
8953
+ const innerRx = rx * innerRadius, innerRy = ry * innerRadius;
8942
8954
  if (hasAngle) {
8955
+ ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle);
8943
8956
  if (drawInnerEllipse) {
8944
- ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle);
8945
8957
  if (closedAngle) {
8946
- set$1(tempPoint$1, width, ry);
8947
- set$1(tempCenter, rx, ry);
8958
+ closePath$2(path);
8959
+ set$2(tempPoint$1, rx + innerRx, ry), set$2(tempCenter, rx, ry);
8948
8960
  rotate$2(tempPoint$1, endAngle, tempCenter, rx, ry);
8949
8961
  moveTo$3(path, tempPoint$1.x, tempPoint$1.y);
8950
8962
  }
8951
- outerStartAngle = endAngle;
8952
- outerEndAngle = startAngle;
8953
- outerAnticlockwise = true;
8963
+ ellipse(path, rx, ry, innerRx, innerRy, 0, endAngle, startAngle, true);
8954
8964
  } else {
8955
8965
  if (!closedAngle) open = true;
8956
8966
  }
8957
8967
  } else {
8968
+ ellipse(path, rx, ry, rx, ry);
8958
8969
  if (drawInnerEllipse) {
8959
- ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius);
8960
8970
  closePath$2(path);
8961
- moveTo$3(path, width, ry);
8962
- outerStartAngle = 360;
8963
- outerAnticlockwise = true;
8964
- } else {
8965
- outerEndAngle = 360;
8971
+ moveTo$3(path, rx + innerRx, ry);
8972
+ ellipse(path, rx, ry, innerRx, innerRy, 0, 360, 0, true);
8966
8973
  }
8967
8974
  }
8968
- ellipse(path, rx, ry, rx, ry, 0, outerStartAngle, outerEndAngle, outerAnticlockwise);
8969
8975
  } else {
8970
8976
  if (hasAngle) {
8971
8977
  if (!closedAngle) {
@@ -9050,7 +9056,7 @@ var LeaferUI = function(exports) {
9050
9056
  __decorate([ pathType(0) ], exports.Star.prototype, "startAngle", void 0);
9051
9057
  exports.Star = __decorate([ registerUI() ], exports.Star);
9052
9058
  const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
9053
- const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$3, defaultPoint: defaultPoint} = PointHelper;
9059
+ const {rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$3, defaultPoint: defaultPoint} = PointHelper;
9054
9060
  exports.Line = class Line extends exports.UI {
9055
9061
  get __tag() {
9056
9062
  return "Line";
@@ -9067,7 +9073,7 @@ var LeaferUI = function(exports) {
9067
9073
  }
9068
9074
  set toPoint(value) {
9069
9075
  this.width = getDistance$3(defaultPoint, value);
9070
- this.rotation = getAngle$1(defaultPoint, value);
9076
+ this.rotation = getAngle$2(defaultPoint, value);
9071
9077
  if (this.height) this.height = 0;
9072
9078
  }
9073
9079
  __updatePath() {
@@ -10662,7 +10668,8 @@ var LeaferUI = function(exports) {
10662
10668
  const {hitFill: hitFill} = data;
10663
10669
  const needHitFillPath = (data.fill || data.__isCanvas) && (hitFill === "path" || hitFill === "pixel" && !(data.__isAlphaPixelFill || data.__isCanvas)) || hitFill === "all" || forceHitFill;
10664
10670
  if (needHitFillPath && this.__hitFill(inner)) return true;
10665
- const {hitStroke: hitStroke, __maxStrokeWidth: strokeWidth} = data;
10671
+ const {hitStroke: hitStroke, strokeScaleFixed: strokeScaleFixed} = data;
10672
+ const strokeWidth = data.__maxStrokeWidth * (strokeScaleFixed ? this.getRenderScaleData(true, strokeScaleFixed, false).scaleX : 1);
10666
10673
  const needHitStrokePath = data.stroke && (hitStroke === "path" || hitStroke === "pixel" && !data.__isAlphaPixelStroke) || hitStroke === "all";
10667
10674
  if (!needHitFillPath && !needHitStrokePath) return false;
10668
10675
  const radiusWidth = inner.radiusX * 2;
@@ -11603,7 +11610,7 @@ var LeaferUI = function(exports) {
11603
11610
  return gap === "auto" ? value < 0 ? 0 : value : value;
11604
11611
  }
11605
11612
  let origin = {}, tempMatrix$1 = getMatrixData();
11606
- const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
11613
+ const {get: get$2, set: set$1, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
11607
11614
  function stretchMode(data, box, scaleX, scaleY) {
11608
11615
  const transform = get$2(), {x: x, y: y} = box;
11609
11616
  if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
@@ -11625,7 +11632,7 @@ var LeaferUI = function(exports) {
11625
11632
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
11626
11633
  if (clipScaleX) {
11627
11634
  if (rotation || skew) {
11628
- set(tempMatrix$1);
11635
+ set$1(tempMatrix$1);
11629
11636
  scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
11630
11637
  multiplyParent(transform, tempMatrix$1);
11631
11638
  } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
@@ -11858,7 +11865,7 @@ var LeaferUI = function(exports) {
11858
11865
  if (isTransparent) data.isTransparent = true;
11859
11866
  }
11860
11867
  }
11861
- const {getAngle: getAngle, getDistance: getDistance$2} = PointHelper;
11868
+ const {getAngle: getAngle$1, getDistance: getDistance$2} = PointHelper;
11862
11869
  const {get: get, rotateOfOuter: rotateOfOuter, scaleOfOuter: scaleOfOuter} = MatrixHelper;
11863
11870
  const {toPoint: toPoint$1} = AroundHelper;
11864
11871
  const realFrom$1 = {};
@@ -11881,7 +11888,7 @@ var LeaferUI = function(exports) {
11881
11888
  let transform;
11882
11889
  const {width: width, height: height} = box;
11883
11890
  if (width !== height || stretch) {
11884
- const angle = getAngle(from, to);
11891
+ const angle = getAngle$1(from, to);
11885
11892
  transform = get();
11886
11893
  if (rotate90) {
11887
11894
  scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
@@ -14123,7 +14130,7 @@ var LeaferUI = function(exports) {
14123
14130
  }
14124
14131
  };
14125
14132
  const {getDistance: getDistance} = HighBezierHelper;
14126
- const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float} = MathHelper;
14133
+ const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float} = MathHelper, {set: set, getAngle: getAngle, getDistanceFrom: getDistanceFrom, getDistancePoint: getDistancePoint} = PointHelper;
14127
14134
  const tempPoint = {}, tempFrom = {};
14128
14135
  const HighCurveHelper = {
14129
14136
  transform(data, matrix) {
@@ -14159,16 +14166,19 @@ var LeaferUI = function(exports) {
14159
14166
  },
14160
14167
  getMotionPathData(data) {
14161
14168
  let total = 0, distance, segments = [];
14162
- let i = 0, x = 0, y = 0, toX, toY, command, closed;
14169
+ let i = 0, x = 0, y = 0, startX = 0, startY = 0, toX, toY, command, closed;
14163
14170
  const len = data.length;
14164
14171
  while (i < len) {
14165
14172
  command = data[i];
14166
14173
  switch (command) {
14167
14174
  case M:
14175
+ startX = data[i + 1];
14176
+ startY = data[i + 2];
14177
+
14168
14178
  case L:
14169
14179
  toX = data[i + 1];
14170
14180
  toY = data[i + 2];
14171
- distance = command === L && i > 0 ? PointHelper.getDistanceFrom(x, y, toX, toY) : 0;
14181
+ distance = command === L && i > 0 ? getDistanceFrom(x, y, toX, toY) : 0;
14172
14182
  x = toX;
14173
14183
  y = toY;
14174
14184
  i += 3;
@@ -14185,7 +14195,9 @@ var LeaferUI = function(exports) {
14185
14195
 
14186
14196
  case Z:
14187
14197
  closed = true;
14198
+ distance = getDistanceFrom(x, y, startX, startY);
14188
14199
  i += 1;
14200
+ break;
14189
14201
 
14190
14202
  default:
14191
14203
  distance = 0;
@@ -14206,25 +14218,26 @@ var LeaferUI = function(exports) {
14206
14218
  if (offsetX) motionDistance += offsetX;
14207
14219
  if (motionDistance > total) motionDistance = motionDistance % total;
14208
14220
  let nowDistance = 0, distance, to = {};
14209
- let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
14221
+ let i = 0, index = 0, x = 0, y = 0, startX = 0, startY = 0, toX, toY, command;
14210
14222
  let x1, y1, x2, y2, t;
14211
14223
  const len = data.length;
14212
14224
  while (i < len) {
14213
14225
  command = data[i];
14214
14226
  switch (command) {
14215
14227
  case M:
14228
+ startX = data[i + 1];
14229
+ startY = data[i + 2];
14230
+
14216
14231
  case L:
14217
14232
  toX = data[i + 1];
14218
14233
  toY = data[i + 2];
14219
14234
  distance = segments[index];
14220
14235
  if (nowDistance + distance >= motionDistance || !distanceData.total) {
14221
- to.x = toX;
14222
- to.y = toY;
14236
+ set(to, toX, toY);
14223
14237
  if (i) {
14224
- tempFrom.x = x;
14225
- tempFrom.y = y;
14226
- PointHelper.getDistancePoint(tempFrom, to, motionDistance - nowDistance, true);
14227
- to.rotation = PointHelper.getAngle(tempFrom, to);
14238
+ set(tempFrom, x, y);
14239
+ getDistancePoint(tempFrom, to, motionDistance - nowDistance, true);
14240
+ to.rotation = getAngle(tempFrom, to);
14228
14241
  return to;
14229
14242
  } else {
14230
14243
  const nextPoint = HighCurveHelper.getDistancePoint(distanceData, motionPrecision, motionPrecision, offsetX);
@@ -14254,7 +14267,19 @@ var LeaferUI = function(exports) {
14254
14267
  break;
14255
14268
 
14256
14269
  case Z:
14270
+ toX = startX;
14271
+ toY = startY;
14272
+ distance = segments[index];
14273
+ if (nowDistance + distance >= motionDistance) {
14274
+ set(tempFrom, x, y), set(to, toX, toY);
14275
+ getDistancePoint(tempFrom, to, motionDistance - nowDistance, true);
14276
+ to.rotation = getAngle(tempFrom, to);
14277
+ return to;
14278
+ }
14279
+ x = toX;
14280
+ y = toY;
14257
14281
  i += 1;
14282
+ break;
14258
14283
 
14259
14284
  default:
14260
14285
  distance = 0;
@@ -14268,26 +14293,27 @@ var LeaferUI = function(exports) {
14268
14293
  const {segments: segments, data: data} = distanceData, path = [];
14269
14294
  motionDistance = UnitConvert.number(motionDistance, distanceData.total);
14270
14295
  let total = 0, distance, cutDistance, to = {};
14271
- let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
14296
+ let i = 0, index = 0, x = 0, y = 0, startX = 0, startY = 0, toX, toY, command;
14272
14297
  let x1, y1, x2, y2, t;
14273
14298
  const len = data.length;
14274
14299
  while (i < len) {
14275
14300
  command = data[i];
14276
14301
  switch (command) {
14277
14302
  case M:
14303
+ startX = data[i + 1];
14304
+ startY = data[i + 2];
14305
+
14278
14306
  case L:
14279
14307
  toX = data[i + 1];
14280
14308
  toY = data[i + 2];
14281
14309
  distance = segments[index];
14282
14310
  if (total + distance > motionDistance || !distanceData.total) {
14283
14311
  if (!i) x = toX, y = toY;
14284
- tempFrom.x = x;
14285
- tempFrom.y = y;
14286
- to.x = toX;
14287
- to.y = toY;
14312
+ set(tempFrom, x, y);
14313
+ set(to, toX, toY);
14288
14314
  cutDistance = float(motionDistance - total);
14289
14315
  if (cutDistance) {
14290
- PointHelper.getDistancePoint(tempFrom, to, cutDistance, true);
14316
+ getDistancePoint(tempFrom, to, cutDistance, true);
14291
14317
  path.push(command, to.x, to.y);
14292
14318
  }
14293
14319
  return path;
@@ -14318,8 +14344,24 @@ var LeaferUI = function(exports) {
14318
14344
  break;
14319
14345
 
14320
14346
  case Z:
14347
+ toX = startX;
14348
+ toY = startY;
14349
+ distance = segments[index];
14350
+ if (total + distance > motionDistance) {
14351
+ set(tempFrom, x, y);
14352
+ set(to, toX, toY);
14353
+ cutDistance = float(motionDistance - total);
14354
+ if (cutDistance) {
14355
+ getDistancePoint(tempFrom, to, cutDistance, true);
14356
+ path.push(L, to.x, to.y);
14357
+ }
14358
+ return path;
14359
+ }
14360
+ x = toX;
14361
+ y = toY;
14321
14362
  i += 1;
14322
14363
  path.push(command);
14364
+ break;
14323
14365
 
14324
14366
  default:
14325
14367
  distance = 0;