@leafer-draw/miniapp 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$9 = 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
  class LeaferCanvas extends LeaferCanvasBase {
6748
6757
  get allowBackgroundColor() {
@@ -6796,6 +6805,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6796
6805
  this.view = Platform.origin.createCanvas(1, 1);
6797
6806
  }
6798
6807
  updateViewSize() {
6808
+ if (this.unreal) return;
6799
6809
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
6800
6810
  this.view.width = Math.ceil(width * pixelRatio);
6801
6811
  this.view.height = Math.ceil(height * pixelRatio);
@@ -6807,6 +6817,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6807
6817
  });
6808
6818
  }
6809
6819
  startAutoLayout(autoBounds, listener) {
6820
+ if (this.resizeListener) return;
6810
6821
  this.resizeListener = listener;
6811
6822
  if (autoBounds) {
6812
6823
  this.checkSize = this.checkSize.bind(this);
@@ -7316,7 +7327,7 @@ class Renderer {
7316
7327
  this.times = 0;
7317
7328
  this.config = {
7318
7329
  usePartRender: true,
7319
- maxFPS: 60
7330
+ maxFPS: 120
7320
7331
  };
7321
7332
  this.target = target;
7322
7333
  this.canvas = canvas;
@@ -7471,11 +7482,15 @@ class Renderer {
7471
7482
  if (this.requestTime || !target) return;
7472
7483
  if (target.parentApp) return target.parentApp.requestRender(false);
7473
7484
  const requestTime = this.requestTime = Date.now();
7474
- Platform.requestRender(() => {
7475
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7485
+ const render = () => {
7486
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7487
+ const {maxFPS: maxFPS} = this.config;
7488
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7489
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7476
7490
  this.requestTime = 0;
7477
7491
  this.checkRender();
7478
- });
7492
+ };
7493
+ Platform.requestRender(render);
7479
7494
  }
7480
7495
  __onResize(e) {
7481
7496
  if (this.canvas.unreal) return;
@@ -7518,7 +7533,8 @@ class Renderer {
7518
7533
  if (this.target) {
7519
7534
  this.stop();
7520
7535
  this.__removeListenEvents();
7521
- this.target = this.canvas = this.config = null;
7536
+ this.config = {};
7537
+ this.target = this.canvas = null;
7522
7538
  }
7523
7539
  }
7524
7540
  }
@@ -7826,7 +7842,11 @@ class LeaferData extends GroupData {
7826
7842
 
7827
7843
  class FrameData extends BoxData {}
7828
7844
 
7829
- class LineData extends UIData {}
7845
+ class LineData extends UIData {
7846
+ get __usePathBox() {
7847
+ return this.points || this.__pathInputed;
7848
+ }
7849
+ }
7830
7850
 
7831
7851
  class RectData extends UIData {
7832
7852
  get __boxStroke() {
@@ -7840,7 +7860,7 @@ class EllipseData extends UIData {
7840
7860
  }
7841
7861
  }
7842
7862
 
7843
- class PolygonData extends UIData {}
7863
+ class PolygonData extends LineData {}
7844
7864
 
7845
7865
  class StarData extends UIData {}
7846
7866
 
@@ -7884,8 +7904,6 @@ class TextData extends UIData {
7884
7904
  if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
7885
7905
  box.set(value);
7886
7906
  if (boxLayout.strokeChanged) layout.strokeChange();
7887
- if (boxLayout.renderChanged) layout.renderChange();
7888
- box.__updateChange();
7889
7907
  } else if (box) {
7890
7908
  t.__box = box.parent = null;
7891
7909
  box.destroy();
@@ -7955,7 +7973,7 @@ const UIBounds = {
7955
7973
  __updateRenderSpread() {
7956
7974
  let width = 0;
7957
7975
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7958
- 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));
7976
+ if (shadow) width = Effect.getShadowSpread(this, shadow);
7959
7977
  if (blur) width = Math.max(width, blur);
7960
7978
  if (filter) width += Filter.getSpread(filter);
7961
7979
  if (renderSpread) width += renderSpread;
@@ -7968,36 +7986,69 @@ const UIBounds = {
7968
7986
  }
7969
7987
  };
7970
7988
 
7989
+ const {float: float} = MathHelper;
7990
+
7991
+ const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
7992
+
7971
7993
  const DragBoundsHelper = {
7994
+ limitMove(leaf, move) {
7995
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7996
+ if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
7997
+ D.axisMove(leaf, move);
7998
+ },
7999
+ limitScaleOf(leaf, origin, scale) {
8000
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8001
+ if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
8002
+ },
8003
+ axisMove(leaf, move) {
8004
+ const {draggable: draggable} = leaf;
8005
+ if (draggable === "x") move.y = 0;
8006
+ if (draggable === "y") move.x = 0;
8007
+ },
8008
+ getDragBounds(leaf) {
8009
+ const {dragBounds: dragBounds} = leaf;
8010
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
8011
+ },
8012
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
8013
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
8014
+ },
7972
8015
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
7973
8016
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
7974
8017
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
7975
8018
  if (!change) move = Object.assign({}, move);
7976
- const isBiggerWidth = content.width > dragBounds.width;
7977
- const isBiggerHeight = content.height > dragBounds.height;
7978
- if (isBiggerWidth && dragBoundsType !== "outer") {
8019
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7979
8020
  if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
7980
8021
  } else {
7981
8022
  if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
7982
8023
  }
7983
- if (isBiggerHeight && dragBoundsType !== "outer") {
8024
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7984
8025
  if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
7985
8026
  } else {
7986
8027
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
7987
8028
  }
7988
- move.x = MathHelper.float(move.x);
7989
- move.y = MathHelper.float(move.y);
8029
+ move.x = float(move.x);
8030
+ move.y = float(move.y);
7990
8031
  return move;
7991
8032
  },
7992
- axisMove(leaf, move) {
7993
- const {draggable: draggable} = leaf;
7994
- if (draggable === "x") move.y = 0;
7995
- if (draggable === "y") move.x = 0;
7996
- },
7997
- limitMove(leaf, move) {
7998
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7999
- if (dragBounds) D.getValidMove(leaf.__localBoxBounds, dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds, dragBoundsType, move, true);
8000
- D.axisMove(leaf, move);
8033
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
8034
+ if (!change) scale = Object.assign({}, scale);
8035
+ let fitScaleX, fitScaleY;
8036
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
8037
+ tempMerge.set(tempContent).add(dragBounds);
8038
+ tempIntersect.set(tempContent).intersect(dragBounds);
8039
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
8040
+ fitScaleX = tempMerge.width / tempContent.width;
8041
+ } else {
8042
+ fitScaleX = tempIntersect.width / tempContent.width;
8043
+ }
8044
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
8045
+ fitScaleY = tempMerge.height / tempContent.height;
8046
+ } else {
8047
+ fitScaleY = tempIntersect.height / tempContent.height;
8048
+ }
8049
+ scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
8050
+ scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
8051
+ return scale;
8001
8052
  }
8002
8053
  };
8003
8054
 
@@ -8015,7 +8066,7 @@ const UIRender = {
8015
8066
  }
8016
8067
  if (data.__useEffect) {
8017
8068
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
8018
- 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"));
8069
+ 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"));
8019
8070
  data.__useEffect = !!(shadow || otherEffect);
8020
8071
  }
8021
8072
  data.__checkSingle();
@@ -8150,20 +8201,9 @@ let UI = UI_1 = class UI extends Leaf {
8150
8201
  if (!path) this.__drawPathByBox(pen);
8151
8202
  return pen;
8152
8203
  }
8153
- constructor(data) {
8154
- super(data);
8155
- }
8156
8204
  reset(_data) {}
8157
- set(data, transition) {
8158
- if (data) {
8159
- if (transition) {
8160
- if (transition === "temp") {
8161
- this.lockNormalStyle = true;
8162
- Object.assign(this, data);
8163
- this.lockNormalStyle = false;
8164
- } else this.animate(data, transition);
8165
- } else Object.assign(this, data);
8166
- }
8205
+ set(data, _transition) {
8206
+ if (data) Object.assign(this, data);
8167
8207
  }
8168
8208
  get(name) {
8169
8209
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -8209,7 +8249,7 @@ let UI = UI_1 = class UI extends Leaf {
8209
8249
  const data = this.__;
8210
8250
  if (data.path) {
8211
8251
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8212
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
8252
+ if (data.__useArrow) PathArrow.addArrows(this);
8213
8253
  } else data.__pathForRender && (data.__pathForRender = undefined);
8214
8254
  }
8215
8255
  __drawRenderPath(canvas) {
@@ -8233,7 +8273,8 @@ let UI = UI_1 = class UI extends Leaf {
8233
8273
  drawImagePlaceholder(canvas, _image) {
8234
8274
  Paint.fill(this.__.placeholderColor, this, canvas);
8235
8275
  }
8236
- animate(_keyframe, _options, _type, _isTemp) {
8276
+ animate(keyframe, _options, _type, _isTemp) {
8277
+ this.set(keyframe);
8237
8278
  return Plugin.need("animate");
8238
8279
  }
8239
8280
  killAnimate(_type, _nextStyle) {}
@@ -8422,9 +8463,6 @@ let Group = class Group extends UI {
8422
8463
  get isBranch() {
8423
8464
  return true;
8424
8465
  }
8425
- constructor(data) {
8426
- super(data);
8427
- }
8428
8466
  reset(data) {
8429
8467
  this.__setBranch();
8430
8468
  super.reset(data);
@@ -8549,7 +8587,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8549
8587
  const canvas = this.canvas = Creator.canvas(config);
8550
8588
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8551
8589
  if (this.isApp) this.__setApp();
8552
- this.__checkAutoLayout(config, parentApp);
8590
+ this.__checkAutoLayout();
8553
8591
  this.view = canvas.view;
8554
8592
  if (!parentApp) {
8555
8593
  this.selector = Creator.selector(this);
@@ -8648,7 +8686,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8648
8686
  this.leafer = leafer;
8649
8687
  this.__level = 1;
8650
8688
  }
8651
- __checkAutoLayout(config, parentApp) {
8689
+ __checkAutoLayout() {
8690
+ const {config: config, parentApp: parentApp} = this;
8652
8691
  if (!parentApp) {
8653
8692
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8654
8693
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8665,7 +8704,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8665
8704
  } else if (attrName === "zIndex") {
8666
8705
  this.canvas.zIndex = newValue;
8667
8706
  setTimeout(() => this.parent && this.parent.__updateSortChildren());
8668
- }
8707
+ } else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
8708
+ mode: newValue
8709
+ });
8669
8710
  }
8670
8711
  return super.__setAttr(attrName, newValue);
8671
8712
  }
@@ -8674,9 +8715,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8674
8715
  return super.__getAttr(attrName);
8675
8716
  }
8676
8717
  __changeCanvasSize(attrName, newValue) {
8677
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8678
- data[attrName] = this.config[attrName] = newValue;
8679
- if (newValue) this.canvas.stopAutoLayout();
8718
+ const {config: config, canvas: canvas} = this;
8719
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8720
+ data[attrName] = config[attrName] = newValue;
8721
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8680
8722
  this.__doResize(data);
8681
8723
  }
8682
8724
  __changeFill(newValue) {
@@ -8823,9 +8865,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8823
8865
  if (!this.parent) {
8824
8866
  if (this.selector) this.selector.destroy();
8825
8867
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
8826
- this.canvasManager.destroy();
8868
+ if (this.canvasManager) this.canvasManager.destroy();
8827
8869
  }
8828
- this.canvas.destroy();
8870
+ if (this.canvas) this.canvas.destroy();
8829
8871
  this.config.view = this.view = this.parentApp = null;
8830
8872
  if (this.userConfig) this.userConfig.view = null;
8831
8873
  super.destroy();
@@ -8847,15 +8889,14 @@ __decorate([ dataProcessor(LeaferData) ], Leafer.prototype, "__", void 0);
8847
8889
 
8848
8890
  __decorate([ boundsType() ], Leafer.prototype, "pixelRatio", void 0);
8849
8891
 
8892
+ __decorate([ dataType("normal") ], Leafer.prototype, "mode", void 0);
8893
+
8850
8894
  Leafer = Leafer_1 = __decorate([ registerUI() ], Leafer);
8851
8895
 
8852
8896
  let Rect = class Rect extends UI {
8853
8897
  get __tag() {
8854
8898
  return "Rect";
8855
8899
  }
8856
- constructor(data) {
8857
- super(data);
8858
- }
8859
8900
  };
8860
8901
 
8861
8902
  __decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
@@ -8987,9 +9028,6 @@ let Frame = class Frame extends Box {
8987
9028
  get isFrame() {
8988
9029
  return true;
8989
9030
  }
8990
- constructor(data) {
8991
- super(data);
8992
- }
8993
9031
  };
8994
9032
 
8995
9033
  __decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
@@ -9006,9 +9044,6 @@ let Ellipse = class Ellipse extends UI {
9006
9044
  get __tag() {
9007
9045
  return "Ellipse";
9008
9046
  }
9009
- constructor(data) {
9010
- super(data);
9011
- }
9012
9047
  __updatePath() {
9013
9048
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9014
9049
  const rx = width / 2, ry = height / 2;
@@ -9048,98 +9083,29 @@ __decorate([ pathType(0) ], Ellipse.prototype, "endAngle", void 0);
9048
9083
 
9049
9084
  Ellipse = __decorate([ registerUI() ], Ellipse);
9050
9085
 
9051
- const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
9052
-
9053
- const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
9054
-
9055
- const {toBounds: toBounds} = PathBounds;
9056
-
9057
- let Line = class Line extends UI {
9058
- get __tag() {
9059
- return "Line";
9060
- }
9061
- get toPoint() {
9062
- const {width: width, rotation: rotation} = this.__;
9063
- const to = getPointData();
9064
- if (width) to.x = width;
9065
- if (rotation) rotate$1(to, rotation);
9066
- return to;
9067
- }
9068
- set toPoint(value) {
9069
- this.width = getDistance$2(defaultPoint, value);
9070
- this.rotation = getAngle$1(defaultPoint, value);
9071
- if (this.height) this.height = 0;
9072
- }
9073
- constructor(data) {
9074
- super(data);
9075
- }
9076
- __updatePath() {
9077
- const data = this.__;
9078
- const path = data.path = [];
9079
- if (data.points) {
9080
- drawPoints$1(path, data.points, false, data.closed);
9081
- } else {
9082
- moveTo$2(path, 0, 0);
9083
- lineTo$2(path, this.width, 0);
9084
- }
9085
- }
9086
- __updateRenderPath() {
9087
- const data = this.__;
9088
- if (!this.pathInputed && data.points && data.curve) {
9089
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
9090
- if (data.__useArrow) PathArrow.addArrows(this, false);
9091
- } else super.__updateRenderPath();
9092
- }
9093
- __updateBoxBounds() {
9094
- if (this.points) {
9095
- toBounds(this.__.__pathForRender, this.__layout.boxBounds);
9096
- } else super.__updateBoxBounds();
9097
- }
9098
- };
9099
-
9100
- __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
9101
-
9102
- __decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
9103
-
9104
- __decorate([ boundsType(0) ], Line.prototype, "height", void 0);
9105
-
9106
- __decorate([ pathType() ], Line.prototype, "points", void 0);
9107
-
9108
- __decorate([ pathType(0) ], Line.prototype, "curve", void 0);
9109
-
9110
- __decorate([ pathType(false) ], Line.prototype, "closed", void 0);
9111
-
9112
- Line = __decorate([ registerUI() ], Line);
9113
-
9114
9086
  const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
9115
9087
 
9116
- const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = PathCommandDataHelper;
9117
-
9118
- const line = Line.prototype;
9088
+ const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
9119
9089
 
9120
9090
  let Polygon = class Polygon extends UI {
9121
9091
  get __tag() {
9122
9092
  return "Polygon";
9123
9093
  }
9124
- constructor(data) {
9125
- super(data);
9126
- }
9127
9094
  __updatePath() {
9128
- const path = this.__.path = [];
9129
- if (this.__.points) {
9130
- drawPoints(path, this.__.points, false, true);
9095
+ const data = this.__;
9096
+ const path = data.path = [];
9097
+ if (data.points) {
9098
+ drawPoints$1(path, data.points, data.curve, true);
9131
9099
  } else {
9132
- const {width: width, height: height, sides: sides} = this.__;
9100
+ const {width: width, height: height, sides: sides} = data;
9133
9101
  const rx = width / 2, ry = height / 2;
9134
- moveTo$1(path, rx, 0);
9102
+ moveTo$2(path, rx, 0);
9135
9103
  for (let i = 1; i < sides; i++) {
9136
- lineTo$1(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
9104
+ lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
9137
9105
  }
9138
9106
  closePath$1(path);
9139
9107
  }
9140
9108
  }
9141
- __updateRenderPath() {}
9142
- __updateBoxBounds() {}
9143
9109
  };
9144
9110
 
9145
9111
  __decorate([ dataProcessor(PolygonData) ], Polygon.prototype, "__", void 0);
@@ -9150,30 +9116,23 @@ __decorate([ pathType() ], Polygon.prototype, "points", void 0);
9150
9116
 
9151
9117
  __decorate([ pathType(0) ], Polygon.prototype, "curve", void 0);
9152
9118
 
9153
- __decorate([ rewrite(line.__updateRenderPath) ], Polygon.prototype, "__updateRenderPath", null);
9154
-
9155
- __decorate([ rewrite(line.__updateBoxBounds) ], Polygon.prototype, "__updateBoxBounds", null);
9156
-
9157
9119
  Polygon = __decorate([ rewriteAble(), registerUI() ], Polygon);
9158
9120
 
9159
9121
  const {sin: sin, cos: cos, PI: PI} = Math;
9160
9122
 
9161
- const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
9123
+ const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
9162
9124
 
9163
9125
  let Star = class Star extends UI {
9164
9126
  get __tag() {
9165
9127
  return "Star";
9166
9128
  }
9167
- constructor(data) {
9168
- super(data);
9169
- }
9170
9129
  __updatePath() {
9171
9130
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9172
9131
  const rx = width / 2, ry = height / 2;
9173
9132
  const path = this.__.path = [];
9174
- moveTo(path, rx, 0);
9133
+ moveTo$1(path, rx, 0);
9175
9134
  for (let i = 1; i < corners * 2; i++) {
9176
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
9135
+ 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));
9177
9136
  }
9178
9137
  closePath(path);
9179
9138
  }
@@ -9187,6 +9146,52 @@ __decorate([ pathType(.382) ], Star.prototype, "innerRadius", void 0);
9187
9146
 
9188
9147
  Star = __decorate([ registerUI() ], Star);
9189
9148
 
9149
+ const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
9150
+
9151
+ const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
9152
+
9153
+ let Line = class Line extends UI {
9154
+ get __tag() {
9155
+ return "Line";
9156
+ }
9157
+ get toPoint() {
9158
+ const {width: width, rotation: rotation} = this.__;
9159
+ const to = getPointData();
9160
+ if (width) to.x = width;
9161
+ if (rotation) rotate$1(to, rotation);
9162
+ return to;
9163
+ }
9164
+ set toPoint(value) {
9165
+ this.width = getDistance$2(defaultPoint, value);
9166
+ this.rotation = getAngle$1(defaultPoint, value);
9167
+ if (this.height) this.height = 0;
9168
+ }
9169
+ __updatePath() {
9170
+ const data = this.__;
9171
+ const path = data.path = [];
9172
+ if (data.points) {
9173
+ drawPoints(path, data.points, data.curve, data.closed);
9174
+ } else {
9175
+ moveTo(path, 0, 0);
9176
+ lineTo(path, this.width, 0);
9177
+ }
9178
+ }
9179
+ };
9180
+
9181
+ __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
9182
+
9183
+ __decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
9184
+
9185
+ __decorate([ boundsType(0) ], Line.prototype, "height", void 0);
9186
+
9187
+ __decorate([ pathType() ], Line.prototype, "points", void 0);
9188
+
9189
+ __decorate([ pathType(0) ], Line.prototype, "curve", void 0);
9190
+
9191
+ __decorate([ pathType(false) ], Line.prototype, "closed", void 0);
9192
+
9193
+ Line = __decorate([ registerUI() ], Line);
9194
+
9190
9195
  let Image = class Image extends Rect {
9191
9196
  get __tag() {
9192
9197
  return "Image";
@@ -9199,9 +9204,6 @@ let Image = class Image extends Rect {
9199
9204
  const {fill: fill} = this.__;
9200
9205
  return isArray(fill) && fill[0].image;
9201
9206
  }
9202
- constructor(data) {
9203
- super(data);
9204
- }
9205
9207
  };
9206
9208
 
9207
9209
  __decorate([ dataProcessor(ImageData) ], Image.prototype, "__", void 0);
@@ -9301,9 +9303,6 @@ let Text = class Text extends UI {
9301
9303
  this.updateLayout();
9302
9304
  return this.__.__textDrawData;
9303
9305
  }
9304
- constructor(data) {
9305
- super(data);
9306
- }
9307
9306
  __updateTextDrawData() {
9308
9307
  const data = this.__;
9309
9308
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -9340,10 +9339,6 @@ let Text = class Text extends UI {
9340
9339
  DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9341
9340
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9342
9341
  }
9343
- __onUpdateSize() {
9344
- if (this.__box) this.__box.__onUpdateSize();
9345
- super.__onUpdateSize();
9346
- }
9347
9342
  __updateRenderSpread() {
9348
9343
  let width = super.__updateRenderSpread();
9349
9344
  if (!width) width = this.isOverflow ? 1 : 0;
@@ -9354,6 +9349,11 @@ let Text = class Text extends UI {
9354
9349
  copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
9355
9350
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
9356
9351
  }
9352
+ __updateChange() {
9353
+ super.__updateChange();
9354
+ const box = this.__box;
9355
+ if (box) box.__onUpdateSize(), box.__updateChange();
9356
+ }
9357
9357
  __drawRenderPath(canvas) {
9358
9358
  canvas.font = this.__.__font;
9359
9359
  }
@@ -9436,9 +9436,6 @@ let Path = class Path extends UI {
9436
9436
  get __tag() {
9437
9437
  return "Path";
9438
9438
  }
9439
- constructor(data) {
9440
- super(data);
9441
- }
9442
9439
  };
9443
9440
 
9444
9441
  __decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
@@ -9451,9 +9448,6 @@ let Pen = class Pen extends Group {
9451
9448
  get __tag() {
9452
9449
  return "Pen";
9453
9450
  }
9454
- constructor(data) {
9455
- super(data);
9456
- }
9457
9451
  setStyle(data) {
9458
9452
  const path = this.pathElement = new Path(data);
9459
9453
  this.pathStyle = data;
@@ -10149,7 +10143,7 @@ function ignoreRender(ui, value) {
10149
10143
 
10150
10144
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
10151
10145
 
10152
- const {floor: floor, max: max, abs: abs} = Math;
10146
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
10153
10147
 
10154
10148
  function createPattern(ui, paint, pixelRatio) {
10155
10149
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -10159,8 +10153,6 @@ function createPattern(ui, paint, pixelRatio) {
10159
10153
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
10160
10154
  scaleX *= pixelRatio;
10161
10155
  scaleY *= pixelRatio;
10162
- const xGap = gap && gap.x * scaleX;
10163
- const yGap = gap && gap.y * scaleY;
10164
10156
  if (sx) {
10165
10157
  sx = abs(sx);
10166
10158
  sy = abs(sy);
@@ -10177,7 +10169,10 @@ function createPattern(ui, paint, pixelRatio) {
10177
10169
  if (size > Platform.image.maxCacheSize) return false;
10178
10170
  }
10179
10171
  let maxSize = Platform.image.maxPatternSize;
10180
- if (!image.isSVG) {
10172
+ if (image.isSVG) {
10173
+ const ws = width / image.width;
10174
+ if (ws > 1) imageScale = ws / ceil(ws);
10175
+ } else {
10181
10176
  const imageSize = image.width * image.height;
10182
10177
  if (maxSize > imageSize) maxSize = imageSize;
10183
10178
  }
@@ -10192,18 +10187,20 @@ function createPattern(ui, paint, pixelRatio) {
10192
10187
  scaleX /= sx;
10193
10188
  scaleY /= sy;
10194
10189
  }
10190
+ const xGap = gap && gap.x * scaleX;
10191
+ const yGap = gap && gap.y * scaleY;
10195
10192
  if (transform || scaleX !== 1 || scaleY !== 1) {
10193
+ const canvasWidth = width + (xGap || 0);
10194
+ const canvasHeight = height + (yGap || 0);
10195
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
10196
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
10196
10197
  if (!imageMatrix) {
10197
10198
  imageMatrix = get$1();
10198
10199
  if (transform) copy$1(imageMatrix, transform);
10199
10200
  }
10200
10201
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
10201
10202
  }
10202
- if (imageMatrix) {
10203
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
10204
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
10205
- }
10206
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
10203
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
10207
10204
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
10208
10205
  paint.style = pattern;
10209
10206
  paint.patternId = id;
@@ -10445,12 +10442,18 @@ function shadow(ui, current, shape) {
10445
10442
  }
10446
10443
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
10447
10444
  }
10448
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
10445
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
10449
10446
  if (end && index < end) other.clearWorld(copyBounds);
10450
10447
  });
10451
10448
  other.recycle(copyBounds);
10452
10449
  }
10453
10450
 
10451
+ function getShadowSpread(_ui, shadow) {
10452
+ let width = 0;
10453
+ 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));
10454
+ return width;
10455
+ }
10456
+
10454
10457
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
10455
10458
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
10456
10459
  if (Platform.fullImageShadow) {
@@ -10528,7 +10531,11 @@ const EffectModule = {
10528
10531
  shadow: shadow,
10529
10532
  innerShadow: innerShadow,
10530
10533
  blur: blur,
10531
- backgroundBlur: backgroundBlur
10534
+ backgroundBlur: backgroundBlur,
10535
+ getShadowSpread: getShadowSpread,
10536
+ isTransformShadow(_shadow) {
10537
+ return undefined;
10538
+ }
10532
10539
  };
10533
10540
 
10534
10541
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
@@ -11036,16 +11043,17 @@ function toTextChar(row) {
11036
11043
  }
11037
11044
 
11038
11045
  function decorationText(drawData, style) {
11039
- let type;
11046
+ let type, offset = 0;
11040
11047
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
11041
11048
  drawData.decorationHeight = fontSize / 11;
11042
11049
  if (isObject(textDecoration)) {
11043
11050
  type = textDecoration.type;
11044
11051
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
11052
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
11045
11053
  } else type = textDecoration;
11046
11054
  switch (type) {
11047
11055
  case "under":
11048
- drawData.decorationY = [ fontSize * .15 ];
11056
+ drawData.decorationY = [ fontSize * .15 + offset ];
11049
11057
  break;
11050
11058
 
11051
11059
  case "delete":
@@ -11053,7 +11061,7 @@ function decorationText(drawData, style) {
11053
11061
  break;
11054
11062
 
11055
11063
  case "under-delete":
11056
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
11064
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
11057
11065
  }
11058
11066
  }
11059
11067
 
@@ -11153,4 +11161,4 @@ try {
11153
11161
  if (wx) useCanvas("miniapp", wx);
11154
11162
  } catch (_a) {}
11155
11163
 
11156
- 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, 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 };
11164
+ 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, 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 };