@leafer-draw/worker 1.0.0-rc.12 → 1.0.0-rc.17

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$1 = 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$9(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$9(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$9(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$9, 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;
@@ -5886,9 +5934,11 @@ class Layouter {
5886
5934
  updateAllChange(target);
5887
5935
  }
5888
5936
  addExtra(leaf) {
5889
- const block = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
5890
- block.updatedList.add(leaf);
5891
- block.beforeBounds.add(leaf.__world);
5937
+ if (!this.__updatedList.has(leaf)) {
5938
+ const { updatedList, beforeBounds } = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
5939
+ updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
5940
+ updatedList.add(leaf);
5941
+ }
5892
5942
  }
5893
5943
  createBlock(data) {
5894
5944
  return new LayoutBlockData(data);
@@ -6161,6 +6211,18 @@ Object.assign(Creator, {
6161
6211
  });
6162
6212
  Platform.layout = Layouter.fullLayout;
6163
6213
 
6214
+ function arrowType(defaultValue) {
6215
+ return (target, key) => {
6216
+ defineLeafAttr(target, key, defaultValue, {
6217
+ set(value) {
6218
+ this.__setAttr(key, value);
6219
+ doStrokeType(this);
6220
+ const data = this.__;
6221
+ data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
6222
+ }
6223
+ });
6224
+ };
6225
+ }
6164
6226
  function effectType(defaultValue) {
6165
6227
  return (target, key) => {
6166
6228
  defineLeafAttr(target, key, defaultValue, {
@@ -6187,12 +6249,14 @@ function resizeType(defaultValue) {
6187
6249
 
6188
6250
  const TextConvert = {};
6189
6251
  const ColorConvert = {};
6252
+ const PathArrow = {};
6190
6253
  const Paint = {};
6191
6254
  const PaintImage = {};
6192
6255
  const PaintGradient = {};
6193
6256
  const Effect = {};
6194
6257
  const Export = {};
6195
6258
 
6259
+ const { parse } = PathConvert;
6196
6260
  const emptyPaint = {};
6197
6261
  const debug$1 = Debug.get('UIData');
6198
6262
  class UIData extends LeafData {
@@ -6210,7 +6274,8 @@ class UIData extends LeafData {
6210
6274
  }
6211
6275
  get __autoWidth() { return !this._width; }
6212
6276
  get __autoHeight() { return !this._height; }
6213
- get __autoBounds() { return !this._width && !this._height; }
6277
+ get __autoSide() { return !this._width || !this._height; }
6278
+ get __autoSize() { return !this._width && !this._height; }
6214
6279
  setVisible(value) {
6215
6280
  if (this.__leaf.leafer)
6216
6281
  this.__leaf.leafer.watcher.hasVisible = true;
@@ -6238,7 +6303,7 @@ class UIData extends LeafData {
6238
6303
  }
6239
6304
  setFill(value) {
6240
6305
  if (this.__naturalWidth)
6241
- this.__naturalWidth = this.__naturalHeight = undefined;
6306
+ this.__removeNaturalSize();
6242
6307
  if (typeof value === 'string' || !value) {
6243
6308
  if (this.__isFills) {
6244
6309
  this.__removeInput('fill');
@@ -6274,6 +6339,17 @@ class UIData extends LeafData {
6274
6339
  this._stroke || (this._stroke = emptyPaint);
6275
6340
  }
6276
6341
  }
6342
+ setPath(value) {
6343
+ if (typeof value === 'string') {
6344
+ this.__setInput('path', value);
6345
+ this._path = parse(value);
6346
+ }
6347
+ else {
6348
+ if (this.__input)
6349
+ this.__removeInput('path');
6350
+ this._path = value;
6351
+ }
6352
+ }
6277
6353
  setShadow(value) {
6278
6354
  this.__setInput('shadow', value);
6279
6355
  if (value instanceof Array) {
@@ -6335,9 +6411,6 @@ class FrameData extends BoxData {
6335
6411
  class LineData extends UIData {
6336
6412
  }
6337
6413
 
6338
- class ArrowData extends LineData {
6339
- }
6340
-
6341
6414
  class RectData extends UIData {
6342
6415
  get __boxStroke() { return true; }
6343
6416
  }
@@ -6352,19 +6425,7 @@ class PolygonData extends UIData {
6352
6425
  class StarData extends UIData {
6353
6426
  }
6354
6427
 
6355
- const { parse } = PathConvert;
6356
6428
  class PathData extends UIData {
6357
- setPath(value) {
6358
- if (typeof value === 'string') {
6359
- this.__setInput('path', value);
6360
- this._path = parse(value);
6361
- }
6362
- else {
6363
- if (this.__input)
6364
- this.__removeInput('path');
6365
- this._path = value;
6366
- }
6367
- }
6368
6429
  }
6369
6430
 
6370
6431
  class PenData extends GroupData {
@@ -6434,6 +6495,8 @@ const UIBounds = {
6434
6495
  }
6435
6496
  }
6436
6497
  this.__layout.strokeBoxSpread = boxWidth;
6498
+ if (this.__.__useArrow)
6499
+ width += strokeWidth * 5;
6437
6500
  return width;
6438
6501
  },
6439
6502
  __updateRenderSpread() {
@@ -6567,6 +6630,7 @@ const RectRender = {
6567
6630
  var UI_1;
6568
6631
  let UI = UI_1 = class UI extends Leaf {
6569
6632
  get app() { return this.leafer && this.leafer.app; }
6633
+ get isFrame() { return false; }
6570
6634
  set scale(value) {
6571
6635
  if (typeof value === 'number') {
6572
6636
  this.scaleX = this.scaleY = value;
@@ -6587,8 +6651,8 @@ let UI = UI_1 = class UI extends Leaf {
6587
6651
  set(data) {
6588
6652
  Object.assign(this, data);
6589
6653
  }
6590
- get() {
6591
- return this.__.__getInputData();
6654
+ get(name) {
6655
+ return name ? this.__.__getInput(name) : this.__.__getInputData();
6592
6656
  }
6593
6657
  createProxyData() { return undefined; }
6594
6658
  find(_condition, _options) { return undefined; }
@@ -6620,6 +6684,8 @@ let UI = UI_1 = class UI extends Leaf {
6620
6684
  if (this.__.path) {
6621
6685
  const data = this.__;
6622
6686
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
6687
+ if (data.__useArrow)
6688
+ PathArrow.addArrows(this, !data.cornerRadius);
6623
6689
  }
6624
6690
  }
6625
6691
  __drawRenderPath(canvas) {
@@ -6630,7 +6696,14 @@ let UI = UI_1 = class UI extends Leaf {
6630
6696
  canvas.beginPath();
6631
6697
  this.__drawPathByData(canvas, this.__.path);
6632
6698
  }
6633
- __drawPathByData(_drawer, _data) { }
6699
+ __drawPathByData(drawer, data) {
6700
+ if (data) {
6701
+ PathDrawer.drawPathByData(drawer, data);
6702
+ }
6703
+ else {
6704
+ this.__drawPathByBox(drawer);
6705
+ }
6706
+ }
6634
6707
  __drawPathByBox(drawer) {
6635
6708
  const { x, y, width, height } = this.__layout.boxBounds;
6636
6709
  if (this.__.cornerRadius) {
@@ -6649,6 +6722,12 @@ let UI = UI_1 = class UI extends Leaf {
6649
6722
  static one(data, x, y, width, height) {
6650
6723
  return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height);
6651
6724
  }
6725
+ static registerUI() {
6726
+ registerUI()(this);
6727
+ }
6728
+ static registerData(data) {
6729
+ dataProcessor(data)(this.prototype);
6730
+ }
6652
6731
  destroy() {
6653
6732
  this.fill = this.stroke = null;
6654
6733
  super.destroy();
@@ -6787,10 +6866,19 @@ __decorate([
6787
6866
  dataType(false)
6788
6867
  ], UI.prototype, "lazy", void 0);
6789
6868
  __decorate([
6790
- strokeType('none')
6869
+ naturalBoundsType(1)
6870
+ ], UI.prototype, "pixelRatio", void 0);
6871
+ __decorate([
6872
+ pathInputType()
6873
+ ], UI.prototype, "path", void 0);
6874
+ __decorate([
6875
+ pathType()
6876
+ ], UI.prototype, "windingRule", void 0);
6877
+ __decorate([
6878
+ arrowType('none')
6791
6879
  ], UI.prototype, "startArrow", void 0);
6792
6880
  __decorate([
6793
- strokeType('none')
6881
+ arrowType('none')
6794
6882
  ], UI.prototype, "endArrow", void 0);
6795
6883
  __decorate([
6796
6884
  pathType(0)
@@ -6816,9 +6904,6 @@ __decorate([
6816
6904
  __decorate([
6817
6905
  rewrite(Leaf.prototype.reset)
6818
6906
  ], UI.prototype, "reset", null);
6819
- __decorate([
6820
- rewrite(PathDrawer.drawPathByData)
6821
- ], UI.prototype, "__drawPathByData", null);
6822
6907
  UI = UI_1 = __decorate([
6823
6908
  useModule(UIBounds),
6824
6909
  useModule(UIRender),
@@ -6827,12 +6912,15 @@ UI = UI_1 = __decorate([
6827
6912
 
6828
6913
  let Group = class Group extends UI {
6829
6914
  get __tag() { return 'Group'; }
6915
+ get isBranch() { return true; }
6830
6916
  constructor(data) {
6831
6917
  super(data);
6918
+ }
6919
+ reset(data) {
6832
6920
  this.__setBranch();
6921
+ super.reset(data);
6833
6922
  }
6834
6923
  __setBranch() {
6835
- this.isBranch = true;
6836
6924
  if (!this.children)
6837
6925
  this.children = [];
6838
6926
  }
@@ -6844,7 +6932,7 @@ let Group = class Group extends UI {
6844
6932
  this.__setBranch();
6845
6933
  }
6846
6934
  else {
6847
- this.removeAll(true);
6935
+ this.clear();
6848
6936
  }
6849
6937
  super.set(data);
6850
6938
  let child;
@@ -6892,6 +6980,7 @@ let Leafer = class Leafer extends Group {
6892
6980
  get __tag() { return 'Leafer'; }
6893
6981
  get isApp() { return false; }
6894
6982
  get app() { return this.parent || this; }
6983
+ get isLeafer() { return true; }
6895
6984
  get imageReady() { return this.viewReady && ImageManager.isComplete; }
6896
6985
  get layoutLocked() { return !this.layouter.running; }
6897
6986
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
@@ -7008,7 +7097,7 @@ let Leafer = class Leafer extends Group {
7008
7097
  this.forceRender();
7009
7098
  }
7010
7099
  forceRender(bounds) {
7011
- this.renderer.addBlock(new Bounds(bounds) || this.canvas.bounds);
7100
+ this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7012
7101
  if (this.viewReady)
7013
7102
  this.renderer.update();
7014
7103
  }
@@ -7039,7 +7128,6 @@ let Leafer = class Leafer extends Group {
7039
7128
  }
7040
7129
  __setLeafer(leafer) {
7041
7130
  this.leafer = leafer;
7042
- this.isLeafer = !!leafer;
7043
7131
  this.__level = 1;
7044
7132
  }
7045
7133
  setZoomLayer(zoomLayer) {
@@ -7226,14 +7314,10 @@ let Rect = class Rect extends UI {
7226
7314
  constructor(data) {
7227
7315
  super(data);
7228
7316
  }
7229
- __drawPathByData(_drawer, _data) { }
7230
7317
  };
7231
7318
  __decorate([
7232
7319
  dataProcessor(RectData)
7233
7320
  ], Rect.prototype, "__", void 0);
7234
- __decorate([
7235
- rewrite(UI.prototype.__drawPathByBox)
7236
- ], Rect.prototype, "__drawPathByData", null);
7237
7321
  Rect = __decorate([
7238
7322
  useModule(RectRender),
7239
7323
  rewriteAble(),
@@ -7246,9 +7330,9 @@ const bounds$1 = {};
7246
7330
  const { copy: copy$2, add } = BoundsHelper;
7247
7331
  let Box = class Box extends Group {
7248
7332
  get __tag() { return 'Box'; }
7333
+ get isBranchLeaf() { return true; }
7249
7334
  constructor(data) {
7250
7335
  super(data);
7251
- this.isBranchLeaf = true;
7252
7336
  this.__layout.renderChanged || this.__layout.renderChange();
7253
7337
  }
7254
7338
  __updateStrokeSpread() { return 0; }
@@ -7262,8 +7346,18 @@ let Box = class Box extends Group {
7262
7346
  }
7263
7347
  __updateRectBoxBounds() { }
7264
7348
  __updateBoxBounds() {
7265
- if (this.__.__autoBounds && this.children.length) {
7349
+ const data = this.__;
7350
+ if (data.__autoSide && this.children.length) {
7351
+ if (this.leafer)
7352
+ this.leafer.layouter.addExtra(this);
7266
7353
  super.__updateBoxBounds();
7354
+ if (!data.__autoSize) {
7355
+ const b = this.__layout.boxBounds;
7356
+ if (!data.__autoWidth)
7357
+ b.x = 0, b.width = data.width;
7358
+ if (!data.__autoHeight)
7359
+ b.y = 0, b.height = data.height;
7360
+ }
7267
7361
  }
7268
7362
  else {
7269
7363
  this.__updateRectBoxBounds();
@@ -7285,7 +7379,6 @@ let Box = class Box extends Group {
7285
7379
  super.__updateChange();
7286
7380
  this.__updateRectChange();
7287
7381
  }
7288
- __drawPathByData(_drawer, _data) { }
7289
7382
  __renderRect(_canvas, _options) { }
7290
7383
  __renderGroup(_canvas, _options) { }
7291
7384
  __render(canvas, options) {
@@ -7330,9 +7423,6 @@ __decorate([
7330
7423
  __decorate([
7331
7424
  rewrite(rect.__updateChange)
7332
7425
  ], Box.prototype, "__updateRectChange", null);
7333
- __decorate([
7334
- rewrite(rect.__drawPathByData)
7335
- ], Box.prototype, "__drawPathByData", null);
7336
7426
  __decorate([
7337
7427
  rewrite(rect.__render)
7338
7428
  ], Box.prototype, "__renderRect", null);
@@ -7346,9 +7436,9 @@ Box = __decorate([
7346
7436
 
7347
7437
  let Frame = class Frame extends Box {
7348
7438
  get __tag() { return 'Frame'; }
7439
+ get isFrame() { return true; }
7349
7440
  constructor(data) {
7350
7441
  super(data);
7351
- this.isFrame = true;
7352
7442
  }
7353
7443
  };
7354
7444
  __decorate([
@@ -7422,7 +7512,7 @@ Ellipse = __decorate([
7422
7512
 
7423
7513
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
7424
7514
  const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
7425
- const { toBounds: toBounds$2 } = PathBounds;
7515
+ const { toBounds: toBounds$1 } = PathBounds;
7426
7516
  let Line = class Line extends UI {
7427
7517
  get __tag() { return 'Line'; }
7428
7518
  get toPoint() {
@@ -7454,8 +7544,11 @@ let Line = class Line extends UI {
7454
7544
  }
7455
7545
  }
7456
7546
  __updateRenderPath() {
7457
- if (this.__.points && this.__.curve) {
7458
- drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
7547
+ const data = this.__;
7548
+ if (!this.pathInputed && data.points && data.curve) {
7549
+ drawPoints$1(data.__pathForRender = [], data.points, data.curve, this.pathClosed);
7550
+ if (data.__useArrow)
7551
+ PathArrow.addArrows(this, false);
7459
7552
  }
7460
7553
  else {
7461
7554
  super.__updateRenderPath();
@@ -7463,7 +7556,7 @@ let Line = class Line extends UI {
7463
7556
  }
7464
7557
  __updateBoxBounds() {
7465
7558
  if (this.points) {
7466
- toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
7559
+ toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
7467
7560
  }
7468
7561
  else {
7469
7562
  super.__updateBoxBounds();
@@ -7496,6 +7589,7 @@ let Polygon = class Polygon extends UI {
7496
7589
  get __tag() { return 'Polygon'; }
7497
7590
  constructor(data) {
7498
7591
  super(data);
7592
+ this.pathClosed = true;
7499
7593
  }
7500
7594
  __updatePath() {
7501
7595
  const path = this.__.path = [];
@@ -7651,7 +7745,7 @@ let Canvas = class Canvas extends Rect {
7651
7745
  }
7652
7746
  };
7653
7747
  __decorate([
7654
- dataProcessor(ImageData)
7748
+ dataProcessor(CanvasData)
7655
7749
  ], Canvas.prototype, "__", void 0);
7656
7750
  __decorate([
7657
7751
  resizeType(100)
@@ -7714,7 +7808,7 @@ let Text = class Text extends UI {
7714
7808
  data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
7715
7809
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
7716
7810
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
7717
- data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
7811
+ data.__clipText = textOverflow !== 'show' && !data.__autoSize;
7718
7812
  this.__updateTextDrawData();
7719
7813
  const { bounds } = data.__textDrawData;
7720
7814
  const b = layout.boxBounds;
@@ -7831,25 +7925,16 @@ Text = __decorate([
7831
7925
  registerUI()
7832
7926
  ], Text);
7833
7927
 
7834
- const { toBounds: toBounds$1 } = PathBounds;
7835
7928
  let Path = class Path extends UI {
7836
7929
  get __tag() { return 'Path'; }
7837
7930
  constructor(data) {
7838
7931
  super(data);
7839
- }
7840
- __updateBoxBounds() {
7841
- toBounds$1(this.__.path, this.__layout.boxBounds);
7932
+ this.__.__pathInputed = 2;
7842
7933
  }
7843
7934
  };
7844
7935
  __decorate([
7845
7936
  dataProcessor(PathData)
7846
7937
  ], Path.prototype, "__", void 0);
7847
- __decorate([
7848
- pathType()
7849
- ], Path.prototype, "path", void 0);
7850
- __decorate([
7851
- pathType()
7852
- ], Path.prototype, "windingRule", void 0);
7853
7938
  __decorate([
7854
7939
  affectStrokeBoundsType('center')
7855
7940
  ], Path.prototype, "strokeAlign", void 0);
@@ -7865,12 +7950,12 @@ let Pen = class Pen extends Group {
7865
7950
  setStyle(data) {
7866
7951
  const path = this.pathElement = new Path(data);
7867
7952
  this.pathStyle = data;
7868
- this.path = path.path || (path.path = []);
7953
+ this.__path = path.path || (path.path = []);
7869
7954
  this.add(path);
7870
7955
  return this;
7871
7956
  }
7872
7957
  beginPath() {
7873
- this.path.length = 0;
7958
+ this.__path.length = 0;
7874
7959
  this.paint();
7875
7960
  return this;
7876
7961
  }
@@ -7894,10 +7979,20 @@ let Pen = class Pen extends Group {
7894
7979
  __decorate([
7895
7980
  dataProcessor(PenData)
7896
7981
  ], Pen.prototype, "__", void 0);
7982
+ __decorate([
7983
+ penPathType()
7984
+ ], Pen.prototype, "path", void 0);
7897
7985
  Pen = __decorate([
7898
- useModule(PathCreator, ['beginPath']),
7986
+ useModule(PathCreator, ['beginPath', 'path']),
7899
7987
  registerUI()
7900
7988
  ], Pen);
7989
+ function penPathType() {
7990
+ return (target, key) => {
7991
+ defineKey(target, key, {
7992
+ get() { return this.__path; }
7993
+ });
7994
+ };
7995
+ }
7901
7996
 
7902
7997
  function fillText(ui, canvas) {
7903
7998
  let row;
@@ -8357,9 +8452,9 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
8357
8452
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
8358
8453
  if (attrName === 'fill' && !ui.__.__naturalWidth) {
8359
8454
  const data = ui.__;
8360
- data.__naturalWidth = image.width;
8361
- data.__naturalHeight = image.height;
8362
- if (data.__autoWidth || data.__autoHeight) {
8455
+ data.__naturalWidth = image.width / data.pixelRatio;
8456
+ data.__naturalHeight = image.height / data.pixelRatio;
8457
+ if (data.__autoSide) {
8363
8458
  ui.forceUpdate('width');
8364
8459
  if (ui.__proxyData) {
8365
8460
  ui.setProxyAttr('width', data.width);
@@ -8389,7 +8484,7 @@ function emit(ui, type, data) {
8389
8484
  }
8390
8485
 
8391
8486
  const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
8392
- const { round, abs: abs$1 } = Math;
8487
+ const { ceil, abs: abs$1 } = Math;
8393
8488
  function createPattern(ui, paint, pixelRatio) {
8394
8489
  let { scaleX, scaleY } = ui.__world;
8395
8490
  const id = scaleX + '-' + scaleY;
@@ -8440,7 +8535,7 @@ function createPattern(ui, paint, pixelRatio) {
8440
8535
  }
8441
8536
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
8442
8537
  }
8443
- const canvas = image.getCanvas(width < 1 ? 1 : round(width), height < 1 ? 1 : round(height), opacity);
8538
+ const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, opacity);
8444
8539
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
8445
8540
  paint.style = pattern;
8446
8541
  paint.patternId = id;
@@ -9351,37 +9446,55 @@ const ExportModule = {
9351
9446
  const { leafer } = leaf;
9352
9447
  if (leafer) {
9353
9448
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
9354
- let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
9355
9449
  options = FileHelper.getExportOptions(options);
9356
- const { scale, slice, trim } = options;
9450
+ let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
9451
+ const { worldTransform, isLeafer, isFrame } = leaf;
9452
+ const { slice, trim, onCanvas } = options;
9453
+ const scale = options.scale || 1;
9357
9454
  const pixelRatio = options.pixelRatio || 1;
9358
9455
  const screenshot = options.screenshot || leaf.isApp;
9359
- const fill = options.fill === undefined ? ((leaf.isLeafer && screenshot) ? leaf.fill : '') : options.fill;
9456
+ const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : undefined) : options.fill;
9360
9457
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
9361
9458
  if (screenshot) {
9362
- renderBounds = screenshot === true ? (leaf.isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
9459
+ renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
9363
9460
  }
9364
9461
  else {
9365
- const { localTransform, __world: world } = leaf;
9366
- matrix.set(world).divide(localTransform).invert();
9367
- scaleX = 1 / (world.scaleX / leaf.scaleX);
9368
- scaleY = 1 / (world.scaleY / leaf.scaleY);
9369
- renderBounds = leaf.getBounds('render', 'local');
9370
- }
9371
- let { x, y, width, height } = renderBounds;
9372
- if (scale) {
9373
- matrix.scale(scale);
9374
- width *= scale, height *= scale;
9375
- scaleX *= scale, scaleY *= scale;
9462
+ const location = options.location || ((isLeafer || isFrame) ? 'inner' : 'local');
9463
+ scaleX = worldTransform.scaleX;
9464
+ scaleY = worldTransform.scaleY;
9465
+ switch (location) {
9466
+ case 'inner':
9467
+ matrix.set(worldTransform).invert();
9468
+ break;
9469
+ case 'local':
9470
+ matrix.set(worldTransform).divide(leaf.localTransform).invert();
9471
+ scaleX /= leaf.scaleX;
9472
+ scaleY /= leaf.scaleY;
9473
+ break;
9474
+ case 'world':
9475
+ scaleX = 1;
9476
+ scaleY = 1;
9477
+ break;
9478
+ }
9479
+ renderBounds = leaf.getBounds('render', location);
9376
9480
  }
9377
- let canvas = Creator.canvas({ width: Math.ceil(width), height: Math.ceil(height), pixelRatio });
9378
- const renderOptions = { matrix: matrix.translate(-x, -y).withScale(scaleX, scaleY) };
9481
+ const { x, y, width, height } = new Bounds(renderBounds).scale(scale).ceil();
9482
+ let canvas = Creator.canvas({ width, height, pixelRatio });
9483
+ const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
9379
9484
  if (slice) {
9380
9485
  leaf = leafer;
9381
9486
  renderOptions.bounds = canvas.bounds;
9382
9487
  }
9383
9488
  canvas.save();
9384
- leaf.__render(canvas, renderOptions);
9489
+ if (isFrame && fill !== undefined) {
9490
+ const oldFill = leaf.get('fill');
9491
+ leaf.fill = '';
9492
+ leaf.__render(canvas, renderOptions);
9493
+ leaf.fill = oldFill;
9494
+ }
9495
+ else {
9496
+ leaf.__render(canvas, renderOptions);
9497
+ }
9385
9498
  canvas.restore();
9386
9499
  if (trim) {
9387
9500
  trimBounds = getTrimBounds(canvas);
@@ -9392,6 +9505,8 @@ const ExportModule = {
9392
9505
  }
9393
9506
  if (needFill)
9394
9507
  canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
9508
+ if (onCanvas)
9509
+ onCanvas(canvas);
9395
9510
  const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
9396
9511
  over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
9397
9512
  }));
@@ -9421,4 +9536,4 @@ Object.assign(Export, ExportModule);
9421
9536
 
9422
9537
  useCanvas();
9423
9538
 
9424
- export { AnimateEvent, Answer, AroundHelper, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, 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, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Run, Star, StarData, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, 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 };
9539
+ export { AnimateEvent, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, 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, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Run, Star, StarData, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, 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 };