@leafer-game/worker 2.1.2 → 2.1.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/worker.js CHANGED
@@ -2850,6 +2850,7 @@ var LeaferUI = function(exports) {
2850
2850
  current.length = PathCommandLengthMap[char];
2851
2851
  current.index = 0;
2852
2852
  pushData(data, current.name);
2853
+ if (char === "m") current.name = PathCommandMap["l"]; else if (char === "M") current.name = PathCommandMap["L"];
2853
2854
  if (!needConvert && convertCommand[char]) needConvert = true;
2854
2855
  } else {
2855
2856
  if (char === "-" || char === "+") {
@@ -2882,10 +2883,9 @@ var LeaferUI = function(exports) {
2882
2883
  old[i + 2] += y;
2883
2884
 
2884
2885
  case M$5:
2885
- x = old[i + 1];
2886
- y = old[i + 2];
2887
- if (lastCommand === command) data.push(L$6, x, y); else data.push(M$5, x, y), startX = x,
2888
- startY = y;
2886
+ x = startX = old[i + 1];
2887
+ y = startY = old[i + 2];
2888
+ data.push(M$5, x, y);
2889
2889
  i += 3;
2890
2890
  break;
2891
2891
 
@@ -2927,8 +2927,8 @@ var LeaferUI = function(exports) {
2927
2927
 
2928
2928
  case S:
2929
2929
  smooth = lastCommand === C$4 || lastCommand === S;
2930
- x1 = smooth ? x * 2 - controlX : old[i + 1];
2931
- y1 = smooth ? y * 2 - controlY : old[i + 2];
2930
+ x1 = smooth ? x * 2 - controlX : x;
2931
+ y1 = smooth ? y * 2 - controlY : y;
2932
2932
  controlX = old[i + 1];
2933
2933
  controlY = old[i + 2];
2934
2934
  x = old[i + 3];
@@ -2962,8 +2962,8 @@ var LeaferUI = function(exports) {
2962
2962
 
2963
2963
  case T:
2964
2964
  smooth = lastCommand === Q$3 || lastCommand === T;
2965
- controlX = smooth ? x * 2 - controlX : old[i + 1];
2966
- controlY = smooth ? y * 2 - controlY : old[i + 2];
2965
+ controlX = smooth ? x * 2 - controlX : x;
2966
+ controlY = smooth ? y * 2 - controlY : y;
2967
2967
  curveMode ? quadraticCurveTo$1(data, x, y, controlX, controlY, old[i + 1], old[i + 2]) : data.push(Q$3, controlX, controlY, old[i + 1], old[i + 2]);
2968
2968
  x = old[i + 1];
2969
2969
  y = old[i + 2];
@@ -4569,10 +4569,10 @@ var LeaferUI = function(exports) {
4569
4569
  y: y
4570
4570
  }, transition) : (t.x = x, t.y = y);
4571
4571
  },
4572
- zoomOfWorld(t, origin, scaleX, scaleY, resize, transition) {
4573
- L$1.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize, transition);
4572
+ zoomOfWorld(t, origin, scaleX, scaleY, resize, transition, boundsType) {
4573
+ L$1.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize, transition, boundsType);
4574
4574
  },
4575
- zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize, transition) {
4575
+ zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize, transition, boundsType) {
4576
4576
  const o = t.__localMatrix;
4577
4577
  if (!isNumber(scaleY)) {
4578
4578
  if (scaleY) transition = scaleY;
@@ -4581,7 +4581,7 @@ var LeaferUI = function(exports) {
4581
4581
  copy$5(matrix$1, o);
4582
4582
  scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
4583
4583
  if (L$1.hasHighPosition(t)) {
4584
- L$1.setTransform(t, matrix$1, resize, transition);
4584
+ L$1.setTransform(t, matrix$1, resize, transition, boundsType);
4585
4585
  } else {
4586
4586
  const x = t.x + matrix$1.e - o.e, y = t.y + matrix$1.f - o.f;
4587
4587
  if (transition && !resize) t.animate({
@@ -4589,7 +4589,7 @@ var LeaferUI = function(exports) {
4589
4589
  y: y,
4590
4590
  scaleX: t.scaleX * scaleX,
4591
4591
  scaleY: t.scaleY * scaleY
4592
- }, transition); else t.x = x, t.y = y, t.scaleResize(scaleX, scaleY, resize !== true);
4592
+ }, transition); else t.x = x, t.y = y, t.scaleResize(scaleX, scaleY, resize !== true, boundsType);
4593
4593
  }
4594
4594
  },
4595
4595
  rotateOfWorld(t, origin, angle, transition) {
@@ -4613,18 +4613,18 @@ var LeaferUI = function(exports) {
4613
4613
  skewOfOuter(matrix$1, origin, skewX, skewY);
4614
4614
  L$1.setTransform(t, matrix$1, resize, transition);
4615
4615
  },
4616
- transformWorld(t, transform, resize, transition) {
4616
+ transformWorld(t, transform, resize, transition, boundsType) {
4617
4617
  copy$5(matrix$1, t.worldTransform);
4618
4618
  multiplyParent$3(matrix$1, transform);
4619
4619
  if (t.parent) divideParent(matrix$1, t.parent.scrollWorldTransform);
4620
- L$1.setTransform(t, matrix$1, resize, transition);
4620
+ L$1.setTransform(t, matrix$1, resize, transition, boundsType);
4621
4621
  },
4622
- transform(t, transform, resize, transition) {
4622
+ transform(t, transform, resize, transition, boundsType) {
4623
4623
  copy$5(matrix$1, t.localTransform);
4624
4624
  multiplyParent$3(matrix$1, transform);
4625
- L$1.setTransform(t, matrix$1, resize, transition);
4625
+ L$1.setTransform(t, matrix$1, resize, transition, boundsType);
4626
4626
  },
4627
- setTransform(t, transform, resize, transition) {
4627
+ setTransform(t, transform, resize, transition, boundsType) {
4628
4628
  const data = t.__, originPoint = data.origin && L$1.getInnerOrigin(t, data.origin);
4629
4629
  const layout = getLayout(transform, originPoint, data.around && L$1.getInnerOrigin(t, data.around));
4630
4630
  if (L$1.hasOffset(t)) {
@@ -4640,7 +4640,7 @@ var LeaferUI = function(exports) {
4640
4640
  PointHelper.move(layout, originPoint.x - changedPoint.x, originPoint.y - changedPoint.y);
4641
4641
  }
4642
4642
  t.set(layout);
4643
- t.scaleResize(scaleX, scaleY, false);
4643
+ t.scaleResize(scaleX, scaleY, false, boundsType);
4644
4644
  } else t.set(layout, transition);
4645
4645
  },
4646
4646
  getFlipTransform(t, axis) {
@@ -5689,39 +5689,45 @@ var LeaferUI = function(exports) {
5689
5689
  this.__updateRenderPath();
5690
5690
  this.__updateBoxBounds();
5691
5691
  layout.resized = "inner";
5692
- if (data.__strokeGeometry) data.__strokeGeometry = undefined;
5693
5692
  }
5694
5693
  if (layout.localBoxChanged) {
5695
5694
  if (this.__local) this.__updateLocalBoxBounds();
5696
5695
  layout.localBoxChanged = undefined;
5697
- if (layout.strokeSpread) layout.strokeChanged = true;
5698
- if (layout.renderSpread) layout.renderChanged = true;
5696
+ if (layout.strokeSpread && !layout.strokeChanged) layout.strokeChanged = layout.boxChanged ? true : 2;
5697
+ if (layout.renderSpread && !layout.renderChanged) layout.renderChanged = layout.boxChanged ? true : 2;
5699
5698
  if (this.parent) this.parent.__layout.boxChange();
5700
5699
  }
5701
5700
  layout.boxChanged = undefined;
5702
5701
  if (layout.strokeChanged) {
5703
- layout.strokeSpread = this.__updateStrokeSpread();
5704
- if (layout.strokeSpread) {
5705
- if (layout.strokeBounds === layout.boxBounds) layout.spreadStroke();
5706
- this.__updateStrokeBounds();
5702
+ if (layout.strokeChanged === 2) {
5707
5703
  this.__updateLocalStrokeBounds();
5708
5704
  } else {
5709
- layout.spreadStrokeCancel();
5705
+ layout.strokeSpread = this.__updateStrokeSpread();
5706
+ if (layout.strokeSpread) {
5707
+ if (layout.strokeBounds === layout.boxBounds) layout.spreadStroke();
5708
+ this.__updateStrokeBounds();
5709
+ this.__updateLocalStrokeBounds();
5710
+ } else {
5711
+ layout.spreadStrokeCancel();
5712
+ }
5713
+ layout.resized = "inner";
5714
+ if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread) layout.renderChanged = true;
5710
5715
  }
5711
5716
  layout.strokeChanged = undefined;
5712
- if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread) layout.renderChanged = true;
5713
5717
  if (this.parent) this.parent.__layout.strokeChange();
5714
- layout.resized = "inner";
5715
- if (data.__strokeGeometry) data.__strokeGeometry = undefined;
5716
5718
  }
5717
5719
  if (layout.renderChanged) {
5718
- layout.renderSpread = this.__updateRenderSpread();
5719
- if (layout.renderSpread) {
5720
- if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) layout.spreadRender();
5721
- this.__updateRenderBounds();
5720
+ if (layout.renderChanged === 2) {
5722
5721
  this.__updateLocalRenderBounds();
5723
5722
  } else {
5724
- layout.spreadRenderCancel();
5723
+ layout.renderSpread = this.__updateRenderSpread();
5724
+ if (layout.renderSpread) {
5725
+ if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) layout.spreadRender();
5726
+ this.__updateRenderBounds();
5727
+ this.__updateLocalRenderBounds();
5728
+ } else {
5729
+ layout.spreadRenderCancel();
5730
+ }
5725
5731
  }
5726
5732
  layout.renderChanged = undefined;
5727
5733
  if (this.parent) this.parent.__layout.renderChange();
@@ -6264,11 +6270,11 @@ var LeaferUI = function(exports) {
6264
6270
  const layer = this.leafer ? this.leafer.zoomLayer : this;
6265
6271
  return layer.getWorldPoint(page, relative, distance, change);
6266
6272
  }
6267
- setTransform(matrix, resize, transition) {
6268
- setTransform(this, matrix, resize, transition);
6273
+ setTransform(matrix, resize, transition, boundsType) {
6274
+ setTransform(this, matrix, resize, transition, boundsType);
6269
6275
  }
6270
- transform(matrix, resize, transition) {
6271
- transform(this, matrix, resize, transition);
6276
+ transform(matrix, resize, transition, boundsType) {
6277
+ transform(this, matrix, resize, transition, boundsType);
6272
6278
  }
6273
6279
  move(x, y, transition) {
6274
6280
  moveLocal(this, x, y, transition);
@@ -6276,8 +6282,8 @@ var LeaferUI = function(exports) {
6276
6282
  moveInner(x, y, transition) {
6277
6283
  moveWorld(this, x, y, true, transition);
6278
6284
  }
6279
- scaleOf(origin, scaleX, scaleY, resize, transition) {
6280
- zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize, transition);
6285
+ scaleOf(origin, scaleX, scaleY, resize, transition, boundsType) {
6286
+ zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize, transition, boundsType);
6281
6287
  }
6282
6288
  rotateOf(origin, rotation, transition) {
6283
6289
  rotateOfLocal(this, getLocalOrigin(this, origin), rotation, transition);
@@ -6285,14 +6291,14 @@ var LeaferUI = function(exports) {
6285
6291
  skewOf(origin, skewX, skewY, resize, transition) {
6286
6292
  skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize, transition);
6287
6293
  }
6288
- transformWorld(worldTransform, resize, transition) {
6289
- transformWorld(this, worldTransform, resize, transition);
6294
+ transformWorld(worldTransform, resize, transition, boundsType) {
6295
+ transformWorld(this, worldTransform, resize, transition, boundsType);
6290
6296
  }
6291
6297
  moveWorld(x, y, transition) {
6292
6298
  moveWorld(this, x, y, false, transition);
6293
6299
  }
6294
- scaleOfWorld(worldOrigin, scaleX, scaleY, resize, transition) {
6295
- zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize, transition);
6300
+ scaleOfWorld(worldOrigin, scaleX, scaleY, resize, transition, boundsType) {
6301
+ zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize, transition, boundsType);
6296
6302
  }
6297
6303
  rotateOfWorld(worldOrigin, rotation) {
6298
6304
  rotateOfWorld(this, worldOrigin, rotation);
@@ -6303,7 +6309,7 @@ var LeaferUI = function(exports) {
6303
6309
  flip(axis, transition) {
6304
6310
  transform(this, getFlipTransform(this, axis), false, transition);
6305
6311
  }
6306
- scaleResize(scaleX, scaleY = scaleX, _noResize) {
6312
+ scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6307
6313
  this.scaleX *= scaleX;
6308
6314
  this.scaleY *= scaleY;
6309
6315
  }
@@ -6668,7 +6674,7 @@ var LeaferUI = function(exports) {
6668
6674
  this.levelMap = null;
6669
6675
  }
6670
6676
  }
6671
- const version = "2.1.2";
6677
+ const version = "2.1.4";
6672
6678
  class LeaferCanvas extends LeaferCanvasBase {
6673
6679
  get allowBackgroundColor() {
6674
6680
  return true;
@@ -11036,7 +11042,7 @@ var LeaferUI = function(exports) {
11036
11042
  needUpdate = false;
11037
11043
  }
11038
11044
  }
11039
- if (paint.mode === "brush") PaintImage.brush(leafPaint);
11045
+ if (paint.mode === "brush") PaintImage.brush(leafPaint, ui);
11040
11046
  if (!leafPaint.data) {
11041
11047
  PaintImage.createData(leafPaint, image, paint, boxBounds);
11042
11048
  const {transform: transform} = leafPaint.data, {opacity: opacity} = paint;
@@ -11269,8 +11275,12 @@ var LeaferUI = function(exports) {
11269
11275
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
11270
11276
  }
11271
11277
  const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
11272
- const pattern = brush ? imageCanvas : image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11273
- paint.style = pattern;
11278
+ if (brush) {
11279
+ paint.style = imageCanvas;
11280
+ PaintImage.cacheBrush(paint, ui, canvas, renderOptions);
11281
+ } else {
11282
+ paint.style = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11283
+ }
11274
11284
  paint.patternId = id;
11275
11285
  }
11276
11286
  }