leafer-draw 1.9.4 → 1.9.5

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.
@@ -136,6 +136,9 @@ class LeafData {
136
136
  const {path: path} = this;
137
137
  return path && path.length === 6 && path[0] === 1;
138
138
  }
139
+ get __usePathBox() {
140
+ return this.__pathInputed;
141
+ }
139
142
  get __blendMode() {
140
143
  if (this.eraser && this.eraser !== "path") return "destination-out";
141
144
  const {blendMode: blendMode} = this;
@@ -1134,13 +1137,13 @@ const AlignHelper = {
1134
1137
  }
1135
1138
  };
1136
1139
 
1137
- const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3} = TwoPointBoundsHelper;
1140
+ const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
1138
1141
 
1139
1142
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1140
1143
 
1141
1144
  const {float: float, fourNumber: fourNumber} = MathHelper;
1142
1145
 
1143
- const {floor: floor$2, ceil: ceil$1} = Math;
1146
+ const {floor: floor$2, ceil: ceil$2} = Math;
1144
1147
 
1145
1148
  let right$1, bottom$1, boundsRight, boundsBottom;
1146
1149
 
@@ -1269,7 +1272,7 @@ const BoundsHelper = {
1269
1272
  point.x = t.x;
1270
1273
  toOuterPoint$2(matrix, point, toPoint$4);
1271
1274
  addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
1272
- toBounds$3(tempPointBounds$1, to);
1275
+ toBounds$2(tempPointBounds$1, to);
1273
1276
  }
1274
1277
  },
