leafer-ui 1.0.0-rc.12 → 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.
@@ -29,7 +29,7 @@ const IncrementId = {
29
29
  };
30
30
  const I$2 = IncrementId;
31
31
 
32
- const { round: round$1, pow: pow$1, PI: PI$4 } = Math;
32
+ const { round, pow: pow$1, PI: PI$4 } = Math;
33
33
  const MathHelper = {
34
34
  within(value, min, max) {
35
35
  if (value < min)
@@ -91,7 +91,7 @@ const MathHelper = {
91
91
  },
92
92
  float(num, maxLength) {
93
93
  const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
94
- num = round$1(num * a) / a;
94
+ num = round(num * a) / a;
95
95
  return num === -0 ? 0 : num;
96
96
  }
97
97
  };
@@ -403,6 +403,10 @@ const PointHelper = {
403
403
  t.x = point.x;
404
404
  t.y = point.y;
405
405
  },
406
+ copyFrom(t, x, y) {
407
+ t.x = x;
408
+ t.y = y;
409
+ },
406
410
  move(t, x, y) {
407
411
  t.x += x;
408
412
  t.y += y;
@@ -430,19 +434,19 @@ const PointHelper = {
430
434
  },
431
435
  tempToInnerOf(t, matrix) {
432
436
  const { tempPoint: temp } = P$5;
433
- P$5.copy(temp, t);
437
+ copy$a(temp, t);
434
438
  toInnerPoint$2(matrix, temp, temp);
435
439
  return temp;
436
440
  },
437
441
  tempToOuterOf(t, matrix) {
438
442
  const { tempPoint: temp } = P$5;
439
- P$5.copy(temp, t);
443
+ copy$a(temp, t);
440
444
  toOuterPoint$2(matrix, temp, temp);
441
445
  return temp;
442
446
  },
443
447
  tempToInnerRadiusPointOf(t, matrix) {
444
448
  const { tempRadiusPoint: temp } = P$5;
445
- P$5.copy(temp, t);
449
+ copy$a(temp, t);
446
450
  P$5.toInnerRadiusPointOf(t, matrix, temp);
447
451
  return temp;
448
452
  },
@@ -468,7 +472,7 @@ const PointHelper = {
468
472
  return y1 + (y2 - y1) / 2;
469
473
  },
470
474
  getDistance(t, point) {
471
- return P$5.getDistanceFrom(t.x, t.y, point.x, point.y);
475
+ return getDistanceFrom(t.x, t.y, point.x, point.y);
472
476
  },
473
477
  getDistanceFrom(x1, y1, x2, y2) {
474
478
  const x = abs$4(x2 - x1);
@@ -476,10 +480,10 @@ const PointHelper = {
476
480
  return sqrt$2(x * x + y * y);
477
481
  },
478
482
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
479
- return min$1(P$5.getDistanceFrom(x1, y1, x2, y2), P$5.getDistanceFrom(x2, y2, x3, y3));
483
+ return min$1(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3));
480
484
  },
481
485
  getAngle(t, to) {
482
- return P$5.getAtan2(t, to) / OneRadian;
486
+ return getAtan2(t, to) / OneRadian;
483
487
  },
484
488
  getRotation(t, origin, to, toOrigin) {
485
489
  if (!toOrigin)
@@ -497,15 +501,19 @@ const PointHelper = {
497
501
  getAtan2(t, to) {
498
502
  return atan2$2(to.y - t.y, to.x - t.x);
499
503
  },
500
- getDistancePoint(t, to, distance) {
501
- const r = P$5.getAtan2(t, to);
502
- return { x: t.x + cos$4(r) * distance, y: t.y + sin$4(r) * distance };
504
+ getDistancePoint(t, to, distance, changeTo) {
505
+ const r = getAtan2(t, to);
506
+ to = changeTo ? to : {};
507
+ to.x = t.x + cos$4(r) * distance;
508
+ to.y = t.y + sin$4(r) * distance;
509
+ return to;
503
510
  },
504
511
  reset(t) {
505
512
  P$5.reset(t);
506
513
  }
507
514
  };
508
515
  const P$5 = PointHelper;
516
+ const { getDistanceFrom, copy: copy$a, getAtan2 } = P$5;
509
517
 
510
518
  class Point {
511
519
  constructor(x, y) {
@@ -559,8 +567,8 @@ class Point {
559
567
  getDistance(to) {
560
568
  return PointHelper.getDistance(this, to);
561
569
  }
562
- getDistancePoint(to, distance) {
563
- return new Point(PointHelper.getDistancePoint(this, to, distance));
570
+ getDistancePoint(to, distance, changeTo) {
571
+ return new Point(PointHelper.getDistancePoint(this, to, distance, changeTo));
564
572
  }
565
573
  getAngle(to) {
566
574
  return PointHelper.getAngle(this, to);
@@ -714,7 +722,7 @@ const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
714
722
  const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
715
723
  const { toOuterPoint: toOuterPoint$1 } = MatrixHelper;
716
724
  const { float } = MathHelper;
717
- const { floor, ceil: ceil$1 } = Math;
725
+ const { floor, ceil: ceil$2 } = Math;
718
726
  let right$1, bottom$1, boundsRight, boundsBottom;
719
727
  const point = {};
720
728
  const toPoint$1 = {};
@@ -846,8 +854,8 @@ const BoundsHelper = {
846
854
  const { x, y } = t;
847
855
  t.x = floor(t.x);
848
856
  t.y = floor(t.y);
849
- t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
850
- t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
857
+ t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
858
+ t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
851
859
  },
852
860
  unsign(t) {
853
861
  if (t.width < 0) {
@@ -1431,6 +1439,8 @@ class LeafData {
1431
1439
  if (value !== undefined)
1432
1440
  return value;
1433
1441
  }
1442
+ if (name === 'path' && !this.__pathInputed)
1443
+ return;
1434
1444
  return this['_' + name];
1435
1445
  }
1436
1446
  __removeInput(name) {
@@ -1444,6 +1454,8 @@ class LeafData {
1444
1454
  if (key[0] !== '_') {
1445
1455
  value = this['_' + key];
1446
1456
  if (value !== undefined) {
1457
+ if (key === 'path' && !this.__pathInputed)
1458
+ continue;
1447
1459
  inputValue = __input ? __input[key] : undefined;
1448
1460
  data[key] = (inputValue === undefined) ? value : inputValue;
1449
1461
  }
@@ -1473,6 +1485,9 @@ class LeafData {
1473
1485
  t.__single = true;
1474
1486
  }
1475
1487
  }
1488
+ __removeNaturalSize() {
1489
+ this.__naturalWidth = this.__naturalHeight = undefined;
1490
+ }
1476
1491
  destroy() {
1477
1492
  this.__input = this.__middle = null;
1478
1493
  }
@@ -1960,7 +1975,7 @@ class LeaferCanvasBase extends Canvas$1 {
1960
1975
  this.setStrokeOptions(options);
1961
1976
  }
1962
1977
  setStrokeOptions(options) {
1963
- this.strokeCap = options.strokeCap;
1978
+ this.strokeCap = options.strokeCap === 'none' ? 'butt' : options.strokeCap;
1964
1979
  this.strokeJoin = options.strokeJoin;
1965
1980
  this.dashPattern = options.dashPattern;
1966
1981
  this.dashOffset = options.dashOffset;
@@ -2183,7 +2198,7 @@ const RectHelper = {
2183
2198
  }
2184
2199
  };
2185
2200
 
2186
- const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2201
+ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2187
2202
  const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2188
2203
  const { set: set$2 } = PointHelper;
2189
2204
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
@@ -2297,7 +2312,7 @@ const BezierHelper = {
2297
2312
  totalRadian -= PI2;
2298
2313
  if (anticlockwise)
2299
2314
  totalRadian -= PI2;
2300
- const parts = ceil(abs$3(totalRadian / PI_2));
2315
+ const parts = ceil$1(abs$3(totalRadian / PI_2));
2301
2316
  const partRadian = totalRadian / parts;
2302
2317
  const partRadian4Sin = sin$3(partRadian / 4);
2303
2318
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -2783,22 +2798,12 @@ const PathCommandDataHelper = {
2783
2798
  }
2784
2799
  },
2785
2800
  drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2786
- if (rotation === undefined)
2787
- rotation = 0;
2788
- if (startAngle === undefined)
2789
- startAngle = 0;
2790
- if (endAngle === undefined)
2791
- endAngle = 360;
2792
- BezierHelper.ellipse(null, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise, null, null, startPoint);
2801
+ BezierHelper.ellipse(null, x, y, radiusX, radiusY, rotation === undefined ? 0 : rotation, startAngle === undefined ? 0 : startAngle, endAngle === undefined ? 360 : endAngle, anticlockwise, null, null, startPoint);
2793
2802
  data.push(M$3, startPoint.x, startPoint.y);
2794
2803
  ellipse$3(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2795
2804
  },
2796
2805
  drawArc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
2797
- if (startAngle === undefined)
2798
- startAngle = 0;
2799
- if (endAngle === undefined)
2800
- endAngle = 360;
2801
- BezierHelper.arc(null, x, y, radius, startAngle, endAngle, anticlockwise, null, null, startPoint);
2806
+ BezierHelper.arc(null, x, y, radius, startAngle === undefined ? 0 : startAngle, endAngle === undefined ? 360 : endAngle, anticlockwise, null, null, startPoint);
2802
2807
  data.push(M$3, startPoint.x, startPoint.y);
2803
2808
  arc$2(data, x, y, radius, startAngle, endAngle, anticlockwise);
2804
2809
  },
@@ -2810,68 +2815,70 @@ const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
2810
2815
 
2811
2816
  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;
2812
2817
  class PathCreator {
2818
+ set path(value) { this.__path = value; }
2819
+ get path() { return this.__path; }
2813
2820
  constructor(path) {
2814
2821
  if (path) {
2815
- this.path = typeof path === 'string' ? PathHelper.parse(path) : path;
2822
+ this.__path = typeof path === 'string' ? PathHelper.parse(path) : path;
2816
2823
  }
2817
2824
  else {
2818
- this.path = [];
2825
+ this.__path = [];
2819
2826
  }
2820
2827
  }
2821
2828
  beginPath() {
2822
- beginPath(this.path);
2829
+ beginPath(this.__path);
2823
2830
  return this;
2824
2831
  }
2825
2832
  moveTo(x, y) {
2826
- moveTo$4(this.path, x, y);
2833
+ moveTo$4(this.__path, x, y);
2827
2834
  return this;
2828
2835
  }
2829
2836
  lineTo(x, y) {
2830
- lineTo$3(this.path, x, y);
2837
+ lineTo$3(this.__path, x, y);
2831
2838
  return this;
2832
2839
  }
2833
2840
  bezierCurveTo(x1, y1, x2, y2, x, y) {
2834
- bezierCurveTo(this.path, x1, y1, x2, y2, x, y);
2841
+ bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
2835
2842
  return this;
2836
2843
  }
2837
2844
  quadraticCurveTo(x1, y1, x, y) {
2838
- quadraticCurveTo(this.path, x1, y1, x, y);
2845
+ quadraticCurveTo(this.__path, x1, y1, x, y);
2839
2846
  return this;
2840
2847
  }
2841
2848
  closePath() {
2842
- closePath$3(this.path);
2849
+ closePath$3(this.__path);
2843
2850
  return this;
2844
2851
  }
2845
2852
  rect(x, y, width, height) {
2846
- rect$1(this.path, x, y, width, height);
2853
+ rect$1(this.__path, x, y, width, height);
2847
2854
  return this;
2848
2855
  }
2849
2856
  roundRect(x, y, width, height, cornerRadius) {
2850
- roundRect$1(this.path, x, y, width, height, cornerRadius);
2857
+ roundRect$1(this.__path, x, y, width, height, cornerRadius);
2851
2858
  return this;
2852
2859
  }
2853
2860
  ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2854
- ellipse$2(this.path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2861
+ ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2855
2862
  return this;
2856
2863
  }
2857
2864
  arc(x, y, radius, startAngle, endAngle, anticlockwise) {
2858
- arc$1(this.path, x, y, radius, startAngle, endAngle, anticlockwise);
2865
+ arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
2859
2866
  return this;
2860
2867
  }
2861
2868
  arcTo(x1, y1, x2, y2, radius) {
2862
- arcTo$2(this.path, x1, y1, x2, y2, radius);
2869
+ arcTo$2(this.__path, x1, y1, x2, y2, radius);
2863
2870
  return this;
2864
2871
  }
2865
2872
  drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2866
- drawEllipse(this.path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2873
+ drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2867
2874
  return this;
2868
2875
  }
2869
2876
  drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
2870
- drawArc(this.path, x, y, radius, startAngle, endAngle, anticlockwise);
2877
+ drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
2871
2878
  return this;
2872
2879
  }
2873
2880
  drawPoints(points, curve, close) {
2874
- drawPoints$2(this.path, points, curve, close);
2881
+ drawPoints$2(this.__path, points, curve, close);
2875
2882
  return this;
2876
2883
  }
2877
2884
  }
@@ -3620,9 +3627,35 @@ function boundsType(defaultValue) {
3620
3627
  defineLeafAttr(target, key, defaultValue, {
3621
3628
  set(value) {
3622
3629
  this.__setAttr(key, value);
3623
- this.__layout.boxChanged || this.__layout.boxChange();
3624
- if (this.__hasAutoLayout)
3625
- this.__layout.matrixChanged || this.__layout.matrixChange();
3630
+ doBoundsType(this);
3631
+ }
3632
+ });
3633
+ };
3634
+ }
3635
+ function naturalBoundsType(defaultValue) {
3636
+ return (target, key) => {
3637
+ defineLeafAttr(target, key, defaultValue, {
3638
+ set(value) {
3639
+ this.__setAttr(key, value);
3640
+ doBoundsType(this);
3641
+ this.__.__removeNaturalSize();
3642
+ }
3643
+ });
3644
+ };
3645
+ }
3646
+ function doBoundsType(leaf) {
3647
+ leaf.__layout.boxChanged || leaf.__layout.boxChange();
3648
+ if (leaf.__hasAutoLayout)
3649
+ leaf.__layout.matrixChanged || leaf.__layout.matrixChange();
3650
+ }
3651
+ function pathInputType(defaultValue) {
3652
+ return (target, key) => {
3653
+ defineLeafAttr(target, key, defaultValue, {
3654
+ set(value) {
3655
+ if (this.__.__pathInputed !== 2)
3656
+ this.__.__pathInputed = value ? 1 : 0;
3657
+ this.__setAttr(key, value);
3658
+ doBoundsType(this);
3626
3659
  }
3627
3660
  });
3628
3661
  };
@@ -3633,11 +3666,14 @@ function affectStrokeBoundsType(defaultValue) {
3633
3666
  defineLeafAttr(target, key, defaultValue, {
3634
3667
  set(value) {
3635
3668
  this.__setAttr(key, value);
3636
- this.__layout.strokeChanged || this.__layout.strokeChange();
3669
+ doStrokeType(this);
3637
3670
  }
3638
3671
  });
3639
3672
  };
3640
3673
  }
3674
+ function doStrokeType(leaf) {
3675
+ leaf.__layout.strokeChanged || leaf.__layout.strokeChange();
3676
+ }
3641
3677
  const strokeType = affectStrokeBoundsType;
3642
3678
  function affectRenderBoundsType(defaultValue) {
3643
3679
  return (target, key) => {
@@ -4257,6 +4293,7 @@ class ChildEvent extends Event {
4257
4293
  }
4258
4294
  ChildEvent.ADD = 'child.add';
4259
4295
  ChildEvent.REMOVE = 'child.remove';
4296
+ ChildEvent.DESTROY = 'child.destroy';
4260
4297
 
4261
4298
  class PropertyEvent extends Event {
4262
4299
  constructor(type, target, attrName, oldValue, newValue) {
@@ -4704,6 +4741,7 @@ const WaitHelper = {
4704
4741
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2, hasParentAutoLayout } = LeafHelper;
4705
4742
  const { updateBounds: updateBounds$1 } = BranchHelper;
4706
4743
  const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
4744
+ const { toBounds: toBounds$2 } = PathBounds;
4707
4745
  const LeafBounds = {
4708
4746
  __updateWorldBounds() {
4709
4747
  toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
@@ -4715,7 +4753,8 @@ const LeafBounds = {
4715
4753
  __updateLocalBounds() {
4716
4754
  const layout = this.__layout;
4717
4755
  if (layout.boxChanged) {
4718
- this.__updatePath();
4756
+ if (!this.__.__pathInputed)
4757
+ this.__updatePath();
4719
4758
  this.__updateRenderPath();
4720
4759
  this.__updateBoxBounds();
4721
4760
  layout.boxChanged = false;
@@ -4782,11 +4821,16 @@ const LeafBounds = {
4782
4821
  },
4783
4822
  __updateBoxBounds() {
4784
4823
  const b = this.__layout.boxBounds;
4785
- const { width, height } = this.__;
4786
- b.x = 0;
4787
- b.y = 0;
4788
- b.width = width;
4789
- b.height = height;
4824
+ const data = this.__;
4825
+ if (data.__pathInputed) {
4826
+ toBounds$2(data.__pathForRender, b);
4827
+ }
4828
+ else {
4829
+ b.x = 0;
4830
+ b.y = 0;
4831
+ b.width = data.width;
4832
+ b.height = data.height;
4833
+ }
4790
4834
  },
4791
4835
  __updateAutoLayout() {
4792
4836
  this.__layout.matrixChanged = true;
@@ -4915,6 +4959,9 @@ let Leaf = class Leaf {
4915
4959
  get innerName() { return this.__.name || this.tag + this.innerId; }
4916
4960
  get __DataProcessor() { return LeafData; }
4917
4961
  get __LayoutProcessor() { return LeafLayout; }
4962
+ get isLeafer() { return false; }
4963
+ get isBranch() { return false; }
4964
+ get isBranchLeaf() { return false; }
4918
4965
  get __localMatrix() { return this.__local || this.__layout; }
4919
4966
  get __localBoxBounds() { return this.__local || this.__layout; }
4920
4967
  get worldTransform() { return this.__layout.getTransform('world'); }
@@ -4928,6 +4975,7 @@ let Leaf = class Leaf {
4928
4975
  get __worldFlipped() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
4929
4976
  get __onlyHitMask() { return this.__hasMask && !this.__.hitChildren; }
4930
4977
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
4978
+ get pathInputed() { return !!this.__.__pathInputed; }
4931
4979
  constructor(data) {
4932
4980
  this.innerId = create(LEAF);
4933
4981
  this.reset(data);
@@ -4979,7 +5027,7 @@ let Leaf = class Leaf {
4979
5027
  }
4980
5028
  }
4981
5029
  set(_data) { }
4982
- get() { return undefined; }
5030
+ get(_name) { return undefined; }
4983
5031
  toJSON() {
4984
5032
  return this.__.__getInputData();
4985
5033
  }
@@ -5196,10 +5244,13 @@ let Leaf = class Leaf {
5196
5244
  }
5197
5245
  destroy() {
5198
5246
  if (!this.destroyed) {
5199
- if (this.parent)
5247
+ const { parent } = this;
5248
+ if (parent)
5200
5249
  this.remove();
5201
5250
  if (this.children)
5202
5251
  this.removeAll(true);
5252
+ if (this.hasEvent(ChildEvent.DESTROY))
5253
+ this.emitEvent(new ChildEvent(ChildEvent.DESTROY, this, parent));
5203
5254
  this.__.destroy();
5204
5255
  this.__layout.destroy();
5205
5256
  this.__captureMap = this.__bubbleMap = this.__parentWait = this.__leaferWait = null;
@@ -5219,11 +5270,6 @@ const { setListWithFn } = BoundsHelper;
5219
5270
  const { sort } = BranchHelper;
5220
5271
  const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5221
5272
  let Branch = class Branch extends Leaf {
5222
- constructor() {
5223
- super();
5224
- this.isBranch = true;
5225
- this.children = [];
5226
- }
5227
5273
  __updateStrokeSpread() {
5228
5274
  const { children } = this;
5229
5275
  for (let i = 0, len = children.length; i < len; i++) {
@@ -5263,6 +5309,8 @@ let Branch = class Branch extends Leaf {
5263
5309
  }
5264
5310
  }
5265
5311
  add(child, index) {
5312
+ if (child === this)
5313
+ return;
5266
5314
  if (child.parent)
5267
5315
  child.parent.remove(child);
5268
5316
  child.parent = this;
@@ -6015,9 +6063,11 @@ class Layouter {
6015
6063
  updateAllChange(target);
6016
6064
  }
6017
6065
  addExtra(leaf) {
6018
- const block = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
6019
- block.updatedList.add(leaf);
6020
- block.beforeBounds.add(leaf.__world);
6066
+ if (!this.__updatedList.has(leaf)) {
6067
+ const { updatedList, beforeBounds } = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
6068
+ updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
6069
+ updatedList.add(leaf);
6070
+ }
6021
6071
  }
6022
6072
  createBlock(data) {
6023
6073
  return new LayoutBlockData(data);
@@ -6533,6 +6583,18 @@ Object.assign(Creator, {
6533
6583
  });
6534
6584
  Platform.layout = Layouter.fullLayout;
6535
6585
 
6586
+ function arrowType(defaultValue) {
6587
+ return (target, key) => {
6588
+ defineLeafAttr(target, key, defaultValue, {
6589
+ set(value) {
6590
+ this.__setAttr(key, value);
6591
+ doStrokeType(this);
6592
+ const data = this.__;
6593
+ data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
6594
+ }
6595
+ });
6596
+ };
6597
+ }
6536
6598
  function effectType(defaultValue) {
6537
6599
  return (target, key) => {
6538
6600
  defineLeafAttr(target, key, defaultValue, {
@@ -6559,12 +6621,14 @@ function resizeType(defaultValue) {
6559
6621
 
6560
6622
  const TextConvert = {};
6561
6623
  const ColorConvert = {};
6624
+ const PathArrow = {};
6562
6625
  const Paint = {};
6563
6626
  const PaintImage = {};
6564
6627
  const PaintGradient = {};
6565
6628
  const Effect = {};
6566
6629
  const Export = {};
6567
6630
 
6631
+ const { parse } = PathConvert;
6568
6632
  const emptyPaint = {};
6569
6633
  const debug$3 = Debug.get('UIData');
6570
6634
  class UIData extends LeafData {
@@ -6582,7 +6646,8 @@ class UIData extends LeafData {
6582
6646
  }
6583
6647
  get __autoWidth() { return !this._width; }
6584
6648
  get __autoHeight() { return !this._height; }
6585
- get __autoBounds() { return !this._width && !this._height; }
6649
+ get __autoSide() { return !this._width || !this._height; }
6650
+ get __autoSize() { return !this._width && !this._height; }
6586
6651
  setVisible(value) {
6587
6652
  if (this.__leaf.leafer)
6588
6653
  this.__leaf.leafer.watcher.hasVisible = true;
@@ -6610,7 +6675,7 @@ class UIData extends LeafData {
6610
6675
  }
6611
6676
  setFill(value) {
6612
6677
  if (this.__naturalWidth)
6613
- this.__naturalWidth = this.__naturalHeight = undefined;
6678
+ this.__removeNaturalSize();
6614
6679
  if (typeof value === 'string' || !value) {
6615
6680
  if (this.__isFills) {
6616
6681
  this.__removeInput('fill');
@@ -6646,6 +6711,17 @@ class UIData extends LeafData {
6646
6711
  this._stroke || (this._stroke = emptyPaint);
6647
6712
  }
6648
6713
  }
6714
+ setPath(value) {
6715
+ if (typeof value === 'string') {
6716
+ this.__setInput('path', value);
6717
+ this._path = parse(value);
6718
+ }
6719
+ else {
6720
+ if (this.__input)
6721
+ this.__removeInput('path');
6722
+ this._path = value;
6723
+ }
6724
+ }
6649
6725
  setShadow(value) {
6650
6726
  this.__setInput('shadow', value);
6651
6727
  if (value instanceof Array) {
@@ -6707,9 +6783,6 @@ class FrameData extends BoxData {
6707
6783
  class LineData extends UIData {
6708
6784
  }
6709
6785
 
6710
- class ArrowData extends LineData {
6711
- }
6712
-
6713
6786
  class RectData extends UIData {
6714
6787
  get __boxStroke() { return true; }
6715
6788
  }
@@ -6724,19 +6797,7 @@ class PolygonData extends UIData {
6724
6797
  class StarData extends UIData {
6725
6798
  }
6726
6799
 
6727
- const { parse } = PathConvert;
6728
6800
  class PathData extends UIData {
6729
- setPath(value) {
6730
- if (typeof value === 'string') {
6731
- this.__setInput('path', value);
6732
- this._path = parse(value);
6733
- }
6734
- else {
6735
- if (this.__input)
6736
- this.__removeInput('path');
6737
- this._path = value;
6738
- }
6739
- }
6740
6801
  }
6741
6802
 
6742
6803
  class PenData extends GroupData {
@@ -6806,6 +6867,8 @@ const UIBounds = {
6806
6867
  }
6807
6868
  }
6808
6869
  this.__layout.strokeBoxSpread = boxWidth;
6870
+ if (this.__.__useArrow)
6871
+ width += strokeWidth * 5;
6809
6872
  return width;
6810
6873
  },
6811
6874
  __updateRenderSpread() {
@@ -6939,6 +7002,7 @@ const RectRender = {
6939
7002
  var UI_1;
6940
7003
  let UI = UI_1 = class UI extends Leaf {
6941
7004
  get app() { return this.leafer && this.leafer.app; }
7005
+ get isFrame() { return false; }
6942
7006
  set scale(value) {
6943
7007
  if (typeof value === 'number') {
6944
7008
  this.scaleX = this.scaleY = value;
@@ -6959,8 +7023,8 @@ let UI = UI_1 = class UI extends Leaf {
6959
7023
  set(data) {
6960
7024
  Object.assign(this, data);
6961
7025
  }
6962
- get() {
6963
- return this.__.__getInputData();
7026
+ get(name) {
7027
+ return name ? this.__.__getInput(name) : this.__.__getInputData();
6964
7028
  }
6965
7029
  createProxyData() { return undefined; }
6966
7030
  find(_condition, _options) { return undefined; }
@@ -6992,6 +7056,8 @@ let UI = UI_1 = class UI extends Leaf {
6992
7056
  if (this.__.path) {
6993
7057
  const data = this.__;
6994
7058
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
7059
+ if (data.__useArrow)
7060
+ PathArrow.addArrows(this, !data.cornerRadius);
6995
7061
  }
6996
7062
  }
6997
7063
  __drawRenderPath(canvas) {
@@ -7002,7 +7068,14 @@ let UI = UI_1 = class UI extends Leaf {
7002
7068
  canvas.beginPath();
7003
7069
  this.__drawPathByData(canvas, this.__.path);
7004
7070
  }
7005
- __drawPathByData(_drawer, _data) { }
7071
+ __drawPathByData(drawer, data) {
7072
+ if (data) {
7073
+ PathDrawer.drawPathByData(drawer, data);
7074
+ }
7075
+ else {
7076
+ this.__drawPathByBox(drawer);
7077
+ }
7078
+ }
7006
7079
  __drawPathByBox(drawer) {
7007
7080
  const { x, y, width, height } = this.__layout.boxBounds;
7008
7081
  if (this.__.cornerRadius) {
@@ -7021,6 +7094,12 @@ let UI = UI_1 = class UI extends Leaf {
7021
7094
  static one(data, x, y, width, height) {
7022
7095
  return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height);
7023
7096
  }
7097
+ static registerUI() {
7098
+ registerUI()(this);
7099
+ }
7100
+ static registerData(data) {
7101
+ dataProcessor(data)(this.prototype);
7102
+ }
7024
7103
  destroy() {
7025
7104
  this.fill = this.stroke = null;
7026
7105
  super.destroy();
@@ -7159,10 +7238,19 @@ __decorate([
7159
7238
  dataType(false)
7160
7239
  ], UI.prototype, "lazy", void 0);
7161
7240
  __decorate([
7162
- strokeType('none')
7241
+ naturalBoundsType(1)
7242
+ ], UI.prototype, "pixelRatio", void 0);
7243
+ __decorate([
7244
+ pathInputType()
7245
+ ], UI.prototype, "path", void 0);
7246
+ __decorate([
7247
+ pathType()
7248
+ ], UI.prototype, "windingRule", void 0);
7249
+ __decorate([
7250
+ arrowType('none')
7163
7251
  ], UI.prototype, "startArrow", void 0);
7164
7252
  __decorate([
7165
- strokeType('none')
7253
+ arrowType('none')
7166
7254
  ], UI.prototype, "endArrow", void 0);
7167
7255
  __decorate([
7168
7256
  pathType(0)
@@ -7188,9 +7276,6 @@ __decorate([
7188
7276
  __decorate([
7189
7277
  rewrite(Leaf.prototype.reset)
7190
7278
  ], UI.prototype, "reset", null);
7191
- __decorate([
7192
- rewrite(PathDrawer.drawPathByData)
7193
- ], UI.prototype, "__drawPathByData", null);
7194
7279
  UI = UI_1 = __decorate([
7195
7280
  useModule(UIBounds),
7196
7281
  useModule(UIRender),
@@ -7199,12 +7284,15 @@ UI = UI_1 = __decorate([
7199
7284
 
7200
7285
  let Group = class Group extends UI {
7201
7286
  get __tag() { return 'Group'; }
7287
+ get isBranch() { return true; }
7202
7288
  constructor(data) {
7203
7289
  super(data);
7290
+ }
7291
+ reset(data) {
7204
7292
  this.__setBranch();
7293
+ super.reset(data);
7205
7294
  }
7206
7295
  __setBranch() {
7207
- this.isBranch = true;
7208
7296
  if (!this.children)
7209
7297
  this.children = [];
7210
7298
  }
@@ -7216,7 +7304,7 @@ let Group = class Group extends UI {
7216
7304
  this.__setBranch();
7217
7305
  }
7218
7306
  else {
7219
- this.removeAll(true);
7307
+ this.clear();
7220
7308
  }
7221
7309
  super.set(data);
7222
7310
  let child;
@@ -7264,6 +7352,7 @@ let Leafer = class Leafer extends Group {
7264
7352
  get __tag() { return 'Leafer'; }
7265
7353
  get isApp() { return false; }
7266
7354
  get app() { return this.parent || this; }
7355
+ get isLeafer() { return true; }
7267
7356
  get imageReady() { return this.viewReady && ImageManager.isComplete; }
7268
7357
  get layoutLocked() { return !this.layouter.running; }
7269
7358
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
@@ -7380,7 +7469,7 @@ let Leafer = class Leafer extends Group {
7380
7469
  this.forceRender();
7381
7470
  }
7382
7471
  forceRender(bounds) {
7383
- this.renderer.addBlock(new Bounds(bounds) || this.canvas.bounds);
7472
+ this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7384
7473
  if (this.viewReady)
7385
7474
  this.renderer.update();
7386
7475
  }
@@ -7411,7 +7500,6 @@ let Leafer = class Leafer extends Group {
7411
7500
  }
7412
7501
  __setLeafer(leafer) {
7413
7502
  this.leafer = leafer;
7414
- this.isLeafer = !!leafer;
7415
7503
  this.__level = 1;
7416
7504
  }
7417
7505
  setZoomLayer(zoomLayer) {
@@ -7598,14 +7686,10 @@ let Rect = class Rect extends UI {
7598
7686
  constructor(data) {
7599
7687
  super(data);
7600
7688
  }
7601
- __drawPathByData(_drawer, _data) { }
7602
7689
  };
7603
7690
  __decorate([
7604
7691
  dataProcessor(RectData)
7605
7692
  ], Rect.prototype, "__", void 0);
7606
- __decorate([
7607
- rewrite(UI.prototype.__drawPathByBox)
7608
- ], Rect.prototype, "__drawPathByData", null);
7609
7693
  Rect = __decorate([
7610
7694
  useModule(RectRender),
7611
7695
  rewriteAble(),
@@ -7618,9 +7702,9 @@ const bounds$1 = {};
7618
7702
  const { copy: copy$3, add } = BoundsHelper;
7619
7703
  let Box = class Box extends Group {
7620
7704
  get __tag() { return 'Box'; }
7705
+ get isBranchLeaf() { return true; }
7621
7706
  constructor(data) {
7622
7707
  super(data);
7623
- this.isBranchLeaf = true;
7624
7708
  this.__layout.renderChanged || this.__layout.renderChange();
7625
7709
  }
7626
7710
  __updateStrokeSpread() { return 0; }
@@ -7634,8 +7718,18 @@ let Box = class Box extends Group {
7634
7718
  }
7635
7719
  __updateRectBoxBounds() { }
7636
7720
  __updateBoxBounds() {
7637
- if (this.__.__autoBounds && this.children.length) {
7721
+ const data = this.__;
7722
+ if (data.__autoSide && this.children.length) {
7723
+ if (this.leafer)
7724
+ this.leafer.layouter.addExtra(this);
7638
7725
  super.__updateBoxBounds();
7726
+ if (!data.__autoSize) {
7727
+ const b = this.__layout.boxBounds;
7728
+ if (!data.__autoWidth)
7729
+ b.x = 0, b.width = data.width;
7730
+ if (!data.__autoHeight)
7731
+ b.y = 0, b.height = data.height;
7732
+ }
7639
7733
  }
7640
7734
  else {
7641
7735
  this.__updateRectBoxBounds();
@@ -7657,7 +7751,6 @@ let Box = class Box extends Group {
7657
7751
  super.__updateChange();
7658
7752
  this.__updateRectChange();
7659
7753
  }
7660
- __drawPathByData(_drawer, _data) { }
7661
7754
  __renderRect(_canvas, _options) { }
7662
7755
  __renderGroup(_canvas, _options) { }
7663
7756
  __render(canvas, options) {
@@ -7702,9 +7795,6 @@ __decorate([
7702
7795
  __decorate([
7703
7796
  rewrite(rect.__updateChange)
7704
7797
  ], Box.prototype, "__updateRectChange", null);
7705
- __decorate([
7706
- rewrite(rect.__drawPathByData)
7707
- ], Box.prototype, "__drawPathByData", null);
7708
7798
  __decorate([
7709
7799
  rewrite(rect.__render)
7710
7800
  ], Box.prototype, "__renderRect", null);
@@ -7718,9 +7808,9 @@ Box = __decorate([
7718
7808
 
7719
7809
  let Frame = class Frame extends Box {
7720
7810
  get __tag() { return 'Frame'; }
7811
+ get isFrame() { return true; }
7721
7812
  constructor(data) {
7722
7813
  super(data);
7723
- this.isFrame = true;
7724
7814
  }
7725
7815
  };
7726
7816
  __decorate([
@@ -7794,7 +7884,7 @@ Ellipse = __decorate([
7794
7884
 
7795
7885
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
7796
7886
  const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
7797
- const { toBounds: toBounds$2 } = PathBounds;
7887
+ const { toBounds: toBounds$1 } = PathBounds;
7798
7888
  let Line = class Line extends UI {
7799
7889
  get __tag() { return 'Line'; }
7800
7890
  get toPoint() {
@@ -7826,8 +7916,11 @@ let Line = class Line extends UI {
7826
7916
  }
7827
7917
  }
7828
7918
  __updateRenderPath() {
7829
- if (this.__.points && this.__.curve) {
7830
- drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
7919
+ const data = this.__;
7920
+ if (!this.pathInputed && data.points && data.curve) {
7921
+ drawPoints$1(data.__pathForRender = [], data.points, data.curve, this.pathClosed);
7922
+ if (data.__useArrow)
7923
+ PathArrow.addArrows(this, false);
7831
7924
  }
7832
7925
  else {
7833
7926
  super.__updateRenderPath();
@@ -7835,7 +7928,7 @@ let Line = class Line extends UI {
7835
7928
  }
7836
7929
  __updateBoxBounds() {
7837
7930
  if (this.points) {
7838
- toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
7931
+ toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
7839
7932
  }
7840
7933
  else {
7841
7934
  super.__updateBoxBounds();
@@ -7868,6 +7961,7 @@ let Polygon = class Polygon extends UI {
7868
7961
  get __tag() { return 'Polygon'; }
7869
7962
  constructor(data) {
7870
7963
  super(data);
7964
+ this.pathClosed = true;
7871
7965
  }
7872
7966
  __updatePath() {
7873
7967
  const path = this.__.path = [];
@@ -8023,7 +8117,7 @@ let Canvas = class Canvas extends Rect {
8023
8117
  }
8024
8118
  };
8025
8119
  __decorate([
8026
- dataProcessor(ImageData)
8120
+ dataProcessor(CanvasData)
8027
8121
  ], Canvas.prototype, "__", void 0);
8028
8122
  __decorate([
8029
8123
  resizeType(100)
@@ -8086,7 +8180,7 @@ let Text = class Text extends UI {
8086
8180
  data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
8087
8181
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8088
8182
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8089
- data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
8183
+ data.__clipText = textOverflow !== 'show' && !data.__autoSize;
8090
8184
  this.__updateTextDrawData();
8091
8185
  const { bounds } = data.__textDrawData;
8092
8186
  const b = layout.boxBounds;
@@ -8203,25 +8297,16 @@ Text = __decorate([
8203
8297
  registerUI()
8204
8298
  ], Text);
8205
8299
 
8206
- const { toBounds: toBounds$1 } = PathBounds;
8207
8300
  let Path = class Path extends UI {
8208
8301
  get __tag() { return 'Path'; }
8209
8302
  constructor(data) {
8210
8303
  super(data);
8211
- }
8212
- __updateBoxBounds() {
8213
- toBounds$1(this.__.path, this.__layout.boxBounds);
8304
+ this.__.__pathInputed = 2;
8214
8305
  }
8215
8306
  };
8216
8307
  __decorate([
8217
8308
  dataProcessor(PathData)
8218
8309
  ], Path.prototype, "__", void 0);
8219
- __decorate([
8220
- pathType()
8221
- ], Path.prototype, "path", void 0);
8222
- __decorate([
8223
- pathType()
8224
- ], Path.prototype, "windingRule", void 0);
8225
8310
  __decorate([
8226
8311
  affectStrokeBoundsType('center')
8227
8312
  ], Path.prototype, "strokeAlign", void 0);
@@ -8237,12 +8322,12 @@ let Pen = class Pen extends Group {
8237
8322
  setStyle(data) {
8238
8323
  const path = this.pathElement = new Path(data);
8239
8324
  this.pathStyle = data;
8240
- this.path = path.path || (path.path = []);
8325
+ this.__path = path.path || (path.path = []);
8241
8326
  this.add(path);
8242
8327
  return this;
8243
8328
  }
8244
8329
  beginPath() {
8245
- this.path.length = 0;
8330
+ this.__path.length = 0;
8246
8331
  this.paint();
8247
8332
  return this;
8248
8333
  }
@@ -8266,10 +8351,20 @@ let Pen = class Pen extends Group {
8266
8351
  __decorate([
8267
8352
  dataProcessor(PenData)
8268
8353
  ], Pen.prototype, "__", void 0);
8354
+ __decorate([
8355
+ penPathType()
8356
+ ], Pen.prototype, "path", void 0);
8269
8357
  Pen = __decorate([
8270
- useModule(PathCreator, ['beginPath']),
8358
+ useModule(PathCreator, ['beginPath', 'path']),
8271
8359
  registerUI()
8272
8360
  ], Pen);
8361
+ function penPathType() {
8362
+ return (target, key) => {
8363
+ defineKey(target, key, {
8364
+ get() { return this.__path; }
8365
+ });
8366
+ };
8367
+ }
8273
8368
 
8274
8369
  let App = class App extends Leafer {
8275
8370
  get __tag() { return 'App'; }
@@ -10370,9 +10465,9 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10370
10465
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
10371
10466
  if (attrName === 'fill' && !ui.__.__naturalWidth) {
10372
10467
  const data = ui.__;
10373
- data.__naturalWidth = image.width;
10374
- data.__naturalHeight = image.height;
10375
- if (data.__autoWidth || data.__autoHeight) {
10468
+ data.__naturalWidth = image.width / data.pixelRatio;
10469
+ data.__naturalHeight = image.height / data.pixelRatio;
10470
+ if (data.__autoSide) {
10376
10471
  ui.forceUpdate('width');
10377
10472
  if (ui.__proxyData) {
10378
10473
  ui.setProxyAttr('width', data.width);
@@ -10402,7 +10497,7 @@ function emit(ui, type, data) {
10402
10497
  }
10403
10498
 
10404
10499
  const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
10405
- const { round, abs: abs$1 } = Math;
10500
+ const { ceil, abs: abs$1 } = Math;
10406
10501
  function createPattern(ui, paint, pixelRatio) {
10407
10502
  let { scaleX, scaleY } = ui.__world;
10408
10503
  const id = scaleX + '-' + scaleY;
@@ -10453,7 +10548,7 @@ function createPattern(ui, paint, pixelRatio) {
10453
10548
  }
10454
10549
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
10455
10550
  }
10456
- const canvas = image.getCanvas(width < 1 ? 1 : round(width), height < 1 ? 1 : round(height), opacity);
10551
+ const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, opacity);
10457
10552
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
10458
10553
  paint.style = pattern;
10459
10554
  paint.patternId = id;
@@ -11364,37 +11459,55 @@ const ExportModule = {
11364
11459
  const { leafer } = leaf;
11365
11460
  if (leafer) {
11366
11461
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
11367
- let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
11368
11462
  options = FileHelper.getExportOptions(options);
11369
- const { scale, slice, trim } = options;
11463
+ let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
11464
+ const { worldTransform, isLeafer, isFrame } = leaf;
11465
+ const { slice, trim, onCanvas } = options;
11466
+ const scale = options.scale || 1;
11370
11467
  const pixelRatio = options.pixelRatio || 1;
11371
11468
  const screenshot = options.screenshot || leaf.isApp;
11372
- const fill = options.fill === undefined ? ((leaf.isLeafer && screenshot) ? leaf.fill : '') : options.fill;
11469
+ const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : undefined) : options.fill;
11373
11470
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
11374
11471
  if (screenshot) {
11375
- renderBounds = screenshot === true ? (leaf.isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
11472
+ renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
11376
11473
  }
11377
11474
  else {
11378
- const { localTransform, __world: world } = leaf;
11379
- matrix.set(world).divide(localTransform).invert();
11380
- scaleX = 1 / (world.scaleX / leaf.scaleX);
11381
- scaleY = 1 / (world.scaleY / leaf.scaleY);
11382
- renderBounds = leaf.getBounds('render', 'local');
11383
- }
11384
- let { x, y, width, height } = renderBounds;
11385
- if (scale) {
11386
- matrix.scale(scale);
11387
- width *= scale, height *= scale;
11388
- scaleX *= scale, scaleY *= scale;
11475
+ const location = options.location || ((isLeafer || isFrame) ? 'inner' : 'local');
11476
+ scaleX = worldTransform.scaleX;
11477
+ scaleY = worldTransform.scaleY;
11478
+ switch (location) {
11479
+ case 'inner':
11480
+ matrix.set(worldTransform).invert();
11481
+ break;
11482
+ case 'local':
11483
+ matrix.set(worldTransform).divide(leaf.localTransform).invert();
11484
+ scaleX /= leaf.scaleX;
11485
+ scaleY /= leaf.scaleY;
11486
+ break;
11487
+ case 'world':
11488
+ scaleX = 1;
11489
+ scaleY = 1;
11490
+ break;
11491
+ }
11492
+ renderBounds = leaf.getBounds('render', location);
11389
11493
  }
11390
- let canvas = Creator.canvas({ width: Math.ceil(width), height: Math.ceil(height), pixelRatio });
11391
- const renderOptions = { matrix: matrix.translate(-x, -y).withScale(scaleX, scaleY) };
11494
+ const { x, y, width, height } = new Bounds(renderBounds).scale(scale).ceil();
11495
+ let canvas = Creator.canvas({ width, height, pixelRatio });
11496
+ const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
11392
11497
  if (slice) {
11393
11498
  leaf = leafer;
11394
11499
  renderOptions.bounds = canvas.bounds;
11395
11500
  }
11396
11501
  canvas.save();
11397
- leaf.__render(canvas, renderOptions);
11502
+ if (isFrame && fill !== undefined) {
11503
+ const oldFill = leaf.get('fill');
11504
+ leaf.fill = '';
11505
+ leaf.__render(canvas, renderOptions);
11506
+ leaf.fill = oldFill;
11507
+ }
11508
+ else {
11509
+ leaf.__render(canvas, renderOptions);
11510
+ }
11398
11511
  canvas.restore();
11399
11512
  if (trim) {
11400
11513
  trimBounds = getTrimBounds(canvas);
@@ -11405,6 +11518,8 @@ const ExportModule = {
11405
11518
  }
11406
11519
  if (needFill)
11407
11520
  canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
11521
+ if (onCanvas)
11522
+ onCanvas(canvas);
11408
11523
  const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
11409
11524
  over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
11410
11525
  }));
@@ -11439,4 +11554,4 @@ Object.assign(Creator, {
11439
11554
  });
11440
11555
  useCanvas();
11441
11556
 
11442
- export { AnimateEvent, Answer, App, AroundHelper, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, effectType, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, opacityType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useCanvas, useModule };
11557
+ export { AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, arrowType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useCanvas, useModule };