@leafer-draw/miniapp 2.1.4 → 2.1.6

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.
@@ -221,7 +221,7 @@ const IncrementId = {
221
221
  RUNTIME: "runtime",
222
222
  LEAF: "leaf",
223
223
  TASK: "task",
224
- CNAVAS: "canvas",
224
+ CANVAS: "canvas",
225
225
  IMAGE: "image",
226
226
  types: {},
227
227
  create(typeName) {
@@ -875,7 +875,7 @@ const PointHelper = {
875
875
  return quick ? t.x === point.x && t.y === point.y : float$1(t.x) === float$1(point.x) && float$1(t.y) === float$1(point.y);
876
876
  },
877
877
  reset(t) {
878
- P$5.reset(t);
878
+ t.x = t.y = 0;
879
879
  }
880
880
  };
881
881
 
@@ -1084,6 +1084,7 @@ class Matrix {
1084
1084
  }
1085
1085
  reset() {
1086
1086
  MatrixHelper.reset(this);
1087
+ return this;
1087
1088
  }
1088
1089
  }
1089
1090
 
@@ -2346,7 +2347,7 @@ class LeaferCanvasBase extends Canvas$1 {
2346
2347
  this.worldTransform = {};
2347
2348
  if (!config) config = minSize;
2348
2349
  this.manager = manager;
2349
- this.innerId = IncrementId.create(IncrementId.CNAVAS);
2350
+ this.innerId = IncrementId.create(IncrementId.CANVAS);
2350
2351
  const {width: width, height: height, pixelRatio: pixelRatio} = config;
2351
2352
  this.autoLayout = !width || !height;
2352
2353
  this.size.pixelRatio = pixelRatio || Platform.devicePixelRatio;
@@ -2496,6 +2497,7 @@ class LeaferCanvasBase extends Canvas$1 {
2496
2497
  }
2497
2498
  useGrayscaleAlpha(bounds) {
2498
2499
  this.setTempPixelBounds(bounds, true, true);
2500
+ if (!tempPixelBounds.width || !tempPixelBounds.height) return;
2499
2501
  let alpha, pixel;
2500
2502
  const {context: context} = this, imageData = context.getImageData(tempPixelBounds.x, tempPixelBounds.y, tempPixelBounds.width, tempPixelBounds.height), {data: data} = imageData;
2501
2503
  for (let i = 0, len = data.length; i < len; i += 4) {
@@ -3720,7 +3722,7 @@ const {arcTo: arcTo} = PathCommandDataHelper;
3720
3722
 
3721
3723
  const PathCorner = {
3722
3724
  smooth(data, cornerRadius, _cornerSmoothing) {
3723
- let command, lastCommand, commandLen;
3725
+ let command, lastCommand, commandLen, startXIndex, startYIndex, smoothLen;
3724
3726
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3725
3727
  if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
3726
3728
  const len = data.length, three = len === 9;
@@ -3729,6 +3731,11 @@ const PathCorner = {
3729
3731
  command = data[i];
3730
3732
  switch (command) {
3731
3733
  case M:
3734
+ smoothLen = smooth.length;
3735
+ if (smoothLen && lastCommand !== Z) {
3736
+ smooth[startXIndex] = startX;
3737
+ smooth[startYIndex] = startY;
3738
+ }
3732
3739
  startX = lastX = data[i + 1];
3733
3740
  startY = lastY = data[i + 2];
3734
3741
  i += 3;
@@ -3739,6 +3746,8 @@ const PathCorner = {
3739
3746
  } else {
3740
3747
  smooth.push(M, startX, startY);
3741
3748
  }
3749
+ startXIndex = smoothLen + 1;
3750
+ startYIndex = smoothLen + 2;
3742
3751
  break;
3743
3752
 
3744
3753
  case L$1:
@@ -3777,8 +3786,8 @@ const PathCorner = {
3777
3786
  lastCommand = command;
3778
3787
  }
3779
3788
  if (command !== Z) {
3780
- smooth[1] = startX;
3781
- smooth[2] = startY;
3789
+ smooth[startXIndex] = startX;
3790
+ smooth[startYIndex] = startY;
3782
3791
  }
3783
3792
  return smooth;
3784
3793
  }
@@ -5519,6 +5528,7 @@ class LeafLayout {
5519
5528
  this.renderChanged = true;
5520
5529
  this.renderSpread || (this.renderSpread = 1);
5521
5530
  this.boundsChanged = true;
5531
+ this.hitCanvasChanged = true;
5522
5532
  }
5523
5533
  scaleChange() {
5524
5534
  this.scaleChanged = true;
@@ -6459,10 +6469,6 @@ let Leaf = class Leaf {
6459
6469
  }
6460
6470
  }
6461
6471
  }
6462
- set(_data, _isTemp) {}
6463
- get(_name) {
6464
- return undefined;
6465
- }
6466
6472
  setAttr(name, value) {
6467
6473
  this[name] = value;
6468
6474
  }
@@ -6479,37 +6485,10 @@ let Leaf = class Leaf {
6479
6485
  toString(options) {
6480
6486
  return JSON.stringify(this.toJSON(options));
6481
6487
  }
6482
- toSVG() {
6483
- return undefined;
6484
- }
6485
- __SVG(_data) {}
6486
- toHTML() {
6487
- return undefined;
6488
- }
6489
- __setAttr(_attrName, _newValue) {
6490
- return true;
6491
- }
6492
- __getAttr(_attrName) {
6493
- return undefined;
6494
- }
6495
- setProxyAttr(_attrName, _newValue) {}
6496
- getProxyAttr(_attrName) {
6497
- return undefined;
6498
- }
6499
- find(_condition, _options) {
6500
- return undefined;
6501
- }
6502
- findTag(_tag) {
6503
- return undefined;
6504
- }
6505
- findOne(_condition, _options) {
6506
- return undefined;
6507
- }
6508
- findId(_id) {
6509
- return undefined;
6488
+ scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6489
+ this.scaleX *= scaleX;
6490
+ this.scaleY *= scaleY;
6510
6491
  }
6511
- focus(_value) {}
6512
- updateState() {}
6513
6492
  updateLayout() {
6514
6493
  this.__layout.update();
6515
6494
  }
@@ -6525,27 +6504,6 @@ let Leaf = class Leaf {
6525
6504
  __extraUpdate() {
6526
6505
  if (this.leaferIsReady) this.leafer.layouter.addExtra(this);
6527
6506
  }
6528
- __updateWorldMatrix() {}
6529
- __updateLocalMatrix() {}
6530
- __updateWorldBounds() {}
6531
- __updateLocalBounds() {}
6532
- __updateLocalBoxBounds() {}
6533
- __updateLocalStrokeBounds() {}
6534
- __updateLocalRenderBounds() {}
6535
- __updateBoxBounds(_secondLayout, _bounds) {}
6536
- __updateContentBounds() {}
6537
- __updateStrokeBounds(_bounds) {}
6538
- __updateRenderBounds(_bounds) {}
6539
- __updateAutoLayout() {}
6540
- __updateFlowLayout() {}
6541
- __updateNaturalSize() {}
6542
- __updateStrokeSpread() {
6543
- return 0;
6544
- }
6545
- __updateRenderSpread() {
6546
- return 0;
6547
- }
6548
- __onUpdateSize() {}
6549
6507
  __updateEraser(value) {
6550
6508
  this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
6551
6509
  }
@@ -6559,7 +6517,6 @@ let Leaf = class Leaf {
6559
6517
  __updateMask(_value) {
6560
6518
  this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6561
6519
  }
6562
- __renderMask(_canvas, _options) {}
6563
6520
  __getNowWorld(options) {
6564
6521
  if (options.matrix) {
6565
6522
  if (!this.__cameraWorld) this.__cameraWorld = {};
@@ -6715,76 +6672,12 @@ let Leaf = class Leaf {
6715
6672
  flip(axis, transition) {
6716
6673
  transform(this, getFlipTransform(this, axis), false, transition);
6717
6674
  }
6718
- scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6719
- this.scaleX *= scaleX;
6720
- this.scaleY *= scaleY;
6721
- }
6722
- __scaleResize(_scaleX, _scaleY) {}
6723
- resizeWidth(_width) {}
6724
- resizeHeight(_height) {}
6725
- hit(_world, _hitRadius) {
6726
- return true;
6727
- }
6728
- __hitWorld(_point, _forceHitFill) {
6729
- return true;
6730
- }
6731
- __hit(_local, _forceHitFill) {
6732
- return true;
6733
- }
6734
- __hitFill(_inner) {
6735
- return true;
6736
- }
6737
- __hitStroke(_inner, _strokeWidth) {
6738
- return true;
6739
- }
6740
- __hitPixel(_inner) {
6741
- return true;
6742
- }
6743
- __drawHitPath(_canvas) {}
6744
- __updateHitCanvas() {}
6745
- __render(_canvas, _options) {}
6746
- __drawFast(_canvas, _options) {}
6747
- __draw(_canvas, _options, _originCanvas) {}
6748
- __clip(_canvas, _options) {}
6749
- __renderShape(_canvas, _options) {}
6750
- __drawShape(_canvas, _options) {}
6751
- __updateWorldOpacity() {}
6752
- __updateChange() {}
6753
- __drawPath(_canvas) {}
6754
- __drawRenderPath(_canvas) {}
6755
- __updatePath() {}
6756
- __updateRenderPath(_updateCache) {}
6757
- getMotionPathData() {
6758
- return Plugin.need("path");
6759
- }
6760
- getMotionPoint(_motionDistance) {
6761
- return Plugin.need("path");
6762
- }
6763
- getMotionTotal() {
6764
- return 0;
6765
- }
6766
- __updateMotionPath() {}
6767
- __runAnimation(_type, _complete) {}
6768
- __updateSortChildren() {}
6769
- add(_child, _index) {}
6770
6675
  remove(_child, destroy) {
6771
6676
  if (this.parent) this.parent.remove(this, destroy);
6772
6677
  }
6773
6678
  dropTo(parent, index, resize) {
6774
6679
  drop(this, parent, index, resize);
6775
6680
  }
6776
- on(_type, _listener, _options) {}
6777
- off(_type, _listener, _options) {}
6778
- on_(_type, _listener, _bind, _options) {
6779
- return undefined;
6780
- }
6781
- off_(_id) {}
6782
- once(_type, _listener, _captureOrBind, _capture) {}
6783
- emit(_type, _event, _capture) {}
6784
- emitEvent(_event, _capture) {}
6785
- hasEvent(_type, _capture) {
6786
- return false;
6787
- }
6788
6681
  static changeAttr(attrName, defaultValue, fn) {
6789
6682
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
6790
6683
  }
@@ -7090,7 +6983,7 @@ class LeafLevelList {
7090
6983
  }
7091
6984
  }
7092
6985
 
7093
- const version = "2.1.4";
6986
+ const version = "2.1.6";
7094
6987
 
7095
6988
  class LeaferCanvas extends LeaferCanvasBase {
7096
6989
  get allowBackgroundColor() {
@@ -8536,17 +8429,12 @@ let UI = UI_1 = class UI extends Leaf {
8536
8429
  if (!path) this.__drawPathByBox(pen);
8537
8430
  return pen;
8538
8431
  }
8539
- reset(_data) {}
8540
8432
  set(data, _transition) {
8541
8433
  if (data) Object.assign(this, data);
8542
8434
  }
8543
8435
  get(name) {
8544
8436
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
8545
8437
  }
8546
- createProxyData() {
8547
- return undefined;
8548
- }
8549
- clearProxyData() {}
8550
8438
  find(_condition, _options) {
8551
8439
  return Plugin.need("find");
8552
8440
  }
@@ -8584,6 +8472,7 @@ let UI = UI_1 = class UI extends Leaf {
8584
8472
  data.lazy && !this.__inLazyBounds && !Export.running ? data.__needComputePaint = true : data.__computePaint();
8585
8473
  }
8586
8474
  }
8475
+ __updatePath() {}
8587
8476
  __updateRenderPath(updateCache) {
8588
8477
  const data = this.__;
8589
8478
  if (data.path) {
@@ -8619,7 +8508,6 @@ let UI = UI_1 = class UI extends Leaf {
8619
8508
  this.set(keyframe);
8620
8509
  return Plugin.need("animate");
8621
8510
  }
8622
- killAnimate(_type, _nextStyle) {}
8623
8511
  export(_filename, _options) {
8624
8512
  return Plugin.need("export");
8625
8513
  }
@@ -8795,8 +8683,6 @@ __decorate([ dataType(100) ], UI.prototype, "placeholderDelay", void 0);
8795
8683
 
8796
8684
  __decorate([ dataType({}) ], UI.prototype, "data", void 0);
8797
8685
 
8798
- __decorate([ rewrite(Leaf.prototype.reset) ], UI.prototype, "reset", null);
8799
-
8800
8686
  UI = UI_1 = __decorate([ useModule(UIBounds), useModule(UIRender), rewriteAble() ], UI);
8801
8687
 
8802
8688
  let Group = class Group extends UI {
@@ -8833,9 +8719,6 @@ let Group = class Group extends UI {
8833
8719
  }
8834
8720
  return data;
8835
8721
  }
8836
- pick(_hitPoint, _options) {
8837
- return undefined;
8838
- }
8839
8722
  addAt(child, index) {
8840
8723
  this.add(child, index);
8841
8724
  }
@@ -8845,11 +8728,6 @@ let Group = class Group extends UI {
8845
8728
  addBefore(child, before) {
8846
8729
  this.add(child, this.children.indexOf(before));
8847
8730
  }
8848
- add(_child, _index) {}
8849
- addMany(..._children) {}
8850
- remove(_child, _destroy) {}
8851
- removeAll(_destroy) {}
8852
- clear() {}
8853
8731
  };
8854
8732
 
8855
8733
  __decorate([ dataProcessor(GroupData) ], Group.prototype, "__", void 0);
@@ -9823,51 +9701,6 @@ let Pen = class Pen extends Group {
9823
9701
  this.add(path);
9824
9702
  return this;
9825
9703
  }
9826
- beginPath() {
9827
- return this;
9828
- }
9829
- moveTo(_x, _y) {
9830
- return this;
9831
- }
9832
- lineTo(_x, _y) {
9833
- return this;
9834
- }
9835
- bezierCurveTo(_x1, _y1, _x2, _y2, _x, _y) {
9836
- return this;
9837
- }
9838
- quadraticCurveTo(_x1, _y1, _x, _y) {
9839
- return this;
9840
- }
9841
- closePath() {
9842
- return this;
9843
- }
9844
- rect(_x, _y, _width, _height) {
9845
- return this;
9846
- }
9847
- roundRect(_x, _y, _width, _height, _cornerRadius) {
9848
- return this;
9849
- }
9850
- ellipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) {
9851
- return this;
9852
- }
9853
- arc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) {
9854
- return this;
9855
- }
9856
- arcTo(_x1, _y1, _x2, _y2, _radius) {
9857
- return this;
9858
- }
9859
- drawEllipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) {
9860
- return this;
9861
- }
9862
- drawArc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) {
9863
- return this;
9864
- }
9865
- drawPoints(_points, _curve, _close) {
9866
- return this;
9867
- }
9868
- clearPath() {
9869
- return this;
9870
- }
9871
9704
  paint() {
9872
9705
  const {pathElement: pathElement} = this;
9873
9706
  if (!pathElement.__layout.boxChanged) pathElement.forceUpdate("path");
@@ -10333,7 +10166,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
10333
10166
  needUpdate = false;
10334
10167
  }
10335
10168
  }
10336
- if (paint.mode === "brush") PaintImage.brush(leafPaint, ui);
10169
+ if (paint.mode === "brush") PaintImage.brush(leafPaint, ui, attrName);
10337
10170
  if (!leafPaint.data) {
10338
10171
  PaintImage.createData(leafPaint, image, paint, boxBounds);
10339
10172
  const {transform: transform} = leafPaint.data, {opacity: opacity} = paint;
@@ -10428,8 +10261,9 @@ function getPatternData(paint, box, image) {
10428
10261
  break;
10429
10262
 
10430
10263
  case "repeat":
10431
- case "brush":
10432
10264
  if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
10265
+
10266
+ case "brush":
10433
10267
  if (!repeat) data.repeat = "repeat";
10434
10268
  const count = isObject(repeat);
10435
10269
  if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
@@ -10440,7 +10274,7 @@ function getPatternData(paint, box, image) {
10440
10274
  default:
10441
10275
  if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10442
10276
  }
10443
- if (!data.transform) {
10277
+ if (!data.transform && mode !== "brush") {
10444
10278
  if (box.x || box.y) translate$1(data.transform = get$3(), box.x, box.y);
10445
10279
  }
10446
10280
  if (scaleX) {
@@ -10569,8 +10403,9 @@ function createPattern(paint, ui, canvas, renderOptions) {
10569
10403
  let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
10570
10404
  if (paint.patternId !== id && !ui.destroyed) {
10571
10405
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
10572
- const {image: image, brush: brush, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
10573
- let imageMatrix, xGap, yGap, {width: width, height: height} = image;
10406
+ const {image: image, brush: brush, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
10407
+ let imageMatrix, xGap, yGap, {width: width, height: height} = image, {opacity: opacity} = paint.originPaint;
10408
+ if (brush || opacity === 1) opacity = undefined;
10574
10409
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
10575
10410
  width *= scaleX;
10576
10411
  height *= scaleY;