1275
1278
  toInnerOf(t, matrix, to) {
@@ -1307,8 +1310,8 @@ const BoundsHelper = {
1307
1310
  const {x: x, y: y} = t;
1308
1311
  t.x = floor$2(t.x);
1309
1312
  t.y = floor$2(t.y);
1310
- t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
1311
- t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
1313
+ t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1314
+ t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
1312
1315
  },
1313
1316
  unsign(t) {
1314
1317
  if (t.width < 0) {
@@ -1368,7 +1371,7 @@ const BoundsHelper = {
1368
1371
  },
1369
1372
  setPoints(t, points) {
1370
1373
  points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
1371
- toBounds$3(tempPointBounds$1, t);
1374
+ toBounds$2(tempPointBounds$1, t);
1372
1375
  },
1373
1376
  setPoint(t, point) {
1374
1377
  B.set(t, point.x, point.y);
@@ -2221,15 +2224,15 @@ class LeaferCanvasBase extends Canvas$1 {
2221
2224
  DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2222
2225
  canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2223
2226
  this.bounds = new Bounds(0, 0, this.width, this.height);
2224
- if (this.context && !this.unreal) {
2225
- this.updateViewSize();
2226
- this.smooth = this.config.smooth;
2227
- }
2227
+ this.updateViewSize();
2228
2228
  this.updateClientBounds();
2229
- if (this.context && !this.unreal && takeCanvas) {
2230
- this.clearWorld(takeCanvas.bounds);
2231
- this.copyWorld(takeCanvas);
2232
- takeCanvas.recycle();
2229
+ if (this.context) {
2230
+ this.smooth = this.config.smooth;
2231
+ if (!this.unreal && takeCanvas) {
2232
+ this.clearWorld(takeCanvas.bounds);
2233
+ this.copyWorld(takeCanvas);
2234
+ takeCanvas.recycle();
2235
+ }
2233
2236
  }
2234
2237
  }
2235
2238
  updateViewSize() {}
@@ -2543,7 +2546,7 @@ const RectHelper = {
2543
2546
  }
2544
2547
  };
2545
2548
 
2546
- const {sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2549
+ const {sin: sin$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil$1, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2547
2550
 
2548
2551
  const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
2549
2552
 
@@ -2614,9 +2617,11 @@ const BezierHelper = {
2614
2617
  const CBy = toY - y1;
2615
2618
  let startRadian = atan2$1(BAy, BAx);
2616
2619
  let endRadian = atan2$1(CBy, CBx);
2620
+ const lenBA = hypot(BAx, BAy);
2621
+ const lenCB = hypot(CBx, CBy);
2617
2622
  let totalRadian = endRadian - startRadian;
2618
2623
  if (totalRadian < 0) totalRadian += PI2;
2619
- if (totalRadian === PI$2 || abs$2(BAx + BAy) < 1e-12 || abs$2(CBx + CBy) < 1e-12) {
2624
+ if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$2(totalRadian - PI$2) < 1e-12) {
2620
2625
  if (data) data.push(L$6, x1, y1);
2621
2626
  if (setPointBounds) {
2622
2627
  setPoint$1(setPointBounds, fromX, fromY);
@@ -2649,7 +2654,7 @@ const BezierHelper = {
2649
2654
  let totalRadian = endRadian - startRadian;
2650
2655
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2651
2656
  if (anticlockwise) totalRadian -= PI2;
2652
- const parts = ceil(abs$2(totalRadian / PI_2));
2657
+ const parts = ceil$1(abs$2(totalRadian / PI_2));
2653
2658
  const partRadian = totalRadian / parts;
2654
2659
  const partRadian4Sin = sin$3(partRadian / 4);
2655
2660
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -3208,11 +3213,7 @@ class PathCreator {
3208
3213
  this.set(path);
3209
3214
  }
3210
3215
  set(path) {
3211
- if (path) {
3212
- this.__path = isString(path) ? PathHelper.parse(path) : path;
3213
- } else {
3214
- this.__path = [];
3215
- }
3216
+ this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
3216
3217
  return this;
3217
3218
  }
3218
3219
  beginPath() {
@@ -3380,7 +3381,7 @@ const {M: M$1, L: L$2, C: C, Q: Q, Z: Z$1, N: N, D: D$1, X: X, G: G, F: F$1, O:
3380
3381
 
3381
3382
  const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
3382
3383
 
3383
- const {addPointBounds: addPointBounds, copy: copy$6, addPoint: addPoint, setPoint: setPoint, addBounds: addBounds, toBounds: toBounds$2} = TwoPointBoundsHelper;
3384
+ const {addPointBounds: addPointBounds, copy: copy$6, addPoint: addPoint, setPoint: setPoint, addBounds: addBounds, toBounds: toBounds$1} = TwoPointBoundsHelper;
3384
3385
 
3385
3386
  const debug$a = Debug.get("PathBounds");
3386
3387
 
@@ -3395,7 +3396,7 @@ const setEndPoint = {};
3395
3396
  const PathBounds = {
3396
3397
  toBounds(data, setBounds) {
3397
3398
  PathBounds.toTwoPointBounds(data, setPointBounds);
3398
- toBounds$2(setPointBounds, setBounds);
3399
+ toBounds$1(setPointBounds, setBounds);
3399
3400
  },
3400
3401
  toTwoPointBounds(data, setPointBounds) {
3401
3402
  if (!data || !data.length) return setPoint(setPointBounds, 0, 0);
@@ -3582,14 +3583,18 @@ const PathCorner = {
3582
3583
  }
3583
3584
  };
3584
3585
 
3585
- PathHelper.creator = new PathCreator;
3586
+ function path(path) {
3587
+ return new PathCreator(path);
3588
+ }
3589
+
3590
+ const pen = path();
3591
+
3592
+ PathHelper.creator = path();
3586
3593
 
3587
3594
  PathHelper.parse = PathConvert.parse;
3588
3595
 
3589
3596
  PathHelper.convertToCanvasData = PathConvert.toCanvasData;
3590
3597
 
3591
- const pen = new PathCreator;
3592
-
3593
3598
  const {drawRoundRect: drawRoundRect} = RectHelper;
3594
3599
 
3595
3600
  function roundRect(drawer) {
@@ -3954,7 +3959,7 @@ const ImageManager = {
3954
3959
  return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
3955
3960
  },
3956
3961
  isFormat(format, config) {
3957
- if (config.format === format) return true;
3962
+ if (config.format) return config.format === format;
3958
3963
  const {url: url} = config;
3959
3964
  if (url.startsWith("data:")) {
3960
3965
  if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
@@ -4048,7 +4053,7 @@ class LeaferImage {
4048
4053
  getFull(_filters) {
4049
4054
  return this.view;
4050
4055
  }
4051
- getCanvas(width, height, opacity, _filters, xGap, yGap) {
4056
+ getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
4052
4057
  width || (width = this.width);
4053
4058
  height || (height = this.height);
4054
4059
  if (this.cache) {
@@ -4064,6 +4069,7 @@ class LeaferImage {
4064
4069
  const canvas = Platform.origin.createCanvas(max$1(floor$1(width + (xGap || 0)), 1), max$1(floor$1(height + (yGap || 0)), 1));
4065
4070
  const ctx = canvas.getContext("2d");
4066
4071
  if (opacity) ctx.globalAlpha = opacity;
4072
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
4067
4073
  ctx.drawImage(this.view, 0, 0, width, height);
4068
4074
  this.cache = this.use > 1 ? {
4069
4075
  data: canvas,
@@ -4715,8 +4721,9 @@ const L = LeafHelper;
4715
4721
 
4716
4722
  const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L;
4717
4723
 
4718
- function getTempLocal(t, world) {
4719
- return t.parent ? PointHelper.tempToInnerOf(world, t.parent.scrollWorldTransform) : world;
4724
+ function getTempLocal(t, worldPoint) {
4725
+ t.updateLayout();
4726
+ return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
4720
4727
  }
4721
4728
 
4722
4729
  const LeafBoundsHelper = {
@@ -5734,7 +5741,7 @@ const {updateBounds: updateBounds$1} = BranchHelper;
5734
5741
 
5735
5742
  const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$3} = BoundsHelper;
5736
5743
 
5737
- const {toBounds: toBounds$1} = PathBounds;
5744
+ const {toBounds: toBounds} = PathBounds;
5738
5745
 
5739
5746
  const LeafBounds = {
5740
5747
  __updateWorldBounds() {
@@ -5806,8 +5813,8 @@ const LeafBounds = {
5806
5813
  __updateBoxBounds(_secondLayout, _bounds) {
5807
5814
  const b = this.__layout.boxBounds;
5808
5815
  const data = this.__;
5809
- if (data.__pathInputed) {
5810
- toBounds$1(data.path, b);
5816
+ if (data.__usePathBox) {
5817
+ toBounds(data.path, b);
5811
5818
  } else {
5812
5819
  b.x = 0;
5813
5820
  b.y = 0;
@@ -6742,7 +6749,7 @@ class LeafLevelList {
6742
6749
  }
6743
6750
  }
6744
6751
 
6745
- const version = "1.9.4";
6752
+ const version = "1.9.5";
6746
6753
 
6747
6754
  const debug$4 = Debug.get("LeaferCanvas");
6748
6755
 
@@ -6833,10 +6840,22 @@ class LeaferCanvas extends LeaferCanvasBase {
6833
6840
  updateViewSize() {
6834
6841
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
6835
6842
  const {style: style} = this.view;
6836
- style.width = width + "px";
6837
- style.height = height + "px";
6838
- this.view.width = Math.ceil(width * pixelRatio);
6839
- this.view.height = Math.ceil(height * pixelRatio);
6843
+ if (this.unreal) {
6844
+ const {config: config, autoWidthStr: autoWidthStr, autoHeightStr: autoHeightStr} = this;
6845
+ if (config.width) {
6846
+ if (isUndefined(autoWidthStr)) this.autoWidthStr = style.width || "";
6847
+ style.width = config.width + "px";
6848
+ } else if (!isUndefined(autoWidthStr)) style.width = autoWidthStr;
6849
+ if (config.height) {
6850
+ if (isUndefined(autoHeightStr)) this.autoHeightStr = style.height || "";
6851
+ style.height = config.height + "px";
6852
+ } else if (!isUndefined(autoHeightStr)) style.height = autoHeightStr;
6853
+ } else {
6854
+ style.width = width + "px";
6855
+ style.height = height + "px";
6856
+ this.view.width = Math.ceil(width * pixelRatio);
6857
+ this.view.height = Math.ceil(height * pixelRatio);
6858
+ }
6840
6859
  }
6841
6860
  updateClientBounds() {
6842
6861
  if (this.view.parentElement) this.clientBounds = this.view.getBoundingClientRect();
@@ -6845,6 +6864,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6845
6864
  this.resizeListener = listener;
6846
6865
  if (autoBounds) {
6847
6866
  this.autoBounds = autoBounds;
6867
+ if (this.resizeObserver) return;
6848
6868
  try {
6849
6869
  this.resizeObserver = new ResizeObserver(entries => {
6850
6870
  this.updateClientBounds();
@@ -6861,18 +6881,10 @@ class LeaferCanvas extends LeaferCanvasBase {
6861
6881
  } catch (_a) {
6862
6882
  this.imitateResizeObserver();
6863
6883
  }
6884
+ this.stopListenPixelRatio();
6864
6885
  } else {
6865
- window.addEventListener("resize", this.windowListener = () => {
6866
- const pixelRatio = Platform.devicePixelRatio;
6867
- if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
6868
- const {width: width, height: height} = this;
6869
- this.emitResize({
6870
- width: width,
6871
- height: height,
6872
- pixelRatio: pixelRatio
6873
- });
6874
- }
6875
- });
6886
+ this.listenPixelRatio();
6887
+ if (this.unreal) this.updateViewSize();
6876
6888
  }
6877
6889
  }
6878
6890
  imitateResizeObserver() {
@@ -6881,6 +6893,25 @@ class LeaferCanvas extends LeaferCanvasBase {
6881
6893
  Platform.requestRender(this.imitateResizeObserver.bind(this));
6882
6894
  }
6883
6895
  }
6896
+ listenPixelRatio() {
6897
+ if (!this.windowListener) window.addEventListener("resize", this.windowListener = () => {
6898
+ const pixelRatio = Platform.devicePixelRatio;
6899
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
6900
+ const {width: width, height: height} = this;
6901
+ this.emitResize({
6902
+ width: width,
6903
+ height: height,
6904
+ pixelRatio: pixelRatio
6905
+ });
6906
+ }
6907
+ });
6908
+ }
6909
+ stopListenPixelRatio() {
6910
+ if (this.windowListener) {
6911
+ window.removeEventListener("resize", this.windowListener);
6912
+ this.windowListener = null;
6913
+ }
6914
+ }
6884
6915
  checkAutoBounds(parentSize) {
6885
6916
  const view = this.view;
6886
6917
  const {x: x, y: y, width: width, height: height} = this.autoBounds.getBoundsFrom(parentSize);
@@ -6918,10 +6949,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6918
6949
  destroy() {
6919
6950
  if (this.view) {
6920
6951
  this.stopAutoLayout();
6921
- if (this.windowListener) {
6922
- window.removeEventListener("resize", this.windowListener);
6923
- this.windowListener = null;
6924
- }
6952
+ this.stopListenPixelRatio();
6925
6953
  if (!this.unreal) {
6926
6954
  const view = this.view;
6927
6955
  if (view.parentElement) view.remove();
@@ -7350,7 +7378,7 @@ class Renderer {
7350
7378
  this.times = 0;
7351
7379
  this.config = {
7352
7380
  usePartRender: true,
7353
- maxFPS: 60
7381
+ maxFPS: 120
7354
7382
  };
7355
7383
  this.target = target;
7356
7384
  this.canvas = canvas;
@@ -7505,11 +7533,15 @@ class Renderer {
7505
7533
  if (this.requestTime || !target) return;
7506
7534
  if (target.parentApp) return target.parentApp.requestRender(false);
7507
7535
  const requestTime = this.requestTime = Date.now();
7508
- Platform.requestRender(() => {
7509
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7536
+ const render = () => {
7537
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7538
+ const {maxFPS: maxFPS} = this.config;
7539
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7540
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7510
7541
  this.requestTime = 0;
7511
7542
  this.checkRender();
7512
- });
7543
+ };
7544
+ Platform.requestRender(render);
7513
7545
  }
7514
7546
  __onResize(e) {
7515
7547
  if (this.canvas.unreal) return;
@@ -7552,7 +7584,8 @@ class Renderer {
7552
7584
  if (this.target) {
7553
7585
  this.stop();
7554
7586
  this.__removeListenEvents();
7555
- this.target = this.canvas = this.config = null;
7587
+ this.config = {};
7588
+ this.target = this.canvas = null;
7556
7589
  }
7557
7590
  }
7558
7591
  }
@@ -7860,7 +7893,11 @@ class LeaferData extends GroupData {
7860
7893
 
7861
7894
  class FrameData extends BoxData {}
7862
7895
 
7863
- class LineData extends UIData {}
7896
+ class LineData extends UIData {
7897
+ get __usePathBox() {
7898
+ return this.points || this.__pathInputed;
7899
+ }
7900
+ }
7864
7901
 
7865
7902
  class RectData extends UIData {
7866
7903
  get __boxStroke() {
@@ -7874,7 +7911,7 @@ class EllipseData extends UIData {
7874
7911
  }
7875
7912
  }
7876
7913
 
7877
- class PolygonData extends UIData {}
7914
+ class PolygonData extends LineData {}
7878
7915
 
7879
7916
  class StarData extends UIData {}
7880
7917
 
@@ -8184,20 +8221,9 @@ let UI = UI_1 = class UI extends Leaf {
8184
8221
  if (!path) this.__drawPathByBox(pen);
8185
8222
  return pen;
8186
8223
  }
8187
- constructor(data) {
8188
- super(data);
8189
- }
8190
8224
  reset(_data) {}
8191
- set(data, transition) {
8192
- if (data) {
8193
- if (transition) {
8194
- if (transition === "temp") {
8195
- this.lockNormalStyle = true;
8196
- Object.assign(this, data);
8197
- this.lockNormalStyle = false;
8198
- } else this.animate(data, transition);
8199
- } else Object.assign(this, data);
8200
- }
8225
+ set(data, _transition) {
8226
+ if (data) Object.assign(this, data);
8201
8227
  }
8202
8228
  get(name) {
8203
8229
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -8243,7 +8269,7 @@ let UI = UI_1 = class UI extends Leaf {
8243
8269
  const data = this.__;
8244
8270
  if (data.path) {
8245
8271
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8246
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
8272
+ if (data.__useArrow) PathArrow.addArrows(this);
8247
8273
  } else data.__pathForRender && (data.__pathForRender = undefined);
8248
8274
  }
8249
8275
  __drawRenderPath(canvas) {
@@ -8267,7 +8293,8 @@ let UI = UI_1 = class UI extends Leaf {
8267
8293
  drawImagePlaceholder(canvas, _image) {
8268
8294
  Paint.fill(this.__.placeholderColor, this, canvas);
8269
8295
  }
8270
- animate(_keyframe, _options, _type, _isTemp) {
8296
+ animate(keyframe, _options, _type, _isTemp) {
8297
+ this.set(keyframe);
8271
8298
  return Plugin.need("animate");
8272
8299
  }
8273
8300
  killAnimate(_type, _nextStyle) {}
@@ -8456,9 +8483,6 @@ let Group = class Group extends UI {
8456
8483
  get isBranch() {
8457
8484
  return true;
8458
8485
  }
8459
- constructor(data) {
8460
- super(data);
8461
- }
8462
8486
  reset(data) {
8463
8487
  this.__setBranch();
8464
8488
  super.reset(data);
@@ -8583,7 +8607,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8583
8607
  const canvas = this.canvas = Creator.canvas(config);
8584
8608
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8585
8609
  if (this.isApp) this.__setApp();
8586
- this.__checkAutoLayout(config, parentApp);
8610
+ this.__checkAutoLayout();
8587
8611
  this.view = canvas.view;
8588
8612
  if (!parentApp) {
8589
8613
  this.selector = Creator.selector(this);
@@ -8682,7 +8706,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8682
8706
  this.leafer = leafer;
8683
8707
  this.__level = 1;
8684
8708
  }
8685
- __checkAutoLayout(config, parentApp) {
8709
+ __checkAutoLayout() {
8710
+ const {config: config, parentApp: parentApp} = this;
8686
8711
  if (!parentApp) {
8687
8712
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8688
8713
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8708,9 +8733,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8708
8733
  return super.__getAttr(attrName);
8709
8734
  }
8710
8735
  __changeCanvasSize(attrName, newValue) {
8711
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8712
- data[attrName] = this.config[attrName] = newValue;
8713
- if (newValue) this.canvas.stopAutoLayout();
8736
+ const {config: config, canvas: canvas} = this;
8737
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8738
+ data[attrName] = config[attrName] = newValue;
8739
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8714
8740
  this.__doResize(data);
8715
8741
  }
8716
8742
  __changeFill(newValue) {
@@ -8857,9 +8883,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8857
8883
  if (!this.parent) {
8858
8884
  if (this.selector) this.selector.destroy();
8859
8885
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
8860
- this.canvasManager.destroy();
8886
+ if (this.canvasManager) this.canvasManager.destroy();
8861
8887
  }
8862
- this.canvas.destroy();
8888
+ if (this.canvas) this.canvas.destroy();
8863
8889
  this.config.view = this.view = this.parentApp = null;
8864
8890
  if (this.userConfig) this.userConfig.view = null;
8865
8891
  super.destroy();
@@ -8887,9 +8913,6 @@ let Rect = class Rect extends UI {
8887
8913
  get __tag() {
8888
8914
  return "Rect";
8889
8915
  }
8890
- constructor(data) {
8891
- super(data);
8892
- }
8893
8916
  };
8894
8917
 
8895
8918
  __decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
@@ -9021,9 +9044,6 @@ let Frame = class Frame extends Box {
9021
9044
  get isFrame() {
9022
9045
  return true;
9023
9046
  }
9024
- constructor(data) {
9025
- super(data);
9026
- }
9027
9047
  };
9028
9048
 
9029
9049
  __decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
@@ -9040,9 +9060,6 @@ let Ellipse = class Ellipse extends UI {
9040
9060
  get __tag() {
9041
9061
  return "Ellipse";
9042
9062
  }
9043
- constructor(data) {
9044
- super(data);
9045
- }
9046
9063
  __updatePath() {
9047
9064
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9048
9065
  const rx = width / 2, ry = height / 2;
@@ -9086,8 +9103,6 @@ const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathComma
9086
9103
 
9087
9104
  const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
9088
9105
 
9089
- const {toBounds: toBounds} = PathBounds;
9090
-
9091
9106
  let Line = class Line extends UI {
9092
9107
  get __tag() {
9093
9108
  return "Line";
@@ -9104,31 +9119,16 @@ let Line = class Line extends UI {
9104
9119
  this.rotation = getAngle$1(defaultPoint, value);
9105
9120
  if (this.height) this.height = 0;
9106
9121
  }
9107
- constructor(data) {
9108
- super(data);
9109
- }
9110
9122
  __updatePath() {
9111
9123
  const data = this.__;
9112
9124
  const path = data.path = [];
9113
9125
  if (data.points) {
9114
- drawPoints$1(path, data.points, false, data.closed);
9126
+ drawPoints$1(path, data.points, data.curve, data.closed);
9115
9127
  } else {
9116
9128
  moveTo$2(path, 0, 0);
9117
9129
  lineTo$2(path, this.width, 0);
9118
9130
  }
9119
9131
  }
9120
- __updateRenderPath() {
9121
- const data = this.__;
9122
- if (!this.pathInputed && data.points && data.curve) {
9123
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
9124
- if (data.__useArrow) PathArrow.addArrows(this, false);
9125
- } else super.__updateRenderPath();
9126
- }
9127
- __updateBoxBounds() {
9128
- if (this.points) {
9129
- toBounds(this.__.__pathForRender, this.__layout.boxBounds);
9130
- } else super.__updateBoxBounds();
9131
- }
9132
9132
  };
9133
9133
 
9134
9134
  __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
@@ -9155,15 +9155,13 @@ let Polygon = class Polygon extends UI {
9155
9155
  get __tag() {
9156
9156
  return "Polygon";
9157
9157
  }
9158
- constructor(data) {
9159
- super(data);
9160
- }
9161
9158
  __updatePath() {
9162
- const path = this.__.path = [];
9163
- if (this.__.points) {
9164
- drawPoints(path, this.__.points, false, true);
9159
+ const data = this.__;
9160
+ const path = data.path = [];
9161
+ if (data.points) {
9162
+ drawPoints(path, data.points, data.curve, true);
9165
9163
  } else {
9166
- const {width: width, height: height, sides: sides} = this.__;
9164
+ const {width: width, height: height, sides: sides} = data;
9167
9165
  const rx = width / 2, ry = height / 2;
9168
9166
  moveTo$1(path, rx, 0);
9169
9167
  for (let i = 1; i < sides; i++) {
@@ -9198,9 +9196,6 @@ let Star = class Star extends UI {
9198
9196
  get __tag() {
9199
9197
  return "Star";
9200
9198
  }
9201
- constructor(data) {
9202
- super(data);
9203
- }
9204
9199
  __updatePath() {
9205
9200
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9206
9201
  const rx = width / 2, ry = height / 2;
@@ -9233,9 +9228,6 @@ let Image$1 = class Image extends Rect {
9233
9228
  const {fill: fill} = this.__;
9234
9229
  return isArray(fill) && fill[0].image;
9235
9230
  }
9236
- constructor(data) {
9237
- super(data);
9238
- }
9239
9231
  };
9240
9232
 
9241
9233
  __decorate([ dataProcessor(ImageData) ], Image$1.prototype, "__", void 0);
@@ -9335,9 +9327,6 @@ let Text = class Text extends UI {
9335
9327
  this.updateLayout();
9336
9328
  return this.__.__textDrawData;
9337
9329
  }
9338
- constructor(data) {
9339
- super(data);
9340
- }
9341
9330
  __updateTextDrawData() {
9342
9331
  const data = this.__;
9343
9332
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -9470,9 +9459,6 @@ let Path = class Path extends UI {
9470
9459
  get __tag() {
9471
9460
  return "Path";
9472
9461
  }
9473
- constructor(data) {
9474
- super(data);
9475
- }
9476
9462
  };
9477
9463
 
9478
9464
  __decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
@@ -9485,9 +9471,6 @@ let Pen = class Pen extends Group {
9485
9471
  get __tag() {
9486
9472
  return "Pen";
9487
9473
  }
9488
- constructor(data) {
9489
- super(data);
9490
- }
9491
9474
  setStyle(data) {
9492
9475
  const path = this.pathElement = new Path(data);
9493
9476
  this.pathStyle = data;
@@ -10183,7 +10166,7 @@ function ignoreRender(ui, value) {
10183
10166
 
10184
10167
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
10185
10168
 
10186
- const {floor: floor, max: max, abs: abs} = Math;
10169
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
10187
10170
 
10188
10171
  function createPattern(ui, paint, pixelRatio) {
10189
10172
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -10193,8 +10176,6 @@ function createPattern(ui, paint, pixelRatio) {
10193
10176
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
10194
10177
  scaleX *= pixelRatio;
10195
10178
  scaleY *= pixelRatio;
10196
- const xGap = gap && gap.x * scaleX;
10197
- const yGap = gap && gap.y * scaleY;
10198
10179
  if (sx) {
10199
10180
  sx = abs(sx);
10200
10181
  sy = abs(sy);
@@ -10211,7 +10192,10 @@ function createPattern(ui, paint, pixelRatio) {
10211
10192
  if (size > Platform.image.maxCacheSize) return false;
10212
10193
  }
10213
10194
  let maxSize = Platform.image.maxPatternSize;
10214
- if (!image.isSVG) {
10195
+ if (image.isSVG) {
10196
+ const ws = width / image.width;
10197
+ if (ws > 1) imageScale = ws / ceil(ws);
10198
+ } else {
10215
10199
  const imageSize = image.width * image.height;
10216
10200
  if (maxSize > imageSize) maxSize = imageSize;
10217
10201
  }
@@ -10226,18 +10210,20 @@ function createPattern(ui, paint, pixelRatio) {
10226
10210
  scaleX /= sx;
10227
10211
  scaleY /= sy;
10228
10212
  }
10213
+ const xGap = gap && gap.x * scaleX;
10214
+ const yGap = gap && gap.y * scaleY;
10229
10215
  if (transform || scaleX !== 1 || scaleY !== 1) {
10216
+ const canvasWidth = width + (xGap || 0);
10217
+ const canvasHeight = height + (yGap || 0);
10218
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
10219
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
10230
10220
  if (!imageMatrix) {
10231
10221
  imageMatrix = get$1();
10232
10222
  if (transform) copy$1(imageMatrix, transform);
10233
10223
  }
10234
10224
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
10235
10225
  }
10236
- if (imageMatrix) {
10237
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
10238
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
10239
- }
10240
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
10226
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
10241
10227
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
10242
10228
  paint.style = pattern;
10243
10229
  paint.patternId = id;
@@ -11185,4 +11171,4 @@ Object.assign(Effect, EffectModule);
11185
11171
 
11186
11172
  useCanvas();
11187
11173
 
11188
- export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, Image$1 as 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, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
11174
+ export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, Image$1 as 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, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };