leafer-ui 1.0.0-rc.11 → 1.0.0-rc.16

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
@@ -32,7 +32,7 @@ var LeaferUI = (function (exports) {
32
32
  };
33
33
  const I$2 = IncrementId;
34
34
 
35
- const { round: round$1, pow: pow$1, PI: PI$4 } = Math;
35
+ const { round, pow: pow$1, PI: PI$4 } = Math;
36
36
  const MathHelper = {
37
37
  within(value, min, max) {
38
38
  if (value < min)
@@ -94,7 +94,7 @@ var LeaferUI = (function (exports) {
94
94
  },
95
95
  float(num, maxLength) {
96
96
  const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
97
- num = round$1(num * a) / a;
97
+ num = round(num * a) / a;
98
98
  return num === -0 ? 0 : num;
99
99
  }
100
100
  };
@@ -406,6 +406,10 @@ var LeaferUI = (function (exports) {
406
406
  t.x = point.x;
407
407
  t.y = point.y;
408
408
  },
409
+ copyFrom(t, x, y) {
410
+ t.x = x;
411
+ t.y = y;
412
+ },
409
413
  move(t, x, y) {
410
414
  t.x += x;
411
415
  t.y += y;
@@ -433,19 +437,19 @@ var LeaferUI = (function (exports) {
433
437
  },
434
438
  tempToInnerOf(t, matrix) {
435
439
  const { tempPoint: temp } = P$5;
436
- P$5.copy(temp, t);
440
+ copy$a(temp, t);
437
441
  toInnerPoint$2(matrix, temp, temp);
438
442
  return temp;
439
443
  },
440
444
  tempToOuterOf(t, matrix) {
441
445
  const { tempPoint: temp } = P$5;
442
- P$5.copy(temp, t);
446
+ copy$a(temp, t);
443
447
  toOuterPoint$2(matrix, temp, temp);
444
448
  return temp;
445
449
  },
446
450
  tempToInnerRadiusPointOf(t, matrix) {
447
451
  const { tempRadiusPoint: temp } = P$5;
448
- P$5.copy(temp, t);
452
+ copy$a(temp, t);
449
453
  P$5.toInnerRadiusPointOf(t, matrix, temp);
450
454
  return temp;
451
455
  },
@@ -471,7 +475,7 @@ var LeaferUI = (function (exports) {
471
475
  return y1 + (y2 - y1) / 2;
472
476
  },
473
477
  getDistance(t, point) {
474
- return P$5.getDistanceFrom(t.x, t.y, point.x, point.y);
478
+ return getDistanceFrom(t.x, t.y, point.x, point.y);
475
479
  },
476
480
  getDistanceFrom(x1, y1, x2, y2) {
477
481
  const x = abs$4(x2 - x1);
@@ -479,10 +483,10 @@ var LeaferUI = (function (exports) {
479
483
  return sqrt$2(x * x + y * y);
480
484
  },
481
485
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
482
- return min$1(P$5.getDistanceFrom(x1, y1, x2, y2), P$5.getDistanceFrom(x2, y2, x3, y3));
486
+ return min$1(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3));
483
487
  },
484
488
  getAngle(t, to) {
485
- return P$5.getAtan2(t, to) / OneRadian;
489
+ return getAtan2(t, to) / OneRadian;
486
490
  },
487
491
  getRotation(t, origin, to, toOrigin) {
488
492
  if (!toOrigin)
@@ -500,15 +504,19 @@ var LeaferUI = (function (exports) {
500
504
  getAtan2(t, to) {
501
505
  return atan2$2(to.y - t.y, to.x - t.x);
502
506
  },
503
- getDistancePoint(t, to, distance) {
504
- const r = P$5.getAtan2(t, to);
505
- return { x: t.x + cos$4(r) * distance, y: t.y + sin$4(r) * distance };
507
+ getDistancePoint(t, to, distance, changeTo) {
508
+ const r = getAtan2(t, to);
509
+ to = changeTo ? to : {};
510
+ to.x = t.x + cos$4(r) * distance;
511
+ to.y = t.y + sin$4(r) * distance;
512
+ return to;
506
513
  },
507
514
  reset(t) {
508
515
  P$5.reset(t);
509
516
  }
510
517
  };
511
518
  const P$5 = PointHelper;
519
+ const { getDistanceFrom, copy: copy$a, getAtan2 } = P$5;
512
520
 
513
521
  class Point {
514
522
  constructor(x, y) {
@@ -562,8 +570,8 @@ var LeaferUI = (function (exports) {
562
570
  getDistance(to) {
563
571
  return PointHelper.getDistance(this, to);
564
572
  }
565
- getDistancePoint(to, distance) {
566
- return new Point(PointHelper.getDistancePoint(this, to, distance));
573
+ getDistancePoint(to, distance, changeTo) {
574
+ return new Point(PointHelper.getDistancePoint(this, to, distance, changeTo));
567
575
  }
568
576
  getAngle(to) {
569
577
  return PointHelper.getAngle(this, to);
@@ -717,7 +725,7 @@ var LeaferUI = (function (exports) {
717
725
  const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
718
726
  const { toOuterPoint: toOuterPoint$1 } = MatrixHelper;
719
727
  const { float } = MathHelper;
720
- const { floor, ceil: ceil$1 } = Math;
728
+ const { floor, ceil: ceil$2 } = Math;
721
729
  let right$1, bottom$1, boundsRight, boundsBottom;
722
730
  const point = {};
723
731
  const toPoint$1 = {};
@@ -849,8 +857,8 @@ var LeaferUI = (function (exports) {
849
857
  const { x, y } = t;
850
858
  t.x = floor(t.x);
851
859
  t.y = floor(t.y);
852
- t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
853
- t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
860
+ t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
861
+ t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
854
862
  },
855
863
  unsign(t) {
856
864
  if (t.width < 0) {
@@ -1434,6 +1442,8 @@ var LeaferUI = (function (exports) {
1434
1442
  if (value !== undefined)
1435
1443
  return value;
1436
1444
  }
1445
+ if (name === 'path' && !this.__pathInputed)
1446
+ return;
1437
1447
  return this['_' + name];
1438
1448
  }
1439
1449
  __removeInput(name) {
@@ -1447,6 +1457,8 @@ var LeaferUI = (function (exports) {
1447
1457
  if (key[0] !== '_') {
1448
1458
  value = this['_' + key];
1449
1459
  if (value !== undefined) {
1460
+ if (key === 'path' && !this.__pathInputed)
1461
+ continue;
1450
1462
  inputValue = __input ? __input[key] : undefined;
1451
1463
  data[key] = (inputValue === undefined) ? value : inputValue;
1452
1464
  }
@@ -1476,6 +1488,9 @@ var LeaferUI = (function (exports) {
1476
1488
  t.__single = true;
1477
1489
  }
1478
1490
  }
1491
+ __removeNaturalSize() {
1492
+ this.__naturalWidth = this.__naturalHeight = undefined;
1493
+ }
1479
1494
  destroy() {
1480
1495
  this.__input = this.__middle = null;
1481
1496
  }
@@ -1963,7 +1978,7 @@ var LeaferUI = (function (exports) {
1963
1978
  this.setStrokeOptions(options);
1964
1979
  }
1965
1980
  setStrokeOptions(options) {
1966
- this.strokeCap = options.strokeCap;
1981
+ this.strokeCap = options.strokeCap === 'none' ? 'butt' : options.strokeCap;
1967
1982
  this.strokeJoin = options.strokeJoin;
1968
1983
  this.dashPattern = options.dashPattern;
1969
1984
  this.dashOffset = options.dashOffset;
@@ -2186,7 +2201,7 @@ var LeaferUI = (function (exports) {
2186
2201
  }
2187
2202
  };
2188
2203
 
2189
- const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2204
+ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2190
2205
  const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2191
2206
  const { set: set$2 } = PointHelper;
2192
2207
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
@@ -2300,7 +2315,7 @@ var LeaferUI = (function (exports) {
2300
2315
  totalRadian -= PI2;
2301
2316
  if (anticlockwise)
2302
2317
  totalRadian -= PI2;
2303
- const parts = ceil(abs$3(totalRadian / PI_2));
2318
+ const parts = ceil$1(abs$3(totalRadian / PI_2));
2304
2319
  const partRadian = totalRadian / parts;
2305
2320
  const partRadian4Sin = sin$3(partRadian / 4);
2306
2321
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -2786,22 +2801,12 @@ var LeaferUI = (function (exports) {
2786
2801
  }
2787
2802
  },
2788
2803
  drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2789
- if (rotation === undefined)
2790
- rotation = 0;
2791
- if (startAngle === undefined)
2792
- startAngle = 0;
2793
- if (endAngle === undefined)
2794
- endAngle = 360;
2795
- BezierHelper.ellipse(null, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise, null, null, startPoint);
2804
+ BezierHelper.ellipse(null, x, y, radiusX, radiusY, rotation === undefined ? 0 : rotation, startAngle === undefined ? 0 : startAngle, endAngle === undefined ? 360 : endAngle, anticlockwise, null, null, startPoint);
2796
2805
  data.push(M$3, startPoint.x, startPoint.y);
2797
2806
  ellipse$3(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2798
2807
  },
2799
2808
  drawArc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
2800
- if (startAngle === undefined)
2801
- startAngle = 0;
2802
- if (endAngle === undefined)
2803
- endAngle = 360;
2804
- BezierHelper.arc(null, x, y, radius, startAngle, endAngle, anticlockwise, null, null, startPoint);
2809
+ BezierHelper.arc(null, x, y, radius, startAngle === undefined ? 0 : startAngle, endAngle === undefined ? 360 : endAngle, anticlockwise, null, null, startPoint);
2805
2810
  data.push(M$3, startPoint.x, startPoint.y);
2806
2811
  arc$2(data, x, y, radius, startAngle, endAngle, anticlockwise);
2807
2812
  },
@@ -2813,68 +2818,70 @@ var LeaferUI = (function (exports) {
2813
2818
 
2814
2819
  const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$1, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
2815
2820
  class PathCreator {
2821
+ set path(value) { this.__path = value; }
2822
+ get path() { return this.__path; }
2816
2823
  constructor(path) {
2817
2824
  if (path) {
2818
- this.path = typeof path === 'string' ? PathHelper.parse(path) : path;
2825
+ this.__path = typeof path === 'string' ? PathHelper.parse(path) : path;
2819
2826
  }
2820
2827
  else {
2821
- this.path = [];
2828
+ this.__path = [];
2822
2829
  }
2823
2830
  }
2824
2831
  beginPath() {
2825
- beginPath(this.path);
2832
+ beginPath(this.__path);
2826
2833
  return this;
2827
2834
  }
2828
2835
  moveTo(x, y) {
2829
- moveTo$4(this.path, x, y);
2836
+ moveTo$4(this.__path, x, y);
2830
2837
  return this;
2831
2838
  }
2832
2839
  lineTo(x, y) {
2833
- lineTo$3(this.path, x, y);
2840
+ lineTo$3(this.__path, x, y);
2834
2841
  return this;
2835
2842
  }
2836
2843
  bezierCurveTo(x1, y1, x2, y2, x, y) {
2837
- bezierCurveTo(this.path, x1, y1, x2, y2, x, y);
2844
+ bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
2838
2845
  return this;
2839
2846
  }
2840
2847
  quadraticCurveTo(x1, y1, x, y) {
2841
- quadraticCurveTo(this.path, x1, y1, x, y);
2848
+ quadraticCurveTo(this.__path, x1, y1, x, y);
2842
2849
  return this;
2843
2850
  }
2844
2851
  closePath() {
2845
- closePath$3(this.path);
2852
+ closePath$3(this.__path);
2846
2853
  return this;
2847
2854
  }
2848
2855
  rect(x, y, width, height) {
2849
- rect$1(this.path, x, y, width, height);
2856
+ rect$1(this.__path, x, y, width, height);
2850
2857
  return this;
2851
2858
  }
2852
2859
  roundRect(x, y, width, height, cornerRadius) {
2853
- roundRect$1(this.path, x, y, width, height, cornerRadius);
2860
+ roundRect$1(this.__path, x, y, width, height, cornerRadius);
2854
2861
  return this;
2855
2862
  }
2856
2863
  ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2857
- ellipse$2(this.path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2864
+ ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2858
2865
  return this;
2859
2866
  }
2860
2867
  arc(x, y, radius, startAngle, endAngle, anticlockwise) {
2861
- arc$1(this.path, x, y, radius, startAngle, endAngle, anticlockwise);
2868
+ arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
2862
2869
  return this;
2863
2870
  }
2864
2871
  arcTo(x1, y1, x2, y2, radius) {
2865
- arcTo$2(this.path, x1, y1, x2, y2, radius);
2872
+ arcTo$2(this.__path, x1, y1, x2, y2, radius);
2866
2873
  return this;
2867
2874
  }
2868
2875
  drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2869
- drawEllipse(this.path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2876
+ drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2870
2877
  return this;
2871
2878
  }
2872
2879
  drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
2873
- drawArc(this.path, x, y, radius, startAngle, endAngle, anticlockwise);
2880
+ drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
2874
2881
  return this;
2875
2882
  }
2876
2883
  drawPoints(points, curve, close) {
2877
- drawPoints$2(this.path, points, curve, close);
2884
+ drawPoints$2(this.__path, points, curve, close);
2878
2885
  return this;
2879
2886
  }
2880
2887
  }
@@ -3623,9 +3630,35 @@ var LeaferUI = (function (exports) {
3623
3630
  defineLeafAttr(target, key, defaultValue, {
3624
3631
  set(value) {
3625
3632
  this.__setAttr(key, value);
3626
- this.__layout.boxChanged || this.__layout.boxChange();
3627
- if (this.__hasAutoLayout)
3628
- this.__layout.matrixChanged || this.__layout.matrixChange();
3633
+ doBoundsType(this);
3634
+ }
3635
+ });
3636
+ };
3637
+ }
3638
+ function naturalBoundsType(defaultValue) {
3639
+ return (target, key) => {
3640
+ defineLeafAttr(target, key, defaultValue, {
3641
+ set(value) {
3642
+ this.__setAttr(key, value);
3643
+ doBoundsType(this);
3644
+ this.__.__removeNaturalSize();
3645
+ }
3646
+ });
3647
+ };
3648
+ }
3649
+ function doBoundsType(leaf) {
3650
+ leaf.__layout.boxChanged || leaf.__layout.boxChange();
3651
+ if (leaf.__hasAutoLayout)
3652
+ leaf.__layout.matrixChanged || leaf.__layout.matrixChange();
3653
+ }
3654
+ function pathInputType(defaultValue) {
3655
+ return (target, key) => {
3656
+ defineLeafAttr(target, key, defaultValue, {
3657
+ set(value) {
3658
+ if (this.__.__pathInputed !== 2)
3659
+ this.__.__pathInputed = value ? 1 : 0;
3660
+ this.__setAttr(key, value);
3661
+ doBoundsType(this);
3629
3662
  }
3630
3663
  });
3631
3664
  };
@@ -3636,11 +3669,14 @@ var LeaferUI = (function (exports) {
3636
3669
  defineLeafAttr(target, key, defaultValue, {
3637
3670
  set(value) {
3638
3671
  this.__setAttr(key, value);
3639
- this.__layout.strokeChanged || this.__layout.strokeChange();
3672
+ doStrokeType(this);
3640
3673
  }
3641
3674
  });
3642
3675
  };
3643
3676
  }
3677
+ function doStrokeType(leaf) {
3678
+ leaf.__layout.strokeChanged || leaf.__layout.strokeChange();
3679
+ }
3644
3680
  const strokeType = affectStrokeBoundsType;
3645
3681
  function affectRenderBoundsType(defaultValue) {
3646
3682
  return (target, key) => {
@@ -4260,6 +4296,7 @@ var LeaferUI = (function (exports) {
4260
4296
  }
4261
4297
  ChildEvent.ADD = 'child.add';
4262
4298
  ChildEvent.REMOVE = 'child.remove';
4299
+ ChildEvent.DESTROY = 'child.destroy';
4263
4300
 
4264
4301
  class PropertyEvent extends Event {
4265
4302
  constructor(type, target, attrName, oldValue, newValue) {
@@ -4707,6 +4744,7 @@ var LeaferUI = (function (exports) {
4707
4744
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2, hasParentAutoLayout } = LeafHelper;
4708
4745
  const { updateBounds: updateBounds$1 } = BranchHelper;
4709
4746
  const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
4747
+ const { toBounds: toBounds$2 } = PathBounds;
4710
4748
  const LeafBounds = {
4711
4749
  __updateWorldBounds() {
4712
4750
  toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
@@ -4718,7 +4756,8 @@ var LeaferUI = (function (exports) {
4718
4756
  __updateLocalBounds() {
4719
4757
  const layout = this.__layout;
4720
4758
  if (layout.boxChanged) {
4721
- this.__updatePath();
4759
+ if (!this.__.__pathInputed)
4760
+ this.__updatePath();
4722
4761
  this.__updateRenderPath();
4723
4762
  this.__updateBoxBounds();
4724
4763
  layout.boxChanged = false;
@@ -4785,11 +4824,16 @@ var LeaferUI = (function (exports) {
4785
4824
  },
4786
4825
  __updateBoxBounds() {
4787
4826
  const b = this.__layout.boxBounds;
4788
- const { width, height } = this.__;
4789
- b.x = 0;
4790
- b.y = 0;
4791
- b.width = width;
4792
- b.height = height;
4827
+ const data = this.__;
4828
+ if (data.__pathInputed) {
4829
+ toBounds$2(data.__pathForRender, b);
4830
+ }
4831
+ else {
4832
+ b.x = 0;
4833
+ b.y = 0;
4834
+ b.width = data.width;
4835
+ b.height = data.height;
4836
+ }
4793
4837
  },
4794
4838
  __updateAutoLayout() {
4795
4839
  this.__layout.matrixChanged = true;
@@ -4918,6 +4962,9 @@ var LeaferUI = (function (exports) {
4918
4962
  get innerName() { return this.__.name || this.tag + this.innerId; }
4919
4963
  get __DataProcessor() { return LeafData; }
4920
4964
  get __LayoutProcessor() { return LeafLayout; }
4965
+ get isLeafer() { return false; }
4966
+ get isBranch() { return false; }
4967
+ get isBranchLeaf() { return false; }
4921
4968
  get __localMatrix() { return this.__local || this.__layout; }
4922
4969
  get __localBoxBounds() { return this.__local || this.__layout; }
4923
4970
  get worldTransform() { return this.__layout.getTransform('world'); }
@@ -4931,6 +4978,7 @@ var LeaferUI = (function (exports) {
4931
4978
  get __worldFlipped() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
4932
4979
  get __onlyHitMask() { return this.__hasMask && !this.__.hitChildren; }
4933
4980
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
4981
+ get pathInputed() { return !!this.__.__pathInputed; }
4934
4982
  constructor(data) {
4935
4983
  this.innerId = create(LEAF);
4936
4984
  this.reset(data);
@@ -4982,7 +5030,7 @@ var LeaferUI = (function (exports) {
4982
5030
  }
4983
5031
  }
4984
5032
  set(_data) { }
4985
- get() { return undefined; }
5033
+ get(_name) { return undefined; }
4986
5034
  toJSON() {
4987
5035
  return this.__.__getInputData();
4988
5036
  }
@@ -5199,10 +5247,13 @@ var LeaferUI = (function (exports) {
5199
5247
  }
5200
5248
  destroy() {
5201
5249
  if (!this.destroyed) {
5202
- if (this.parent)
5250
+ const { parent } = this;
5251
+ if (parent)
5203
5252
  this.remove();
5204
5253
  if (this.children)
5205
5254
  this.removeAll(true);
5255
+ if (this.hasEvent(ChildEvent.DESTROY))
5256
+ this.emitEvent(new ChildEvent(ChildEvent.DESTROY, this, parent));
5206
5257
  this.__.destroy();
5207
5258
  this.__layout.destroy();
5208
5259
  this.__captureMap = this.__bubbleMap = this.__parentWait = this.__leaferWait = null;
@@ -5222,11 +5273,6 @@ var LeaferUI = (function (exports) {
5222
5273
  const { sort } = BranchHelper;
5223
5274
  const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5224
5275
  exports.Branch = class Branch extends exports.Leaf {
5225
- constructor() {
5226
- super();
5227
- this.isBranch = true;
5228
- this.children = [];
5229
- }
5230
5276
  __updateStrokeSpread() {
5231
5277
  const { children } = this;
5232
5278
  for (let i = 0, len = children.length; i < len; i++) {
@@ -5266,6 +5312,8 @@ var LeaferUI = (function (exports) {
5266
5312
  }
5267
5313
  }
5268
5314
  add(child, index) {
5315
+ if (child === this)
5316
+ return;
5269
5317
  if (child.parent)
5270
5318
  child.parent.remove(child);
5271
5319
  child.parent = this;
@@ -6018,9 +6066,11 @@ var LeaferUI = (function (exports) {
6018
6066
  updateAllChange(target);
6019
6067
  }
6020
6068
  addExtra(leaf) {
6021
- const block = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
6022
- block.updatedList.add(leaf);
6023
- block.beforeBounds.add(leaf.__world);
6069
+ if (!this.__updatedList.has(leaf)) {
6070
+ const { updatedList, beforeBounds } = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
6071
+ updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
6072
+ updatedList.add(leaf);
6073
+ }
6024
6074
  }
6025
6075
  createBlock(data) {
6026
6076
  return new LayoutBlockData(data);
@@ -6536,6 +6586,18 @@ var LeaferUI = (function (exports) {
6536
6586
  });
6537
6587
  Platform.layout = Layouter.fullLayout;
6538
6588
 
6589
+ function arrowType(defaultValue) {
6590
+ return (target, key) => {
6591
+ defineLeafAttr(target, key, defaultValue, {
6592
+ set(value) {
6593
+ this.__setAttr(key, value);
6594
+ doStrokeType(this);
6595
+ const data = this.__;
6596
+ data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
6597
+ }
6598
+ });
6599
+ };
6600
+ }
6539
6601
  function effectType(defaultValue) {
6540
6602
  return (target, key) => {
6541
6603
  defineLeafAttr(target, key, defaultValue, {
@@ -6562,12 +6624,14 @@ var LeaferUI = (function (exports) {
6562
6624
 
6563
6625
  const TextConvert = {};
6564
6626
  const ColorConvert = {};
6627
+ const PathArrow = {};
6565
6628
  const Paint = {};
6566
6629
  const PaintImage = {};
6567
6630
  const PaintGradient = {};
6568
6631
  const Effect = {};
6569
6632
  const Export = {};
6570
6633
 
6634
+ const { parse } = PathConvert;
6571
6635
  const emptyPaint = {};
6572
6636
  const debug$3 = Debug.get('UIData');
6573
6637
  class UIData extends LeafData {
@@ -6585,7 +6649,8 @@ var LeaferUI = (function (exports) {
6585
6649
  }
6586
6650
  get __autoWidth() { return !this._width; }
6587
6651
  get __autoHeight() { return !this._height; }
6588
- get __autoBounds() { return !this._width && !this._height; }
6652
+ get __autoSide() { return !this._width || !this._height; }
6653
+ get __autoSize() { return !this._width && !this._height; }
6589
6654
  setVisible(value) {
6590
6655
  if (this.__leaf.leafer)
6591
6656
  this.__leaf.leafer.watcher.hasVisible = true;
@@ -6613,7 +6678,7 @@ var LeaferUI = (function (exports) {
6613
6678
  }
6614
6679
  setFill(value) {
6615
6680
  if (this.__naturalWidth)
6616
- this.__naturalWidth = this.__naturalHeight = undefined;
6681
+ this.__removeNaturalSize();
6617
6682
  if (typeof value === 'string' || !value) {
6618
6683
  if (this.__isFills) {
6619
6684
  this.__removeInput('fill');
@@ -6649,6 +6714,17 @@ var LeaferUI = (function (exports) {
6649
6714
  this._stroke || (this._stroke = emptyPaint);
6650
6715
  }
6651
6716
  }
6717
+ setPath(value) {
6718
+ if (typeof value === 'string') {
6719
+ this.__setInput('path', value);
6720
+ this._path = parse(value);
6721
+ }
6722
+ else {
6723
+ if (this.__input)
6724
+ this.__removeInput('path');
6725
+ this._path = value;
6726
+ }
6727
+ }
6652
6728
  setShadow(value) {
6653
6729
  this.__setInput('shadow', value);
6654
6730
  if (value instanceof Array) {
@@ -6710,9 +6786,6 @@ var LeaferUI = (function (exports) {
6710
6786
  class LineData extends UIData {
6711
6787
  }
6712
6788
 
6713
- class ArrowData extends LineData {
6714
- }
6715
-
6716
6789
  class RectData extends UIData {
6717
6790
  get __boxStroke() { return true; }
6718
6791
  }
@@ -6727,19 +6800,7 @@ var LeaferUI = (function (exports) {
6727
6800
  class StarData extends UIData {
6728
6801
  }
6729
6802
 
6730
- const { parse } = PathConvert;
6731
6803
  class PathData extends UIData {
6732
- setPath(value) {
6733
- if (typeof value === 'string') {
6734
- this.__setInput('path', value);
6735
- this._path = parse(value);
6736
- }
6737
- else {
6738
- if (this.__input)
6739
- this.__removeInput('path');
6740
- this._path = value;
6741
- }
6742
- }
6743
6804
  }
6744
6805
 
6745
6806
  class PenData extends GroupData {
@@ -6809,6 +6870,8 @@ var LeaferUI = (function (exports) {
6809
6870
  }
6810
6871
  }
6811
6872
  this.__layout.strokeBoxSpread = boxWidth;
6873
+ if (this.__.__useArrow)
6874
+ width += strokeWidth * 5;
6812
6875
  return width;
6813
6876
  },
6814
6877
  __updateRenderSpread() {
@@ -6942,6 +7005,7 @@ var LeaferUI = (function (exports) {
6942
7005
  var UI_1;
6943
7006
  exports.UI = UI_1 = class UI extends exports.Leaf {
6944
7007
  get app() { return this.leafer && this.leafer.app; }
7008
+ get isFrame() { return false; }
6945
7009
  set scale(value) {
6946
7010
  if (typeof value === 'number') {
6947
7011
  this.scaleX = this.scaleY = value;
@@ -6962,8 +7026,8 @@ var LeaferUI = (function (exports) {
6962
7026
  set(data) {
6963
7027
  Object.assign(this, data);
6964
7028
  }
6965
- get() {
6966
- return this.__.__getInputData();
7029
+ get(name) {
7030
+ return name ? this.__.__getInput(name) : this.__.__getInputData();
6967
7031
  }
6968
7032
  createProxyData() { return undefined; }
6969
7033
  find(_condition, _options) { return undefined; }
@@ -6995,6 +7059,8 @@ var LeaferUI = (function (exports) {
6995
7059
  if (this.__.path) {
6996
7060
  const data = this.__;
6997
7061
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
7062
+ if (data.__useArrow)
7063
+ PathArrow.addArrows(this, !data.cornerRadius);
6998
7064
  }
6999
7065
  }
7000
7066
  __drawRenderPath(canvas) {
@@ -7005,7 +7071,14 @@ var LeaferUI = (function (exports) {
7005
7071
  canvas.beginPath();
7006
7072
  this.__drawPathByData(canvas, this.__.path);
7007
7073
  }
7008
- __drawPathByData(_drawer, _data) { }
7074
+ __drawPathByData(drawer, data) {
7075
+ if (data) {
7076
+ PathDrawer.drawPathByData(drawer, data);
7077
+ }
7078
+ else {
7079
+ this.__drawPathByBox(drawer);
7080
+ }
7081
+ }
7009
7082
  __drawPathByBox(drawer) {
7010
7083
  const { x, y, width, height } = this.__layout.boxBounds;
7011
7084
  if (this.__.cornerRadius) {
@@ -7024,6 +7097,12 @@ var LeaferUI = (function (exports) {
7024
7097
  static one(data, x, y, width, height) {
7025
7098
  return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height);
7026
7099
  }
7100
+ static registerUI() {
7101
+ registerUI()(this);
7102
+ }
7103
+ static registerData(data) {
7104
+ dataProcessor(data)(this.prototype);
7105
+ }
7027
7106
  destroy() {
7028
7107
  this.fill = this.stroke = null;
7029
7108
  super.destroy();
@@ -7162,10 +7241,19 @@ var LeaferUI = (function (exports) {
7162
7241
  dataType(false)
7163
7242
  ], exports.UI.prototype, "lazy", void 0);
7164
7243
  __decorate([
7165
- strokeType('none')
7244
+ naturalBoundsType(1)
7245
+ ], exports.UI.prototype, "pixelRatio", void 0);
7246
+ __decorate([
7247
+ pathInputType()
7248
+ ], exports.UI.prototype, "path", void 0);
7249
+ __decorate([
7250
+ pathType()
7251
+ ], exports.UI.prototype, "windingRule", void 0);
7252
+ __decorate([
7253
+ arrowType('none')
7166
7254
  ], exports.UI.prototype, "startArrow", void 0);
7167
7255
  __decorate([
7168
- strokeType('none')
7256
+ arrowType('none')
7169
7257
  ], exports.UI.prototype, "endArrow", void 0);
7170
7258
  __decorate([
7171
7259
  pathType(0)
@@ -7191,9 +7279,6 @@ var LeaferUI = (function (exports) {
7191
7279
  __decorate([
7192
7280
  rewrite(exports.Leaf.prototype.reset)
7193
7281
  ], exports.UI.prototype, "reset", null);
7194
- __decorate([
7195
- rewrite(PathDrawer.drawPathByData)
7196
- ], exports.UI.prototype, "__drawPathByData", null);
7197
7282
  exports.UI = UI_1 = __decorate([
7198
7283
  useModule(UIBounds),
7199
7284
  useModule(UIRender),
@@ -7202,12 +7287,15 @@ var LeaferUI = (function (exports) {
7202
7287
 
7203
7288
  exports.Group = class Group extends exports.UI {
7204
7289
  get __tag() { return 'Group'; }
7290
+ get isBranch() { return true; }
7205
7291
  constructor(data) {
7206
7292
  super(data);
7293
+ }
7294
+ reset(data) {
7207
7295
  this.__setBranch();
7296
+ super.reset(data);
7208
7297
  }
7209
7298
  __setBranch() {
7210
- this.isBranch = true;
7211
7299
  if (!this.children)
7212
7300
  this.children = [];
7213
7301
  }
@@ -7219,7 +7307,7 @@ var LeaferUI = (function (exports) {
7219
7307
  this.__setBranch();
7220
7308
  }
7221
7309
  else {
7222
- this.removeAll(true);
7310
+ this.clear();
7223
7311
  }
7224
7312
  super.set(data);
7225
7313
  let child;
@@ -7267,6 +7355,7 @@ var LeaferUI = (function (exports) {
7267
7355
  get __tag() { return 'Leafer'; }
7268
7356
  get isApp() { return false; }
7269
7357
  get app() { return this.parent || this; }
7358
+ get isLeafer() { return true; }
7270
7359
  get imageReady() { return this.viewReady && ImageManager.isComplete; }
7271
7360
  get layoutLocked() { return !this.layouter.running; }
7272
7361
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
@@ -7383,7 +7472,7 @@ var LeaferUI = (function (exports) {
7383
7472
  this.forceRender();
7384
7473
  }
7385
7474
  forceRender(bounds) {
7386
- this.renderer.addBlock(new Bounds(bounds) || this.canvas.bounds);
7475
+ this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7387
7476
  if (this.viewReady)
7388
7477
  this.renderer.update();
7389
7478
  }
@@ -7414,7 +7503,6 @@ var LeaferUI = (function (exports) {
7414
7503
  }
7415
7504
  __setLeafer(leafer) {
7416
7505
  this.leafer = leafer;
7417
- this.isLeafer = !!leafer;
7418
7506
  this.__level = 1;
7419
7507
  }
7420
7508
  setZoomLayer(zoomLayer) {
@@ -7601,14 +7689,10 @@ var LeaferUI = (function (exports) {
7601
7689
  constructor(data) {
7602
7690
  super(data);
7603
7691
  }
7604
- __drawPathByData(_drawer, _data) { }
7605
7692
  };
7606
7693
  __decorate([
7607
7694
  dataProcessor(RectData)
7608
7695
  ], exports.Rect.prototype, "__", void 0);
7609
- __decorate([
7610
- rewrite(exports.UI.prototype.__drawPathByBox)
7611
- ], exports.Rect.prototype, "__drawPathByData", null);
7612
7696
  exports.Rect = __decorate([
7613
7697
  useModule(RectRender),
7614
7698
  rewriteAble(),
@@ -7621,9 +7705,9 @@ var LeaferUI = (function (exports) {
7621
7705
  const { copy: copy$3, add } = BoundsHelper;
7622
7706
  exports.Box = class Box extends exports.Group {
7623
7707
  get __tag() { return 'Box'; }
7708
+ get isBranchLeaf() { return true; }
7624
7709
  constructor(data) {
7625
7710
  super(data);
7626
- this.isBranchLeaf = true;
7627
7711
  this.__layout.renderChanged || this.__layout.renderChange();
7628
7712
  }
7629
7713
  __updateStrokeSpread() { return 0; }
@@ -7637,8 +7721,18 @@ var LeaferUI = (function (exports) {
7637
7721
  }
7638
7722
  __updateRectBoxBounds() { }
7639
7723
  __updateBoxBounds() {
7640
- if (this.__.__autoBounds && this.children.length) {
7724
+ const data = this.__;
7725
+ if (data.__autoSide && this.children.length) {
7726
+ if (this.leafer)
7727
+ this.leafer.layouter.addExtra(this);
7641
7728
  super.__updateBoxBounds();
7729
+ if (!data.__autoSize) {
7730
+ const b = this.__layout.boxBounds;
7731
+ if (!data.__autoWidth)
7732
+ b.x = 0, b.width = data.width;
7733
+ if (!data.__autoHeight)
7734
+ b.y = 0, b.height = data.height;
7735
+ }
7642
7736
  }
7643
7737
  else {
7644
7738
  this.__updateRectBoxBounds();
@@ -7660,7 +7754,6 @@ var LeaferUI = (function (exports) {
7660
7754
  super.__updateChange();
7661
7755
  this.__updateRectChange();
7662
7756
  }
7663
- __drawPathByData(_drawer, _data) { }
7664
7757
  __renderRect(_canvas, _options) { }
7665
7758
  __renderGroup(_canvas, _options) { }
7666
7759
  __render(canvas, options) {
@@ -7705,9 +7798,6 @@ var LeaferUI = (function (exports) {
7705
7798
  __decorate([
7706
7799
  rewrite(rect.__updateChange)
7707
7800
  ], exports.Box.prototype, "__updateRectChange", null);
7708
- __decorate([
7709
- rewrite(rect.__drawPathByData)
7710
- ], exports.Box.prototype, "__drawPathByData", null);
7711
7801
  __decorate([
7712
7802
  rewrite(rect.__render)
7713
7803
  ], exports.Box.prototype, "__renderRect", null);
@@ -7721,9 +7811,9 @@ var LeaferUI = (function (exports) {
7721
7811
 
7722
7812
  exports.Frame = class Frame extends exports.Box {
7723
7813
  get __tag() { return 'Frame'; }
7814
+ get isFrame() { return true; }
7724
7815
  constructor(data) {
7725
7816
  super(data);
7726
- this.isFrame = true;
7727
7817
  }
7728
7818
  };
7729
7819
  __decorate([
@@ -7797,7 +7887,7 @@ var LeaferUI = (function (exports) {
7797
7887
 
7798
7888
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
7799
7889
  const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
7800
- const { toBounds: toBounds$2 } = PathBounds;
7890
+ const { toBounds: toBounds$1 } = PathBounds;
7801
7891
  exports.Line = class Line extends exports.UI {
7802
7892
  get __tag() { return 'Line'; }
7803
7893
  get toPoint() {
@@ -7829,8 +7919,11 @@ var LeaferUI = (function (exports) {
7829
7919
  }
7830
7920
  }
7831
7921
  __updateRenderPath() {
7832
- if (this.__.points && this.__.curve) {
7833
- drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
7922
+ const data = this.__;
7923
+ if (!this.pathInputed && data.points && data.curve) {
7924
+ drawPoints$1(data.__pathForRender = [], data.points, data.curve, this.pathClosed);
7925
+ if (data.__useArrow)
7926
+ PathArrow.addArrows(this, false);
7834
7927
  }
7835
7928
  else {
7836
7929
  super.__updateRenderPath();
@@ -7838,7 +7931,7 @@ var LeaferUI = (function (exports) {
7838
7931
  }
7839
7932
  __updateBoxBounds() {
7840
7933
  if (this.points) {
7841
- toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
7934
+ toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
7842
7935
  }
7843
7936
  else {
7844
7937
  super.__updateBoxBounds();
@@ -7871,6 +7964,7 @@ var LeaferUI = (function (exports) {
7871
7964
  get __tag() { return 'Polygon'; }
7872
7965
  constructor(data) {
7873
7966
  super(data);
7967
+ this.pathClosed = true;
7874
7968
  }
7875
7969
  __updatePath() {
7876
7970
  const path = this.__.path = [];
@@ -8026,7 +8120,7 @@ var LeaferUI = (function (exports) {
8026
8120
  }
8027
8121
  };
8028
8122
  __decorate([
8029
- dataProcessor(ImageData)
8123
+ dataProcessor(CanvasData)
8030
8124
  ], exports.Canvas.prototype, "__", void 0);
8031
8125
  __decorate([
8032
8126
  resizeType(100)
@@ -8089,7 +8183,7 @@ var LeaferUI = (function (exports) {
8089
8183
  data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
8090
8184
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8091
8185
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8092
- data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
8186
+ data.__clipText = textOverflow !== 'show' && !data.__autoSize;
8093
8187
  this.__updateTextDrawData();
8094
8188
  const { bounds } = data.__textDrawData;
8095
8189
  const b = layout.boxBounds;
@@ -8206,25 +8300,16 @@ var LeaferUI = (function (exports) {
8206
8300
  registerUI()
8207
8301
  ], exports.Text);
8208
8302
 
8209
- const { toBounds: toBounds$1 } = PathBounds;
8210
8303
  exports.Path = class Path extends exports.UI {
8211
8304
  get __tag() { return 'Path'; }
8212
8305
  constructor(data) {
8213
8306
  super(data);
8214
- }
8215
- __updateBoxBounds() {
8216
- toBounds$1(this.__.path, this.__layout.boxBounds);
8307
+ this.__.__pathInputed = 2;
8217
8308
  }
8218
8309
  };
8219
8310
  __decorate([
8220
8311
  dataProcessor(PathData)
8221
8312
  ], exports.Path.prototype, "__", void 0);
8222
- __decorate([
8223
- pathType()
8224
- ], exports.Path.prototype, "path", void 0);
8225
- __decorate([
8226
- pathType()
8227
- ], exports.Path.prototype, "windingRule", void 0);
8228
8313
  __decorate([
8229
8314
  affectStrokeBoundsType('center')
8230
8315
  ], exports.Path.prototype, "strokeAlign", void 0);
@@ -8240,12 +8325,12 @@ var LeaferUI = (function (exports) {
8240
8325
  setStyle(data) {
8241
8326
  const path = this.pathElement = new exports.Path(data);
8242
8327
  this.pathStyle = data;
8243
- this.path = path.path || (path.path = []);
8328
+ this.__path = path.path || (path.path = []);
8244
8329
  this.add(path);
8245
8330
  return this;
8246
8331
  }
8247
8332
  beginPath() {
8248
- this.path.length = 0;
8333
+ this.__path.length = 0;
8249
8334
  this.paint();
8250
8335
  return this;
8251
8336
  }
@@ -8269,10 +8354,20 @@ var LeaferUI = (function (exports) {
8269
8354
  __decorate([
8270
8355
  dataProcessor(PenData)
8271
8356
  ], exports.Pen.prototype, "__", void 0);
8357
+ __decorate([
8358
+ penPathType()
8359
+ ], exports.Pen.prototype, "path", void 0);
8272
8360
  exports.Pen = __decorate([
8273
- useModule(PathCreator, ['beginPath']),
8361
+ useModule(PathCreator, ['beginPath', 'path']),
8274
8362
  registerUI()
8275
8363
  ], exports.Pen);
8364
+ function penPathType() {
8365
+ return (target, key) => {
8366
+ defineKey(target, key, {
8367
+ get() { return this.__path; }
8368
+ });
8369
+ };
8370
+ }
8276
8371
 
8277
8372
  exports.App = class App extends exports.Leafer {
8278
8373
  get __tag() { return 'App'; }
@@ -10373,9 +10468,9 @@ var LeaferUI = (function (exports) {
10373
10468
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
10374
10469
  if (attrName === 'fill' && !ui.__.__naturalWidth) {
10375
10470
  const data = ui.__;
10376
- data.__naturalWidth = image.width;
10377
- data.__naturalHeight = image.height;
10378
- if (data.__autoWidth || data.__autoHeight) {
10471
+ data.__naturalWidth = image.width / data.pixelRatio;
10472
+ data.__naturalHeight = image.height / data.pixelRatio;
10473
+ if (data.__autoSide) {
10379
10474
  ui.forceUpdate('width');
10380
10475
  if (ui.__proxyData) {
10381
10476
  ui.setProxyAttr('width', data.width);
@@ -10405,7 +10500,7 @@ var LeaferUI = (function (exports) {
10405
10500
  }
10406
10501
 
10407
10502
  const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
10408
- const { round, abs: abs$1 } = Math;
10503
+ const { ceil, abs: abs$1 } = Math;
10409
10504
  function createPattern(ui, paint, pixelRatio) {
10410
10505
  let { scaleX, scaleY } = ui.__world;
10411
10506
  const id = scaleX + '-' + scaleY;
@@ -10456,7 +10551,7 @@ var LeaferUI = (function (exports) {
10456
10551
  }
10457
10552
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
10458
10553
  }
10459
- const canvas = image.getCanvas(width < 1 ? 1 : round(width), height < 1 ? 1 : round(height), opacity);
10554
+ const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, opacity);
10460
10555
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
10461
10556
  paint.style = pattern;
10462
10557
  paint.patternId = id;
@@ -11367,37 +11462,55 @@ var LeaferUI = (function (exports) {
11367
11462
  const { leafer } = leaf;
11368
11463
  if (leafer) {
11369
11464
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
11370
- let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
11371
11465
  options = FileHelper.getExportOptions(options);
11372
- const { scale, slice, trim } = options;
11466
+ let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
11467
+ const { worldTransform, isLeafer, isFrame } = leaf;
11468
+ const { slice, trim, onCanvas } = options;
11469
+ const scale = options.scale || 1;
11373
11470
  const pixelRatio = options.pixelRatio || 1;
11374
11471
  const screenshot = options.screenshot || leaf.isApp;
11375
- const fill = options.fill === undefined ? ((leaf.isLeafer && screenshot) ? leaf.fill : '') : options.fill;
11472
+ const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : undefined) : options.fill;
11376
11473
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
11377
11474
  if (screenshot) {
11378
- renderBounds = screenshot === true ? (leaf.isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
11475
+ renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
11379
11476
  }
11380
11477
  else {
11381
- const { localTransform, __world: world } = leaf;
11382
- matrix.set(world).divide(localTransform).invert();
11383
- scaleX = 1 / (world.scaleX / leaf.scaleX);
11384
- scaleY = 1 / (world.scaleY / leaf.scaleY);
11385
- renderBounds = leaf.getBounds('render', 'local');
11386
- }
11387
- let { x, y, width, height } = renderBounds;
11388
- if (scale) {
11389
- matrix.scale(scale);
11390
- width *= scale, height *= scale;
11391
- scaleX *= scale, scaleY *= scale;
11478
+ const location = options.location || ((isLeafer || isFrame) ? 'inner' : 'local');
11479
+ scaleX = worldTransform.scaleX;
11480
+ scaleY = worldTransform.scaleY;
11481
+ switch (location) {
11482
+ case 'inner':
11483
+ matrix.set(worldTransform).invert();
11484
+ break;
11485
+ case 'local':
11486
+ matrix.set(worldTransform).divide(leaf.localTransform).invert();
11487
+ scaleX /= leaf.scaleX;
11488
+ scaleY /= leaf.scaleY;
11489
+ break;
11490
+ case 'world':
11491
+ scaleX = 1;
11492
+ scaleY = 1;
11493
+ break;
11494
+ }
11495
+ renderBounds = leaf.getBounds('render', location);
11392
11496
  }
11393
- let canvas = Creator.canvas({ width: Math.ceil(width), height: Math.ceil(width), pixelRatio });
11394
- const renderOptions = { matrix: matrix.translate(-x, -y).withScale(scaleX, scaleY) };
11497
+ const { x, y, width, height } = new Bounds(renderBounds).scale(scale).ceil();
11498
+ let canvas = Creator.canvas({ width, height, pixelRatio });
11499
+ const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
11395
11500
  if (slice) {
11396
11501
  leaf = leafer;
11397
11502
  renderOptions.bounds = canvas.bounds;
11398
11503
  }
11399
11504
  canvas.save();
11400
- leaf.__render(canvas, renderOptions);
11505
+ if (isFrame && fill !== undefined) {
11506
+ const oldFill = leaf.get('fill');
11507
+ leaf.fill = '';
11508
+ leaf.__render(canvas, renderOptions);
11509
+ leaf.fill = oldFill;
11510
+ }
11511
+ else {
11512
+ leaf.__render(canvas, renderOptions);
11513
+ }
11401
11514
  canvas.restore();
11402
11515
  if (trim) {
11403
11516
  trimBounds = getTrimBounds(canvas);
@@ -11408,6 +11521,8 @@ var LeaferUI = (function (exports) {
11408
11521
  }
11409
11522
  if (needFill)
11410
11523
  canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
11524
+ if (onCanvas)
11525
+ onCanvas(canvas);
11411
11526
  const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
11412
11527
  over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
11413
11528
  }));
@@ -11444,7 +11559,6 @@ var LeaferUI = (function (exports) {
11444
11559
 
11445
11560
  exports.AnimateEvent = AnimateEvent;
11446
11561
  exports.AroundHelper = AroundHelper;
11447
- exports.ArrowData = ArrowData;
11448
11562
  exports.AutoBounds = AutoBounds;
11449
11563
  exports.BezierHelper = BezierHelper;
11450
11564
  exports.Bounds = Bounds;
@@ -11509,6 +11623,7 @@ var LeaferUI = (function (exports) {
11509
11623
  exports.Paint = Paint;
11510
11624
  exports.PaintGradient = PaintGradient;
11511
11625
  exports.PaintImage = PaintImage;
11626
+ exports.PathArrow = PathArrow;
11512
11627
  exports.PathBounds = PathBounds;
11513
11628
  exports.PathCommandDataHelper = PathCommandDataHelper;
11514
11629
  exports.PathCommandMap = PathCommandMap;
@@ -11553,6 +11668,7 @@ var LeaferUI = (function (exports) {
11553
11668
  exports.Watcher = Watcher;
11554
11669
  exports.affectRenderBoundsType = affectRenderBoundsType;
11555
11670
  exports.affectStrokeBoundsType = affectStrokeBoundsType;
11671
+ exports.arrowType = arrowType;
11556
11672
  exports.autoLayoutType = autoLayoutType;
11557
11673
  exports.boundsType = boundsType;
11558
11674
  exports.canvasPatch = canvasPatch;
@@ -11563,6 +11679,8 @@ var LeaferUI = (function (exports) {
11563
11679
  exports.defineDataProcessor = defineDataProcessor;
11564
11680
  exports.defineKey = defineKey;
11565
11681
  exports.defineLeafAttr = defineLeafAttr;
11682
+ exports.doBoundsType = doBoundsType;
11683
+ exports.doStrokeType = doStrokeType;
11566
11684
  exports.effectType = effectType;
11567
11685
  exports.eraserType = eraserType;
11568
11686
  exports.getBoundsData = getBoundsData;
@@ -11572,7 +11690,9 @@ var LeaferUI = (function (exports) {
11572
11690
  exports.hitType = hitType;
11573
11691
  exports.layoutProcessor = layoutProcessor;
11574
11692
  exports.maskType = maskType;
11693
+ exports.naturalBoundsType = naturalBoundsType;
11575
11694
  exports.opacityType = opacityType;
11695
+ exports.pathInputType = pathInputType;
11576
11696
  exports.pathType = pathType;
11577
11697
  exports.positionType = positionType;
11578
11698
  exports.registerUI = registerUI;