leafer-draw 1.9.4 → 1.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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;
@@ -369,7 +372,7 @@ function getMatrixData() {
369
372
 
370
373
  const {sin: sin$5, cos: cos$5, acos: acos, sqrt: sqrt$3} = Math;
371
374
 
372
- const {float: float$1} = MathHelper;
375
+ const {float: float$2} = MathHelper;
373
376
 
374
377
  const tempPoint$3 = {};
375
378
 
@@ -611,12 +614,12 @@ const MatrixHelper = {
611
614
  const cosR = c / scaleY;
612
615
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
613
616
  }
614
- const cosR = float$1(cos$5(rotation));
617
+ const cosR = float$2(cos$5(rotation));
615
618
  const sinR = sin$5(rotation);
616
- scaleX = float$1(scaleX), scaleY = float$1(scaleY);
617
- skewX = cosR ? float$1((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
618
- skewY = cosR ? float$1((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
619
- rotation = float$1(rotation / OneRadian);
619
+ scaleX = float$2(scaleX), scaleY = float$2(scaleY);
620
+ skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
621
+ skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
622
+ rotation = float$2(rotation / OneRadian);
620
623
  } else {
621
624
  scaleX = a;
622
625
  scaleY = d;
@@ -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
- const {float: float, fourNumber: fourNumber} = MathHelper;
1144
+ const {float: float$1, 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) {
@@ -1321,10 +1324,10 @@ const BoundsHelper = {
1321
1324
  }
1322
1325
  },
1323
1326
  float(t, maxLength) {
1324
- t.x = float(t.x, maxLength);
1325
- t.y = float(t.y, maxLength);
1326
- t.width = float(t.width, maxLength);
1327
- t.height = float(t.height, maxLength);
1327
+ t.x = float$1(t.x, maxLength);
1328
+ t.y = float$1(t.y, maxLength);
1329
+ t.width = float$1(t.width, maxLength);
1330
+ t.height = float$1(t.height, maxLength);
1328
1331
  },
1329
1332
  add(t, bounds, isPoint) {
1330
1333
  right$1 = t.x + t.width;
@@ -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 = {
@@ -5456,6 +5463,8 @@ LeaferEvent.RESTART = "leafer.restart";
5456
5463
 
5457
5464
  LeaferEvent.END = "leafer.end";
5458
5465
 
5466
+ LeaferEvent.UPDATE_MODE = "leafer.update_mode";
5467
+
5459
5468
  LeaferEvent.TRANSFORM = "leafer.transform";
5460
5469
 
5461
5470
  LeaferEvent.MOVE = "leafer.move";
@@ -5734,7 +5743,7 @@ const {updateBounds: updateBounds$1} = BranchHelper;
5734
5743
 
5735
5744
  const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$3} = BoundsHelper;
5736
5745
 
5737
- const {toBounds: toBounds$1} = PathBounds;
5746
+ const {toBounds: toBounds} = PathBounds;
5738
5747
 
5739
5748
  const LeafBounds = {
5740
5749
  __updateWorldBounds() {
@@ -5806,8 +5815,8 @@ const LeafBounds = {
5806
5815
  __updateBoxBounds(_secondLayout, _bounds) {
5807
5816
  const b = this.__layout.boxBounds;
5808
5817
  const data = this.__;
5809
- if (data.__pathInputed) {
5810
- toBounds$1(data.path, b);
5818
+ if (data.__usePathBox) {
5819
+ toBounds(data.path, b);
5811
5820
  } else {
5812
5821
  b.x = 0;
5813
5822
  b.y = 0;
@@ -6742,7 +6751,7 @@ class LeafLevelList {
6742
6751
  }
6743
6752
  }
6744
6753
 
6745
- const version = "1.9.4";
6754
+ const version = "1.9.6";
6746
6755
 
6747
6756
  const debug$4 = Debug.get("LeaferCanvas");
6748
6757
 
@@ -6833,10 +6842,22 @@ class LeaferCanvas extends LeaferCanvasBase {
6833
6842
  updateViewSize() {
6834
6843
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
6835
6844
  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);
6845
+ if (this.unreal) {
6846
+ const {config: config, autoWidthStr: autoWidthStr, autoHeightStr: autoHeightStr} = this;
6847
+ if (config.width) {
6848
+ if (isUndefined(autoWidthStr)) this.autoWidthStr = style.width || "";
6849
+ style.width = config.width + "px";
6850
+ } else if (!isUndefined(autoWidthStr)) style.width = autoWidthStr;
6851
+ if (config.height) {
6852
+ if (isUndefined(autoHeightStr)) this.autoHeightStr = style.height || "";
6853
+ style.height = config.height + "px";
6854
+ } else if (!isUndefined(autoHeightStr)) style.height = autoHeightStr;
6855
+ } else {
6856
+ style.width = width + "px";
6857
+ style.height = height + "px";
6858
+ this.view.width = Math.ceil(width * pixelRatio);
6859
+ this.view.height = Math.ceil(height * pixelRatio);
6860
+ }
6840
6861
  }
6841
6862
  updateClientBounds() {
6842
6863
  if (this.view.parentElement) this.clientBounds = this.view.getBoundingClientRect();
@@ -6845,6 +6866,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6845
6866
  this.resizeListener = listener;
6846
6867
  if (autoBounds) {
6847
6868
  this.autoBounds = autoBounds;
6869
+ if (this.resizeObserver) return;
6848
6870
  try {
6849
6871
  this.resizeObserver = new ResizeObserver(entries => {
6850
6872
  this.updateClientBounds();
@@ -6861,18 +6883,10 @@ class LeaferCanvas extends LeaferCanvasBase {
6861
6883
  } catch (_a) {
6862
6884
  this.imitateResizeObserver();
6863
6885
  }
6886
+ this.stopListenPixelRatio();
6864
6887
  } 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
- });
6888
+ this.listenPixelRatio();
6889
+ if (this.unreal) this.updateViewSize();
6876
6890
  }
6877
6891
  }
6878
6892
  imitateResizeObserver() {
@@ -6881,6 +6895,25 @@ class LeaferCanvas extends LeaferCanvasBase {
6881
6895
  Platform.requestRender(this.imitateResizeObserver.bind(this));
6882
6896
  }
6883
6897
  }
6898
+ listenPixelRatio() {
6899
+ if (!this.windowListener) window.addEventListener("resize", this.windowListener = () => {
6900
+ const pixelRatio = Platform.devicePixelRatio;
6901
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
6902
+ const {width: width, height: height} = this;
6903
+ this.emitResize({
6904
+ width: width,
6905
+ height: height,
6906
+ pixelRatio: pixelRatio
6907
+ });
6908
+ }
6909
+ });
6910
+ }
6911
+ stopListenPixelRatio() {
6912
+ if (this.windowListener) {
6913
+ window.removeEventListener("resize", this.windowListener);
6914
+ this.windowListener = null;
6915
+ }
6916
+ }
6884
6917
  checkAutoBounds(parentSize) {
6885
6918
  const view = this.view;
6886
6919
  const {x: x, y: y, width: width, height: height} = this.autoBounds.getBoundsFrom(parentSize);
@@ -6918,10 +6951,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6918
6951
  destroy() {
6919
6952
  if (this.view) {
6920
6953
  this.stopAutoLayout();
6921
- if (this.windowListener) {
6922
- window.removeEventListener("resize", this.windowListener);
6923
- this.windowListener = null;
6924
- }
6954
+ this.stopListenPixelRatio();
6925
6955
  if (!this.unreal) {
6926
6956
  const view = this.view;
6927
6957
  if (view.parentElement) view.remove();
@@ -7350,7 +7380,7 @@ class Renderer {
7350
7380
  this.times = 0;
7351
7381
  this.config = {
7352
7382
  usePartRender: true,
7353
- maxFPS: 60
7383
+ maxFPS: 120
7354
7384
  };
7355
7385
  this.target = target;
7356
7386
  this.canvas = canvas;
@@ -7505,11 +7535,15 @@ class Renderer {
7505
7535
  if (this.requestTime || !target) return;
7506
7536
  if (target.parentApp) return target.parentApp.requestRender(false);
7507
7537
  const requestTime = this.requestTime = Date.now();
7508
- Platform.requestRender(() => {
7509
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7538
+ const render = () => {
7539
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7540
+ const {maxFPS: maxFPS} = this.config;
7541
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7542
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7510
7543
  this.requestTime = 0;
7511
7544
  this.checkRender();
7512
- });
7545
+ };
7546
+ Platform.requestRender(render);
7513
7547
  }
7514
7548
  __onResize(e) {
7515
7549
  if (this.canvas.unreal) return;
@@ -7552,7 +7586,8 @@ class Renderer {
7552
7586
  if (this.target) {
7553
7587
  this.stop();
7554
7588
  this.__removeListenEvents();
7555
- this.target = this.canvas = this.config = null;
7589
+ this.config = {};
7590
+ this.target = this.canvas = null;
7556
7591
  }
7557
7592
  }
7558
7593
  }
@@ -7860,7 +7895,11 @@ class LeaferData extends GroupData {
7860
7895
 
7861
7896
  class FrameData extends BoxData {}
7862
7897
 
7863
- class LineData extends UIData {}
7898
+ class LineData extends UIData {
7899
+ get __usePathBox() {
7900
+ return this.points || this.__pathInputed;
7901
+ }
7902
+ }
7864
7903
 
7865
7904
  class RectData extends UIData {
7866
7905
  get __boxStroke() {
@@ -7874,7 +7913,7 @@ class EllipseData extends UIData {
7874
7913
  }
7875
7914
  }
7876
7915
 
7877
- class PolygonData extends UIData {}
7916
+ class PolygonData extends LineData {}
7878
7917
 
7879
7918
  class StarData extends UIData {}
7880
7919
 
@@ -7918,8 +7957,6 @@ class TextData extends UIData {
7918
7957
  if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
7919
7958
  box.set(value);
7920
7959
  if (boxLayout.strokeChanged) layout.strokeChange();
7921
- if (boxLayout.renderChanged) layout.renderChange();
7922
- box.__updateChange();
7923
7960
  } else if (box) {
7924
7961
  t.__box = box.parent = null;
7925
7962
  box.destroy();
@@ -7989,7 +8026,7 @@ const UIBounds = {
7989
8026
  __updateRenderSpread() {
7990
8027
  let width = 0;
7991
8028
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7992
- if (shadow) shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
8029
+ if (shadow) width = Effect.getShadowSpread(this, shadow);
7993
8030
  if (blur) width = Math.max(width, blur);
7994
8031
  if (filter) width += Filter.getSpread(filter);
7995
8032
  if (renderSpread) width += renderSpread;
@@ -8002,36 +8039,69 @@ const UIBounds = {
8002
8039
  }
8003
8040
  };
8004
8041
 
8042
+ const {float: float} = MathHelper;
8043
+
8044
+ const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
8045
+
8005
8046
  const DragBoundsHelper = {
8047
+ limitMove(leaf, move) {
8048
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8049
+ if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
8050
+ D.axisMove(leaf, move);
8051
+ },
8052
+ limitScaleOf(leaf, origin, scale) {
8053
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8054
+ if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
8055
+ },
8056
+ axisMove(leaf, move) {
8057
+ const {draggable: draggable} = leaf;
8058
+ if (draggable === "x") move.y = 0;
8059
+ if (draggable === "y") move.x = 0;
8060
+ },
8061
+ getDragBounds(leaf) {
8062
+ const {dragBounds: dragBounds} = leaf;
8063
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
8064
+ },
8065
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
8066
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
8067
+ },
8006
8068
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
8007
8069
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
8008
8070
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
8009
8071
  if (!change) move = Object.assign({}, move);
8010
- const isBiggerWidth = content.width > dragBounds.width;
8011
- const isBiggerHeight = content.height > dragBounds.height;
8012
- if (isBiggerWidth && dragBoundsType !== "outer") {
8072
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
8013
8073
  if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
8014
8074
  } else {
8015
8075
  if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
8016
8076
  }
8017
- if (isBiggerHeight && dragBoundsType !== "outer") {
8077
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
8018
8078
  if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
8019
8079
  } else {
8020
8080
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
8021
8081
  }
8022
- move.x = MathHelper.float(move.x);
8023
- move.y = MathHelper.float(move.y);
8082
+ move.x = float(move.x);
8083
+ move.y = float(move.y);
8024
8084
  return move;
8025
8085
  },
8026
- axisMove(leaf, move) {
8027
- const {draggable: draggable} = leaf;
8028
- if (draggable === "x") move.y = 0;
8029
- if (draggable === "y") move.x = 0;
8030
- },
8031
- limitMove(leaf, move) {
8032
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8033
- if (dragBounds) D.getValidMove(leaf.__localBoxBounds, dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds, dragBoundsType, move, true);
8034
- D.axisMove(leaf, move);
8086
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
8087
+ if (!change) scale = Object.assign({}, scale);
8088
+ let fitScaleX, fitScaleY;
8089
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
8090
+ tempMerge.set(tempContent).add(dragBounds);
8091
+ tempIntersect.set(tempContent).intersect(dragBounds);
8092
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
8093
+ fitScaleX = tempMerge.width / tempContent.width;
8094
+ } else {
8095
+ fitScaleX = tempIntersect.width / tempContent.width;
8096
+ }
8097
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
8098
+ fitScaleY = tempMerge.height / tempContent.height;
8099
+ } else {
8100
+ fitScaleY = tempIntersect.height / tempContent.height;
8101
+ }
8102
+ scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
8103
+ scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
8104
+ return scale;
8035
8105
  }
8036
8106
  };
8037
8107
 
@@ -8049,7 +8119,7 @@ const UIRender = {
8049
8119
  }
8050
8120
  if (data.__useEffect) {
8051
8121
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
8052
- stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
8122
+ stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !Effect.isTransformShadow(shadow[0]) && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
8053
8123
  data.__useEffect = !!(shadow || otherEffect);
8054
8124
  }
8055
8125
  data.__checkSingle();
@@ -8184,20 +8254,9 @@ let UI = UI_1 = class UI extends Leaf {
8184
8254
  if (!path) this.__drawPathByBox(pen);
8185
8255
  return pen;
8186
8256
  }
8187
- constructor(data) {
8188
- super(data);
8189
- }
8190
8257
  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
- }
8258
+ set(data, _transition) {
8259
+ if (data) Object.assign(this, data);
8201
8260
  }
8202
8261
  get(name) {
8203
8262
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -8243,7 +8302,7 @@ let UI = UI_1 = class UI extends Leaf {
8243
8302
  const data = this.__;
8244
8303
  if (data.path) {
8245
8304
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8246
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
8305
+ if (data.__useArrow) PathArrow.addArrows(this);
8247
8306
  } else data.__pathForRender && (data.__pathForRender = undefined);
8248
8307
  }
8249
8308
  __drawRenderPath(canvas) {
@@ -8267,7 +8326,8 @@ let UI = UI_1 = class UI extends Leaf {
8267
8326
  drawImagePlaceholder(canvas, _image) {
8268
8327
  Paint.fill(this.__.placeholderColor, this, canvas);
8269
8328
  }
8270
- animate(_keyframe, _options, _type, _isTemp) {
8329
+ animate(keyframe, _options, _type, _isTemp) {
8330
+ this.set(keyframe);
8271
8331
  return Plugin.need("animate");
8272
8332
  }
8273
8333
  killAnimate(_type, _nextStyle) {}
@@ -8456,9 +8516,6 @@ let Group = class Group extends UI {
8456
8516
  get isBranch() {
8457
8517
  return true;
8458
8518
  }
8459
- constructor(data) {
8460
- super(data);
8461
- }
8462
8519
  reset(data) {
8463
8520
  this.__setBranch();
8464
8521
  super.reset(data);
@@ -8583,7 +8640,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8583
8640
  const canvas = this.canvas = Creator.canvas(config);
8584
8641
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8585
8642
  if (this.isApp) this.__setApp();
8586
- this.__checkAutoLayout(config, parentApp);
8643
+ this.__checkAutoLayout();
8587
8644
  this.view = canvas.view;
8588
8645
  if (!parentApp) {
8589
8646
  this.selector = Creator.selector(this);
@@ -8682,7 +8739,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8682
8739
  this.leafer = leafer;
8683
8740
  this.__level = 1;
8684
8741
  }
8685
- __checkAutoLayout(config, parentApp) {
8742
+ __checkAutoLayout() {
8743
+ const {config: config, parentApp: parentApp} = this;
8686
8744
  if (!parentApp) {
8687
8745
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8688
8746
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8699,7 +8757,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8699
8757
  } else if (attrName === "zIndex") {
8700
8758
  this.canvas.zIndex = newValue;
8701
8759
  setTimeout(() => this.parent && this.parent.__updateSortChildren());
8702
- }
8760
+ } else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
8761
+ mode: newValue
8762
+ });
8703
8763
  }
8704
8764
  return super.__setAttr(attrName, newValue);
8705
8765
  }
@@ -8708,9 +8768,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8708
8768
  return super.__getAttr(attrName);
8709
8769
  }
8710
8770
  __changeCanvasSize(attrName, newValue) {
8711
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8712
- data[attrName] = this.config[attrName] = newValue;
8713
- if (newValue) this.canvas.stopAutoLayout();
8771
+ const {config: config, canvas: canvas} = this;
8772
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8773
+ data[attrName] = config[attrName] = newValue;
8774
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8714
8775
  this.__doResize(data);
8715
8776
  }
8716
8777
  __changeFill(newValue) {
@@ -8857,9 +8918,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8857
8918
  if (!this.parent) {
8858
8919
  if (this.selector) this.selector.destroy();
8859
8920
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
8860
- this.canvasManager.destroy();
8921
+ if (this.canvasManager) this.canvasManager.destroy();
8861
8922
  }
8862
- this.canvas.destroy();
8923
+ if (this.canvas) this.canvas.destroy();
8863
8924
  this.config.view = this.view = this.parentApp = null;
8864
8925
  if (this.userConfig) this.userConfig.view = null;
8865
8926
  super.destroy();
@@ -8881,15 +8942,14 @@ __decorate([ dataProcessor(LeaferData) ], Leafer.prototype, "__", void 0);
8881
8942
 
8882
8943
  __decorate([ boundsType() ], Leafer.prototype, "pixelRatio", void 0);
8883
8944
 
8945
+ __decorate([ dataType("normal") ], Leafer.prototype, "mode", void 0);
8946
+
8884
8947
  Leafer = Leafer_1 = __decorate([ registerUI() ], Leafer);
8885
8948
 
8886
8949
  let Rect = class Rect extends UI {
8887
8950
  get __tag() {
8888
8951
  return "Rect";
8889
8952
  }
8890
- constructor(data) {
8891
- super(data);
8892
- }
8893
8953
  };
8894
8954
 
8895
8955
  __decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
@@ -9021,9 +9081,6 @@ let Frame = class Frame extends Box {
9021
9081
  get isFrame() {
9022
9082
  return true;
9023
9083
  }
9024
- constructor(data) {
9025
- super(data);
9026
- }
9027
9084
  };
9028
9085
 
9029
9086
  __decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
@@ -9040,9 +9097,6 @@ let Ellipse = class Ellipse extends UI {
9040
9097
  get __tag() {
9041
9098
  return "Ellipse";
9042
9099
  }
9043
- constructor(data) {
9044
- super(data);
9045
- }
9046
9100
  __updatePath() {
9047
9101
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9048
9102
  const rx = width / 2, ry = height / 2;
@@ -9082,98 +9136,29 @@ __decorate([ pathType(0) ], Ellipse.prototype, "endAngle", void 0);
9082
9136
 
9083
9137
  Ellipse = __decorate([ registerUI() ], Ellipse);
9084
9138
 
9085
- const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
9086
-
9087
- const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
9088
-
9089
- const {toBounds: toBounds} = PathBounds;
9090
-
9091
- let Line = class Line extends UI {
9092
- get __tag() {
9093
- return "Line";
9094
- }
9095
- get toPoint() {
9096
- const {width: width, rotation: rotation} = this.__;
9097
- const to = getPointData();
9098
- if (width) to.x = width;
9099
- if (rotation) rotate$1(to, rotation);
9100
- return to;
9101
- }
9102
- set toPoint(value) {
9103
- this.width = getDistance$2(defaultPoint, value);
9104
- this.rotation = getAngle$1(defaultPoint, value);
9105
- if (this.height) this.height = 0;
9106
- }
9107
- constructor(data) {
9108
- super(data);
9109
- }
9110
- __updatePath() {
9111
- const data = this.__;
9112
- const path = data.path = [];
9113
- if (data.points) {
9114
- drawPoints$1(path, data.points, false, data.closed);
9115
- } else {
9116
- moveTo$2(path, 0, 0);
9117
- lineTo$2(path, this.width, 0);
9118
- }
9119
- }
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
- };
9133
-
9134
- __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
9135
-
9136
- __decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
9137
-
9138
- __decorate([ boundsType(0) ], Line.prototype, "height", void 0);
9139
-
9140
- __decorate([ pathType() ], Line.prototype, "points", void 0);
9141
-
9142
- __decorate([ pathType(0) ], Line.prototype, "curve", void 0);
9143
-
9144
- __decorate([ pathType(false) ], Line.prototype, "closed", void 0);
9145
-
9146
- Line = __decorate([ registerUI() ], Line);
9147
-
9148
9139
  const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
9149
9140
 
9150
- const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = PathCommandDataHelper;
9151
-
9152
- const line = Line.prototype;
9141
+ const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
9153
9142
 
9154
9143
  let Polygon = class Polygon extends UI {
9155
9144
  get __tag() {
9156
9145
  return "Polygon";
9157
9146
  }
9158
- constructor(data) {
9159
- super(data);
9160
- }
9161
9147
  __updatePath() {
9162
- const path = this.__.path = [];
9163
- if (this.__.points) {
9164
- drawPoints(path, this.__.points, false, true);
9148
+ const data = this.__;
9149
+ const path = data.path = [];
9150
+ if (data.points) {
9151
+ drawPoints$1(path, data.points, data.curve, true);
9165
9152
  } else {
9166
- const {width: width, height: height, sides: sides} = this.__;
9153
+ const {width: width, height: height, sides: sides} = data;
9167
9154
  const rx = width / 2, ry = height / 2;
9168
- moveTo$1(path, rx, 0);
9155
+ moveTo$2(path, rx, 0);
9169
9156
  for (let i = 1; i < sides; i++) {
9170
- lineTo$1(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
9157
+ lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
9171
9158
  }
9172
9159
  closePath$1(path);
9173
9160
  }
9174
9161
  }
9175
- __updateRenderPath() {}
9176
- __updateBoxBounds() {}
9177
9162
  };
9178
9163
 
9179
9164
  __decorate([ dataProcessor(PolygonData) ], Polygon.prototype, "__", void 0);
@@ -9184,30 +9169,23 @@ __decorate([ pathType() ], Polygon.prototype, "points", void 0);
9184
9169
 
9185
9170
  __decorate([ pathType(0) ], Polygon.prototype, "curve", void 0);
9186
9171
 
9187
- __decorate([ rewrite(line.__updateRenderPath) ], Polygon.prototype, "__updateRenderPath", null);
9188
-
9189
- __decorate([ rewrite(line.__updateBoxBounds) ], Polygon.prototype, "__updateBoxBounds", null);
9190
-
9191
9172
  Polygon = __decorate([ rewriteAble(), registerUI() ], Polygon);
9192
9173
 
9193
9174
  const {sin: sin, cos: cos, PI: PI} = Math;
9194
9175
 
9195
- const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
9176
+ const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
9196
9177
 
9197
9178
  let Star = class Star extends UI {
9198
9179
  get __tag() {
9199
9180
  return "Star";
9200
9181
  }
9201
- constructor(data) {
9202
- super(data);
9203
- }
9204
9182
  __updatePath() {
9205
9183
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9206
9184
  const rx = width / 2, ry = height / 2;
9207
9185
  const path = this.__.path = [];
9208
- moveTo(path, rx, 0);
9186
+ moveTo$1(path, rx, 0);
9209
9187
  for (let i = 1; i < corners * 2; i++) {
9210
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
9188
+ lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
9211
9189
  }
9212
9190
  closePath(path);
9213
9191
  }
@@ -9221,6 +9199,52 @@ __decorate([ pathType(.382) ], Star.prototype, "innerRadius", void 0);
9221
9199
 
9222
9200
  Star = __decorate([ registerUI() ], Star);
9223
9201
 
9202
+ const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
9203
+
9204
+ const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
9205
+
9206
+ let Line = class Line extends UI {
9207
+ get __tag() {
9208
+ return "Line";
9209
+ }
9210
+ get toPoint() {
9211
+ const {width: width, rotation: rotation} = this.__;
9212
+ const to = getPointData();
9213
+ if (width) to.x = width;
9214
+ if (rotation) rotate$1(to, rotation);
9215
+ return to;
9216
+ }
9217
+ set toPoint(value) {
9218
+ this.width = getDistance$2(defaultPoint, value);
9219
+ this.rotation = getAngle$1(defaultPoint, value);
9220
+ if (this.height) this.height = 0;
9221
+ }
9222
+ __updatePath() {
9223
+ const data = this.__;
9224
+ const path = data.path = [];
9225
+ if (data.points) {
9226
+ drawPoints(path, data.points, data.curve, data.closed);
9227
+ } else {
9228
+ moveTo(path, 0, 0);
9229
+ lineTo(path, this.width, 0);
9230
+ }
9231
+ }
9232
+ };
9233
+
9234
+ __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
9235
+
9236
+ __decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
9237
+
9238
+ __decorate([ boundsType(0) ], Line.prototype, "height", void 0);
9239
+
9240
+ __decorate([ pathType() ], Line.prototype, "points", void 0);
9241
+
9242
+ __decorate([ pathType(0) ], Line.prototype, "curve", void 0);
9243
+
9244
+ __decorate([ pathType(false) ], Line.prototype, "closed", void 0);
9245
+
9246
+ Line = __decorate([ registerUI() ], Line);
9247
+
9224
9248
  let Image$1 = class Image extends Rect {
9225
9249
  get __tag() {
9226
9250
  return "Image";
@@ -9233,9 +9257,6 @@ let Image$1 = class Image extends Rect {
9233
9257
  const {fill: fill} = this.__;
9234
9258
  return isArray(fill) && fill[0].image;
9235
9259
  }
9236
- constructor(data) {
9237
- super(data);
9238
- }
9239
9260
  };
9240
9261
 
9241
9262
  __decorate([ dataProcessor(ImageData) ], Image$1.prototype, "__", void 0);
@@ -9335,9 +9356,6 @@ let Text = class Text extends UI {
9335
9356
  this.updateLayout();
9336
9357
  return this.__.__textDrawData;
9337
9358
  }
9338
- constructor(data) {
9339
- super(data);
9340
- }
9341
9359
  __updateTextDrawData() {
9342
9360
  const data = this.__;
9343
9361
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -9374,10 +9392,6 @@ let Text = class Text extends UI {
9374
9392
  DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9375
9393
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9376
9394
  }
9377
- __onUpdateSize() {
9378
- if (this.__box) this.__box.__onUpdateSize();
9379
- super.__onUpdateSize();
9380
- }
9381
9395
  __updateRenderSpread() {
9382
9396
  let width = super.__updateRenderSpread();
9383
9397
  if (!width) width = this.isOverflow ? 1 : 0;
@@ -9388,6 +9402,11 @@ let Text = class Text extends UI {
9388
9402
  copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
9389
9403
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
9390
9404
  }
9405
+ __updateChange() {
9406
+ super.__updateChange();
9407
+ const box = this.__box;
9408
+ if (box) box.__onUpdateSize(), box.__updateChange();
9409
+ }
9391
9410
  __drawRenderPath(canvas) {
9392
9411
  canvas.font = this.__.__font;
9393
9412
  }
@@ -9470,9 +9489,6 @@ let Path = class Path extends UI {
9470
9489
  get __tag() {
9471
9490
  return "Path";
9472
9491
  }
9473
- constructor(data) {
9474
- super(data);
9475
- }
9476
9492
  };
9477
9493
 
9478
9494
  __decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
@@ -9485,9 +9501,6 @@ let Pen = class Pen extends Group {
9485
9501
  get __tag() {
9486
9502
  return "Pen";
9487
9503
  }
9488
- constructor(data) {
9489
- super(data);
9490
- }
9491
9504
  setStyle(data) {
9492
9505
  const path = this.pathElement = new Path(data);
9493
9506
  this.pathStyle = data;
@@ -10183,7 +10196,7 @@ function ignoreRender(ui, value) {
10183
10196
 
10184
10197
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
10185
10198
 
10186
- const {floor: floor, max: max, abs: abs} = Math;
10199
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
10187
10200
 
10188
10201
  function createPattern(ui, paint, pixelRatio) {
10189
10202
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -10193,8 +10206,6 @@ function createPattern(ui, paint, pixelRatio) {
10193
10206
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
10194
10207
  scaleX *= pixelRatio;
10195
10208
  scaleY *= pixelRatio;
10196
- const xGap = gap && gap.x * scaleX;
10197
- const yGap = gap && gap.y * scaleY;
10198
10209
  if (sx) {
10199
10210
  sx = abs(sx);
10200
10211
  sy = abs(sy);
@@ -10211,7 +10222,10 @@ function createPattern(ui, paint, pixelRatio) {
10211
10222
  if (size > Platform.image.maxCacheSize) return false;
10212
10223
  }
10213
10224
  let maxSize = Platform.image.maxPatternSize;
10214
- if (!image.isSVG) {
10225
+ if (image.isSVG) {
10226
+ const ws = width / image.width;
10227
+ if (ws > 1) imageScale = ws / ceil(ws);
10228
+ } else {
10215
10229
  const imageSize = image.width * image.height;
10216
10230
  if (maxSize > imageSize) maxSize = imageSize;
10217
10231
  }
@@ -10226,18 +10240,20 @@ function createPattern(ui, paint, pixelRatio) {
10226
10240
  scaleX /= sx;
10227
10241
  scaleY /= sy;
10228
10242
  }
10243
+ const xGap = gap && gap.x * scaleX;
10244
+ const yGap = gap && gap.y * scaleY;
10229
10245
  if (transform || scaleX !== 1 || scaleY !== 1) {
10246
+ const canvasWidth = width + (xGap || 0);
10247
+ const canvasHeight = height + (yGap || 0);
10248
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
10249
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
10230
10250
  if (!imageMatrix) {
10231
10251
  imageMatrix = get$1();
10232
10252
  if (transform) copy$1(imageMatrix, transform);
10233
10253
  }
10234
10254
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
10235
10255
  }
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);
10256
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
10241
10257
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
10242
10258
  paint.style = pattern;
10243
10259
  paint.patternId = id;
@@ -10479,12 +10495,18 @@ function shadow(ui, current, shape) {
10479
10495
  }
10480
10496
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
10481
10497
  }
10482
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
10498
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
10483
10499
  if (end && index < end) other.clearWorld(copyBounds);
10484
10500
  });
10485
10501
  other.recycle(copyBounds);
10486
10502
  }
10487
10503
 
10504
+ function getShadowSpread(_ui, shadow) {
10505
+ let width = 0;
10506
+ shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
10507
+ return width;
10508
+ }
10509
+
10488
10510
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
10489
10511
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
10490
10512
  if (Platform.fullImageShadow) {
@@ -10562,7 +10584,11 @@ const EffectModule = {
10562
10584
  shadow: shadow,
10563
10585
  innerShadow: innerShadow,
10564
10586
  blur: blur,
10565
- backgroundBlur: backgroundBlur
10587
+ backgroundBlur: backgroundBlur,
10588
+ getShadowSpread: getShadowSpread,
10589
+ isTransformShadow(_shadow) {
10590
+ return undefined;
10591
+ }
10566
10592
  };
10567
10593
 
10568
10594
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
@@ -11070,16 +11096,17 @@ function toTextChar(row) {
11070
11096
  }
11071
11097
 
11072
11098
  function decorationText(drawData, style) {
11073
- let type;
11099
+ let type, offset = 0;
11074
11100
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
11075
11101
  drawData.decorationHeight = fontSize / 11;
11076
11102
  if (isObject(textDecoration)) {
11077
11103
  type = textDecoration.type;
11078
11104
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
11105
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
11079
11106
  } else type = textDecoration;
11080
11107
  switch (type) {
11081
11108
  case "under":
11082
- drawData.decorationY = [ fontSize * .15 ];
11109
+ drawData.decorationY = [ fontSize * .15 + offset ];
11083
11110
  break;
11084
11111
 
11085
11112
  case "delete":
@@ -11087,7 +11114,7 @@ function decorationText(drawData, style) {
11087
11114
  break;
11088
11115
 
11089
11116
  case "under-delete":
11090
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
11117
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
11091
11118
  }
11092
11119
  }
11093
11120
 
@@ -11185,4 +11212,4 @@ Object.assign(Effect, EffectModule);
11185
11212
 
11186
11213
  useCanvas();
11187
11214
 
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 };
11215
+ 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 };