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.
package/dist/web.js CHANGED
@@ -119,6 +119,9 @@ var LeaferUI = function(exports) {
119
119
  const {path: path} = this;
120
120
  return path && path.length === 6 && path[0] === 1;
121
121
  }
122
+ get __usePathBox() {
123
+ return this.__pathInputed;
124
+ }
122
125
  get __blendMode() {
123
126
  if (this.eraser && this.eraser !== "path") return "destination-out";
124
127
  const {blendMode: blendMode} = this;
@@ -341,7 +344,7 @@ var LeaferUI = function(exports) {
341
344
  };
342
345
  }
343
346
  const {sin: sin$5, cos: cos$5, acos: acos, sqrt: sqrt$3} = Math;
344
- const {float: float$1} = MathHelper;
347
+ const {float: float$2} = MathHelper;
345
348
  const tempPoint$3 = {};
346
349
  function getWorld() {
347
350
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), {
@@ -580,12 +583,12 @@ var LeaferUI = function(exports) {
580
583
  const cosR = c / scaleY;
581
584
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
582
585
  }
583
- const cosR = float$1(cos$5(rotation));
586
+ const cosR = float$2(cos$5(rotation));
584
587
  const sinR = sin$5(rotation);
585
- scaleX = float$1(scaleX), scaleY = float$1(scaleY);
586
- skewX = cosR ? float$1((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
587
- skewY = cosR ? float$1((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
588
- rotation = float$1(rotation / OneRadian);
588
+ scaleX = float$2(scaleX), scaleY = float$2(scaleY);
589
+ skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
590
+ skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
591
+ rotation = float$2(rotation / OneRadian);
589
592
  } else {
590
593
  scaleX = a;
591
594
  scaleY = d;
@@ -1080,10 +1083,10 @@ var LeaferUI = function(exports) {
1080
1083
  toPoint$5(align, box, to, onlyBoxSize, content, onlyContentSize);
1081
1084
  }
1082
1085
  };
1083
- const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3} = TwoPointBoundsHelper;
1086
+ const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
1084
1087
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1085
- const {float: float, fourNumber: fourNumber} = MathHelper;
1086
- const {floor: floor$2, ceil: ceil$1} = Math;
1088
+ const {float: float$1, fourNumber: fourNumber} = MathHelper;
1089
+ const {floor: floor$2, ceil: ceil$2} = Math;
1087
1090
  let right$1, bottom$1, boundsRight, boundsBottom;
1088
1091
  const point = {};
1089
1092
  const toPoint$4 = {};
@@ -1207,7 +1210,7 @@ var LeaferUI = function(exports) {
1207
1210
  point.x = t.x;
1208
1211
  toOuterPoint$2(matrix, point, toPoint$4);
1209
1212
  addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
1210
- toBounds$3(tempPointBounds$1, to);
1213
+ toBounds$2(tempPointBounds$1, to);
1211
1214
  }
1212
1215
  },
1213
1216
  toInnerOf(t, matrix, to) {
@@ -1245,8 +1248,8 @@ var LeaferUI = function(exports) {
1245
1248
  const {x: x, y: y} = t;
1246
1249
  t.x = floor$2(t.x);
1247
1250
  t.y = floor$2(t.y);
1248
- t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
1249
- t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
1251
+ t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1252
+ t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
1250
1253
  },
1251
1254
  unsign(t) {
1252
1255
  if (t.width < 0) {
@@ -1259,10 +1262,10 @@ var LeaferUI = function(exports) {
1259
1262
  }
1260
1263
  },
1261
1264
  float(t, maxLength) {
1262
- t.x = float(t.x, maxLength);
1263
- t.y = float(t.y, maxLength);
1264
- t.width = float(t.width, maxLength);
1265
- t.height = float(t.height, maxLength);
1265
+ t.x = float$1(t.x, maxLength);
1266
+ t.y = float$1(t.y, maxLength);
1267
+ t.width = float$1(t.width, maxLength);
1268
+ t.height = float$1(t.height, maxLength);
1266
1269
  },
1267
1270
  add(t, bounds, isPoint) {
1268
1271
  right$1 = t.x + t.width;
@@ -1306,7 +1309,7 @@ var LeaferUI = function(exports) {
1306
1309
  },
1307
1310
  setPoints(t, points) {
1308
1311
  points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
1309
- toBounds$3(tempPointBounds$1, t);
1312
+ toBounds$2(tempPointBounds$1, t);
1310
1313
  },
1311
1314
  setPoint(t, point) {
1312
1315
  B.set(t, point.x, point.y);
@@ -2063,15 +2066,15 @@ var LeaferUI = function(exports) {
2063
2066
  DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2064
2067
  canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2065
2068
  this.bounds = new Bounds(0, 0, this.width, this.height);
2066
- if (this.context && !this.unreal) {
2067
- this.updateViewSize();
2068
- this.smooth = this.config.smooth;
2069
- }
2069
+ this.updateViewSize();
2070
2070
  this.updateClientBounds();
2071
- if (this.context && !this.unreal && takeCanvas) {
2072
- this.clearWorld(takeCanvas.bounds);
2073
- this.copyWorld(takeCanvas);
2074
- takeCanvas.recycle();
2071
+ if (this.context) {
2072
+ this.smooth = this.config.smooth;
2073
+ if (!this.unreal && takeCanvas) {
2074
+ this.clearWorld(takeCanvas.bounds);
2075
+ this.copyWorld(takeCanvas);
2076
+ takeCanvas.recycle();
2077
+ }
2075
2078
  }
2076
2079
  }
2077
2080
  updateViewSize() {}
@@ -2372,7 +2375,7 @@ var LeaferUI = function(exports) {
2372
2375
  data[0] ? drawer.arcTo(x, y, right, y, data[0]) : drawer.lineTo(x, y);
2373
2376
  }
2374
2377
  };
2375
- const {sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2378
+ 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;
2376
2379
  const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
2377
2380
  const {set: set, toNumberPoints: toNumberPoints} = PointHelper;
2378
2381
  const {M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5} = PathCommandMap;
@@ -2438,9 +2441,11 @@ var LeaferUI = function(exports) {
2438
2441
  const CBy = toY - y1;
2439
2442
  let startRadian = atan2$1(BAy, BAx);
2440
2443
  let endRadian = atan2$1(CBy, CBx);
2444
+ const lenBA = hypot(BAx, BAy);
2445
+ const lenCB = hypot(CBx, CBy);
2441
2446
  let totalRadian = endRadian - startRadian;
2442
2447
  if (totalRadian < 0) totalRadian += PI2;
2443
- if (totalRadian === PI$2 || abs$2(BAx + BAy) < 1e-12 || abs$2(CBx + CBy) < 1e-12) {
2448
+ if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$2(totalRadian - PI$2) < 1e-12) {
2444
2449
  if (data) data.push(L$6, x1, y1);
2445
2450
  if (setPointBounds) {
2446
2451
  setPoint$1(setPointBounds, fromX, fromY);
@@ -2473,7 +2478,7 @@ var LeaferUI = function(exports) {
2473
2478
  let totalRadian = endRadian - startRadian;
2474
2479
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2475
2480
  if (anticlockwise) totalRadian -= PI2;
2476
- const parts = ceil(abs$2(totalRadian / PI_2));
2481
+ const parts = ceil$1(abs$2(totalRadian / PI_2));
2477
2482
  const partRadian = totalRadian / parts;
2478
2483
  const partRadian4Sin = sin$3(partRadian / 4);
2479
2484
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -3013,11 +3018,7 @@ var LeaferUI = function(exports) {
3013
3018
  this.set(path);
3014
3019
  }
3015
3020
  set(path) {
3016
- if (path) {
3017
- this.__path = isString(path) ? PathHelper.parse(path) : path;
3018
- } else {
3019
- this.__path = [];
3020
- }
3021
+ this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
3021
3022
  return this;
3022
3023
  }
3023
3024
  beginPath() {
@@ -3179,7 +3180,7 @@ var LeaferUI = function(exports) {
3179
3180
  };
3180
3181
  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: O, P: P, U: U} = PathCommandMap;
3181
3182
  const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
3182
- const {addPointBounds: addPointBounds, copy: copy$6, addPoint: addPoint, setPoint: setPoint, addBounds: addBounds, toBounds: toBounds$2} = TwoPointBoundsHelper;
3183
+ const {addPointBounds: addPointBounds, copy: copy$6, addPoint: addPoint, setPoint: setPoint, addBounds: addBounds, toBounds: toBounds$1} = TwoPointBoundsHelper;
3183
3184
  const debug$a = Debug.get("PathBounds");
3184
3185
  let radius, radiusX, radiusY;
3185
3186
  const tempPointBounds = {};
@@ -3188,7 +3189,7 @@ var LeaferUI = function(exports) {
3188
3189
  const PathBounds = {
3189
3190
  toBounds(data, setBounds) {
3190
3191
  PathBounds.toTwoPointBounds(data, setPointBounds);
3191
- toBounds$2(setPointBounds, setBounds);
3192
+ toBounds$1(setPointBounds, setBounds);
3192
3193
  },
3193
3194
  toTwoPointBounds(data, setPointBounds) {
3194
3195
  if (!data || !data.length) return setPoint(setPointBounds, 0, 0);
@@ -3370,10 +3371,13 @@ var LeaferUI = function(exports) {
3370
3371
  return smooth;
3371
3372
  }
3372
3373
  };
3373
- PathHelper.creator = new PathCreator;
3374
+ function path(path) {
3375
+ return new PathCreator(path);
3376
+ }
3377
+ const pen = path();
3378
+ PathHelper.creator = path();
3374
3379
  PathHelper.parse = PathConvert.parse;
3375
3380
  PathHelper.convertToCanvasData = PathConvert.toCanvasData;
3376
- const pen = new PathCreator;
3377
3381
  const {drawRoundRect: drawRoundRect} = RectHelper;
3378
3382
  function roundRect(drawer) {
3379
3383
  if (drawer && !drawer.roundRect) {
@@ -3726,7 +3730,7 @@ var LeaferUI = function(exports) {
3726
3730
  return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
3727
3731
  },
3728
3732
  isFormat(format, config) {
3729
- if (config.format === format) return true;
3733
+ if (config.format) return config.format === format;
3730
3734
  const {url: url} = config;
3731
3735
  if (url.startsWith("data:")) {
3732
3736
  if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
@@ -3816,7 +3820,7 @@ var LeaferUI = function(exports) {
3816
3820
  getFull(_filters) {
3817
3821
  return this.view;
3818
3822
  }
3819
- getCanvas(width, height, opacity, _filters, xGap, yGap) {
3823
+ getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
3820
3824
  width || (width = this.width);
3821
3825
  height || (height = this.height);
3822
3826
  if (this.cache) {
@@ -3832,6 +3836,7 @@ var LeaferUI = function(exports) {
3832
3836
  const canvas = Platform.origin.createCanvas(max$1(floor$1(width + (xGap || 0)), 1), max$1(floor$1(height + (yGap || 0)), 1));
3833
3837
  const ctx = canvas.getContext("2d");
3834
3838
  if (opacity) ctx.globalAlpha = opacity;
3839
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
3835
3840
  ctx.drawImage(this.view, 0, 0, width, height);
3836
3841
  this.cache = this.use > 1 ? {
3837
3842
  data: canvas,
@@ -4431,8 +4436,9 @@ var LeaferUI = function(exports) {
4431
4436
  };
4432
4437
  const L = LeafHelper;
4433
4438
  const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L;
4434
- function getTempLocal(t, world) {
4435
- return t.parent ? PointHelper.tempToInnerOf(world, t.parent.scrollWorldTransform) : world;
4439
+ function getTempLocal(t, worldPoint) {
4440
+ t.updateLayout();
4441
+ return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
4436
4442
  }
4437
4443
  const LeafBoundsHelper = {
4438
4444
  worldBounds(target) {
@@ -5099,6 +5105,7 @@ var LeaferUI = function(exports) {
5099
5105
  LeaferEvent.STOP = "leafer.stop";
5100
5106
  LeaferEvent.RESTART = "leafer.restart";
5101
5107
  LeaferEvent.END = "leafer.end";
5108
+ LeaferEvent.UPDATE_MODE = "leafer.update_mode";
5102
5109
  LeaferEvent.TRANSFORM = "leafer.transform";
5103
5110
  LeaferEvent.MOVE = "leafer.move";
5104
5111
  LeaferEvent.SCALE = "leafer.scale";
@@ -5357,7 +5364,7 @@ var LeaferUI = function(exports) {
5357
5364
  const {updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2} = LeafHelper;
5358
5365
  const {updateBounds: updateBounds$1} = BranchHelper;
5359
5366
  const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$3} = BoundsHelper;
5360
- const {toBounds: toBounds$1} = PathBounds;
5367
+ const {toBounds: toBounds} = PathBounds;
5361
5368
  const LeafBounds = {
5362
5369
  __updateWorldBounds() {
5363
5370
  const layout = this.__layout;
@@ -5428,8 +5435,8 @@ var LeaferUI = function(exports) {
5428
5435
  __updateBoxBounds(_secondLayout, _bounds) {
5429
5436
  const b = this.__layout.boxBounds;
5430
5437
  const data = this.__;
5431
- if (data.__pathInputed) {
5432
- toBounds$1(data.path, b);
5438
+ if (data.__usePathBox) {
5439
+ toBounds(data.path, b);
5433
5440
  } else {
5434
5441
  b.x = 0;
5435
5442
  b.y = 0;
@@ -6344,7 +6351,7 @@ var LeaferUI = function(exports) {
6344
6351
  this.levelMap = null;
6345
6352
  }
6346
6353
  }
6347
- const version = "1.9.4";
6354
+ const version = "1.9.6";
6348
6355
  const debug$4 = Debug.get("LeaferCanvas");
6349
6356
  class LeaferCanvas extends LeaferCanvasBase {
6350
6357
  set zIndex(zIndex) {
@@ -6433,10 +6440,22 @@ var LeaferUI = function(exports) {
6433
6440
  updateViewSize() {
6434
6441
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
6435
6442
  const {style: style} = this.view;
6436
- style.width = width + "px";
6437
- style.height = height + "px";
6438
- this.view.width = Math.ceil(width * pixelRatio);
6439
- this.view.height = Math.ceil(height * pixelRatio);
6443
+ if (this.unreal) {
6444
+ const {config: config, autoWidthStr: autoWidthStr, autoHeightStr: autoHeightStr} = this;
6445
+ if (config.width) {
6446
+ if (isUndefined(autoWidthStr)) this.autoWidthStr = style.width || "";
6447
+ style.width = config.width + "px";
6448
+ } else if (!isUndefined(autoWidthStr)) style.width = autoWidthStr;
6449
+ if (config.height) {
6450
+ if (isUndefined(autoHeightStr)) this.autoHeightStr = style.height || "";
6451
+ style.height = config.height + "px";
6452
+ } else if (!isUndefined(autoHeightStr)) style.height = autoHeightStr;
6453
+ } else {
6454
+ style.width = width + "px";
6455
+ style.height = height + "px";
6456
+ this.view.width = Math.ceil(width * pixelRatio);
6457
+ this.view.height = Math.ceil(height * pixelRatio);
6458
+ }
6440
6459
  }
6441
6460
  updateClientBounds() {
6442
6461
  if (this.view.parentElement) this.clientBounds = this.view.getBoundingClientRect();
@@ -6445,6 +6464,7 @@ var LeaferUI = function(exports) {
6445
6464
  this.resizeListener = listener;
6446
6465
  if (autoBounds) {
6447
6466
  this.autoBounds = autoBounds;
6467
+ if (this.resizeObserver) return;
6448
6468
  try {
6449
6469
  this.resizeObserver = new ResizeObserver(entries => {
6450
6470
  this.updateClientBounds();
@@ -6461,18 +6481,10 @@ var LeaferUI = function(exports) {
6461
6481
  } catch (_a) {
6462
6482
  this.imitateResizeObserver();
6463
6483
  }
6484
+ this.stopListenPixelRatio();
6464
6485
  } else {
6465
- window.addEventListener("resize", this.windowListener = () => {
6466
- const pixelRatio = Platform.devicePixelRatio;
6467
- if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
6468
- const {width: width, height: height} = this;
6469
- this.emitResize({
6470
- width: width,
6471
- height: height,
6472
- pixelRatio: pixelRatio
6473
- });
6474
- }
6475
- });
6486
+ this.listenPixelRatio();
6487
+ if (this.unreal) this.updateViewSize();
6476
6488
  }
6477
6489
  }
6478
6490
  imitateResizeObserver() {
@@ -6481,6 +6493,25 @@ var LeaferUI = function(exports) {
6481
6493
  Platform.requestRender(this.imitateResizeObserver.bind(this));
6482
6494
  }
6483
6495
  }
6496
+ listenPixelRatio() {
6497
+ if (!this.windowListener) window.addEventListener("resize", this.windowListener = () => {
6498
+ const pixelRatio = Platform.devicePixelRatio;
6499
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
6500
+ const {width: width, height: height} = this;
6501
+ this.emitResize({
6502
+ width: width,
6503
+ height: height,
6504
+ pixelRatio: pixelRatio
6505
+ });
6506
+ }
6507
+ });
6508
+ }
6509
+ stopListenPixelRatio() {
6510
+ if (this.windowListener) {
6511
+ window.removeEventListener("resize", this.windowListener);
6512
+ this.windowListener = null;
6513
+ }
6514
+ }
6484
6515
  checkAutoBounds(parentSize) {
6485
6516
  const view = this.view;
6486
6517
  const {x: x, y: y, width: width, height: height} = this.autoBounds.getBoundsFrom(parentSize);
@@ -6518,10 +6549,7 @@ var LeaferUI = function(exports) {
6518
6549
  destroy() {
6519
6550
  if (this.view) {
6520
6551
  this.stopAutoLayout();
6521
- if (this.windowListener) {
6522
- window.removeEventListener("resize", this.windowListener);
6523
- this.windowListener = null;
6524
- }
6552
+ this.stopListenPixelRatio();
6525
6553
  if (!this.unreal) {
6526
6554
  const view = this.view;
6527
6555
  if (view.parentElement) view.remove();
@@ -6925,7 +6953,7 @@ var LeaferUI = function(exports) {
6925
6953
  this.times = 0;
6926
6954
  this.config = {
6927
6955
  usePartRender: true,
6928
- maxFPS: 60
6956
+ maxFPS: 120
6929
6957
  };
6930
6958
  this.target = target;
6931
6959
  this.canvas = canvas;
@@ -7080,11 +7108,15 @@ var LeaferUI = function(exports) {
7080
7108
  if (this.requestTime || !target) return;
7081
7109
  if (target.parentApp) return target.parentApp.requestRender(false);
7082
7110
  const requestTime = this.requestTime = Date.now();
7083
- Platform.requestRender(() => {
7084
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7111
+ const render = () => {
7112
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7113
+ const {maxFPS: maxFPS} = this.config;
7114
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7115
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7085
7116
  this.requestTime = 0;
7086
7117
  this.checkRender();
7087
- });
7118
+ };
7119
+ Platform.requestRender(render);
7088
7120
  }
7089
7121
  __onResize(e) {
7090
7122
  if (this.canvas.unreal) return;
@@ -7127,7 +7159,8 @@ var LeaferUI = function(exports) {
7127
7159
  if (this.target) {
7128
7160
  this.stop();
7129
7161
  this.__removeListenEvents();
7130
- this.target = this.canvas = this.config = null;
7162
+ this.config = {};
7163
+ this.target = this.canvas = null;
7131
7164
  }
7132
7165
  }
7133
7166
  }
@@ -7404,7 +7437,11 @@ var LeaferUI = function(exports) {
7404
7437
  }
7405
7438
  }
7406
7439
  class FrameData extends BoxData {}
7407
- class LineData extends UIData {}
7440
+ class LineData extends UIData {
7441
+ get __usePathBox() {
7442
+ return this.points || this.__pathInputed;
7443
+ }
7444
+ }
7408
7445
  class RectData extends UIData {
7409
7446
  get __boxStroke() {
7410
7447
  return !this.__pathInputed;
@@ -7415,7 +7452,7 @@ var LeaferUI = function(exports) {
7415
7452
  return !this.__pathInputed;
7416
7453
  }
7417
7454
  }
7418
- class PolygonData extends UIData {}
7455
+ class PolygonData extends LineData {}
7419
7456
  class StarData extends UIData {}
7420
7457
  class PathData extends UIData {
7421
7458
  get __pathInputed() {
@@ -7454,8 +7491,6 @@ var LeaferUI = function(exports) {
7454
7491
  if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
7455
7492
  box.set(value);
7456
7493
  if (boxLayout.strokeChanged) layout.strokeChange();
7457
- if (boxLayout.renderChanged) layout.renderChange();
7458
- box.__updateChange();
7459
7494
  } else if (box) {
7460
7495
  t.__box = box.parent = null;
7461
7496
  box.destroy();
@@ -7522,7 +7557,7 @@ var LeaferUI = function(exports) {
7522
7557
  __updateRenderSpread() {
7523
7558
  let width = 0;
7524
7559
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7525
- 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));
7560
+ if (shadow) width = Effect.getShadowSpread(this, shadow);
7526
7561
  if (blur) width = Math.max(width, blur);
7527
7562
  if (filter) width += Filter.getSpread(filter);
7528
7563
  if (renderSpread) width += renderSpread;
@@ -7534,36 +7569,67 @@ var LeaferUI = function(exports) {
7534
7569
  return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7535
7570
  }
7536
7571
  };
7572
+ const {float: float} = MathHelper;
7573
+ const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
7537
7574
  const DragBoundsHelper = {
7575
+ limitMove(leaf, move) {
7576
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7577
+ if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
7578
+ D.axisMove(leaf, move);
7579
+ },
7580
+ limitScaleOf(leaf, origin, scale) {
7581
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7582
+ if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
7583
+ },
7584
+ axisMove(leaf, move) {
7585
+ const {draggable: draggable} = leaf;
7586
+ if (draggable === "x") move.y = 0;
7587
+ if (draggable === "y") move.x = 0;
7588
+ },
7589
+ getDragBounds(leaf) {
7590
+ const {dragBounds: dragBounds} = leaf;
7591
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
7592
+ },
7593
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
7594
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
7595
+ },
7538
7596
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
7539
7597
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
7540
7598
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
7541
7599
  if (!change) move = Object.assign({}, move);
7542
- const isBiggerWidth = content.width > dragBounds.width;
7543
- const isBiggerHeight = content.height > dragBounds.height;
7544
- if (isBiggerWidth && dragBoundsType !== "outer") {
7600
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7545
7601
  if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
7546
7602
  } else {
7547
7603
  if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
7548
7604
  }
7549
- if (isBiggerHeight && dragBoundsType !== "outer") {
7605
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7550
7606
  if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
7551
7607
  } else {
7552
7608
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
7553
7609
  }
7554
- move.x = MathHelper.float(move.x);
7555
- move.y = MathHelper.float(move.y);
7610
+ move.x = float(move.x);
7611
+ move.y = float(move.y);
7556
7612
  return move;
7557
7613
  },
7558
- axisMove(leaf, move) {
7559
- const {draggable: draggable} = leaf;
7560
- if (draggable === "x") move.y = 0;
7561
- if (draggable === "y") move.x = 0;
7562
- },
7563
- limitMove(leaf, move) {
7564
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7565
- if (dragBounds) D.getValidMove(leaf.__localBoxBounds, dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds, dragBoundsType, move, true);
7566
- D.axisMove(leaf, move);
7614
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
7615
+ if (!change) scale = Object.assign({}, scale);
7616
+ let fitScaleX, fitScaleY;
7617
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
7618
+ tempMerge.set(tempContent).add(dragBounds);
7619
+ tempIntersect.set(tempContent).intersect(dragBounds);
7620
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7621
+ fitScaleX = tempMerge.width / tempContent.width;
7622
+ } else {
7623
+ fitScaleX = tempIntersect.width / tempContent.width;
7624
+ }
7625
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7626
+ fitScaleY = tempMerge.height / tempContent.height;
7627
+ } else {
7628
+ fitScaleY = tempIntersect.height / tempContent.height;
7629
+ }
7630
+ scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
7631
+ scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
7632
+ return scale;
7567
7633
  }
7568
7634
  };
7569
7635
  const D = DragBoundsHelper;
@@ -7578,7 +7644,7 @@ var LeaferUI = function(exports) {
7578
7644
  }
7579
7645
  if (data.__useEffect) {
7580
7646
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7581
- 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"));
7647
+ 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"));
7582
7648
  data.__useEffect = !!(shadow || otherEffect);
7583
7649
  }
7584
7650
  data.__checkSingle();
@@ -7709,20 +7775,9 @@ var LeaferUI = function(exports) {
7709
7775
  if (!path) this.__drawPathByBox(pen);
7710
7776
  return pen;
7711
7777
  }
7712
- constructor(data) {
7713
- super(data);
7714
- }
7715
7778
  reset(_data) {}
7716
- set(data, transition) {
7717
- if (data) {
7718
- if (transition) {
7719
- if (transition === "temp") {
7720
- this.lockNormalStyle = true;
7721
- Object.assign(this, data);
7722
- this.lockNormalStyle = false;
7723
- } else this.animate(data, transition);
7724
- } else Object.assign(this, data);
7725
- }
7779
+ set(data, _transition) {
7780
+ if (data) Object.assign(this, data);
7726
7781
  }
7727
7782
  get(name) {
7728
7783
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -7768,7 +7823,7 @@ var LeaferUI = function(exports) {
7768
7823
  const data = this.__;
7769
7824
  if (data.path) {
7770
7825
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
7771
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
7826
+ if (data.__useArrow) PathArrow.addArrows(this);
7772
7827
  } else data.__pathForRender && (data.__pathForRender = undefined);
7773
7828
  }
7774
7829
  __drawRenderPath(canvas) {
@@ -7792,7 +7847,8 @@ var LeaferUI = function(exports) {
7792
7847
  drawImagePlaceholder(canvas, _image) {
7793
7848
  Paint.fill(this.__.placeholderColor, this, canvas);
7794
7849
  }
7795
- animate(_keyframe, _options, _type, _isTemp) {
7850
+ animate(keyframe, _options, _type, _isTemp) {
7851
+ this.set(keyframe);
7796
7852
  return Plugin.need("animate");
7797
7853
  }
7798
7854
  killAnimate(_type, _nextStyle) {}
@@ -7906,9 +7962,6 @@ var LeaferUI = function(exports) {
7906
7962
  get isBranch() {
7907
7963
  return true;
7908
7964
  }
7909
- constructor(data) {
7910
- super(data);
7911
- }
7912
7965
  reset(data) {
7913
7966
  this.__setBranch();
7914
7967
  super.reset(data);
@@ -8026,7 +8079,7 @@ var LeaferUI = function(exports) {
8026
8079
  const canvas = this.canvas = Creator.canvas(config);
8027
8080
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8028
8081
  if (this.isApp) this.__setApp();
8029
- this.__checkAutoLayout(config, parentApp);
8082
+ this.__checkAutoLayout();
8030
8083
  this.view = canvas.view;
8031
8084
  if (!parentApp) {
8032
8085
  this.selector = Creator.selector(this);
@@ -8125,7 +8178,8 @@ var LeaferUI = function(exports) {
8125
8178
  this.leafer = leafer;
8126
8179
  this.__level = 1;
8127
8180
  }
8128
- __checkAutoLayout(config, parentApp) {
8181
+ __checkAutoLayout() {
8182
+ const {config: config, parentApp: parentApp} = this;
8129
8183
  if (!parentApp) {
8130
8184
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8131
8185
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8142,7 +8196,9 @@ var LeaferUI = function(exports) {
8142
8196
  } else if (attrName === "zIndex") {
8143
8197
  this.canvas.zIndex = newValue;
8144
8198
  setTimeout(() => this.parent && this.parent.__updateSortChildren());
8145
- }
8199
+ } else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
8200
+ mode: newValue
8201
+ });
8146
8202
  }
8147
8203
  return super.__setAttr(attrName, newValue);
8148
8204
  }
@@ -8151,9 +8207,10 @@ var LeaferUI = function(exports) {
8151
8207
  return super.__getAttr(attrName);
8152
8208
  }
8153
8209
  __changeCanvasSize(attrName, newValue) {
8154
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8155
- data[attrName] = this.config[attrName] = newValue;
8156
- if (newValue) this.canvas.stopAutoLayout();
8210
+ const {config: config, canvas: canvas} = this;
8211
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8212
+ data[attrName] = config[attrName] = newValue;
8213
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8157
8214
  this.__doResize(data);
8158
8215
  }
8159
8216
  __changeFill(newValue) {
@@ -8300,9 +8357,9 @@ var LeaferUI = function(exports) {
8300
8357
  if (!this.parent) {
8301
8358
  if (this.selector) this.selector.destroy();
8302
8359
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
8303
- this.canvasManager.destroy();
8360
+ if (this.canvasManager) this.canvasManager.destroy();
8304
8361
  }
8305
- this.canvas.destroy();
8362
+ if (this.canvas) this.canvas.destroy();
8306
8363
  this.config.view = this.view = this.parentApp = null;
8307
8364
  if (this.userConfig) this.userConfig.view = null;
8308
8365
  super.destroy();
@@ -8320,14 +8377,12 @@ var LeaferUI = function(exports) {
8320
8377
  exports.Leafer.list = new LeafList;
8321
8378
  __decorate([ dataProcessor(LeaferData) ], exports.Leafer.prototype, "__", void 0);
8322
8379
  __decorate([ boundsType() ], exports.Leafer.prototype, "pixelRatio", void 0);
8380
+ __decorate([ dataType("normal") ], exports.Leafer.prototype, "mode", void 0);
8323
8381
  exports.Leafer = Leafer_1 = __decorate([ registerUI() ], exports.Leafer);
8324
8382
  exports.Rect = class Rect extends exports.UI {
8325
8383
  get __tag() {
8326
8384
  return "Rect";
8327
8385
  }
8328
- constructor(data) {
8329
- super(data);
8330
- }
8331
8386
  };
8332
8387
  __decorate([ dataProcessor(RectData) ], exports.Rect.prototype, "__", void 0);
8333
8388
  exports.Rect = __decorate([ useModule(RectRender), rewriteAble(), registerUI() ], exports.Rect);
@@ -8439,9 +8494,6 @@ var LeaferUI = function(exports) {
8439
8494
  get isFrame() {
8440
8495
  return true;
8441
8496
  }
8442
- constructor(data) {
8443
- super(data);
8444
- }
8445
8497
  };
8446
8498
  __decorate([ dataProcessor(FrameData) ], exports.Frame.prototype, "__", void 0);
8447
8499
  __decorate([ surfaceType("#FFFFFF") ], exports.Frame.prototype, "fill", void 0);
@@ -8452,9 +8504,6 @@ var LeaferUI = function(exports) {
8452
8504
  get __tag() {
8453
8505
  return "Ellipse";
8454
8506
  }
8455
- constructor(data) {
8456
- super(data);
8457
- }
8458
8507
  __updatePath() {
8459
8508
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
8460
8509
  const rx = width / 2, ry = height / 2;
@@ -8488,108 +8537,46 @@ var LeaferUI = function(exports) {
8488
8537
  __decorate([ pathType(0) ], exports.Ellipse.prototype, "startAngle", void 0);
8489
8538
  __decorate([ pathType(0) ], exports.Ellipse.prototype, "endAngle", void 0);
8490
8539
  exports.Ellipse = __decorate([ registerUI() ], exports.Ellipse);
8491
- const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
8492
- const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8493
- const {toBounds: toBounds} = PathBounds;
8494
- exports.Line = class Line extends exports.UI {
8495
- get __tag() {
8496
- return "Line";
8497
- }
8498
- get toPoint() {
8499
- const {width: width, rotation: rotation} = this.__;
8500
- const to = getPointData();
8501
- if (width) to.x = width;
8502
- if (rotation) rotate$1(to, rotation);
8503
- return to;
8504
- }
8505
- set toPoint(value) {
8506
- this.width = getDistance$2(defaultPoint, value);
8507
- this.rotation = getAngle$1(defaultPoint, value);
8508
- if (this.height) this.height = 0;
8509
- }
8510
- constructor(data) {
8511
- super(data);
8512
- }
8513
- __updatePath() {
8514
- const data = this.__;
8515
- const path = data.path = [];
8516
- if (data.points) {
8517
- drawPoints$1(path, data.points, false, data.closed);
8518
- } else {
8519
- moveTo$2(path, 0, 0);
8520
- lineTo$2(path, this.width, 0);
8521
- }
8522
- }
8523
- __updateRenderPath() {
8524
- const data = this.__;
8525
- if (!this.pathInputed && data.points && data.curve) {
8526
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
8527
- if (data.__useArrow) PathArrow.addArrows(this, false);
8528
- } else super.__updateRenderPath();
8529
- }
8530
- __updateBoxBounds() {
8531
- if (this.points) {
8532
- toBounds(this.__.__pathForRender, this.__layout.boxBounds);
8533
- } else super.__updateBoxBounds();
8534
- }
8535
- };
8536
- __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8537
- __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
8538
- __decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
8539
- __decorate([ pathType() ], exports.Line.prototype, "points", void 0);
8540
- __decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
8541
- __decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
8542
- exports.Line = __decorate([ registerUI() ], exports.Line);
8543
8540
  const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
8544
- const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = PathCommandDataHelper;
8545
- const line = exports.Line.prototype;
8541
+ const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
8546
8542
  exports.Polygon = class Polygon extends exports.UI {
8547
8543
  get __tag() {
8548
8544
  return "Polygon";
8549
8545
  }
8550
- constructor(data) {
8551
- super(data);
8552
- }
8553
8546
  __updatePath() {
8554
- const path = this.__.path = [];
8555
- if (this.__.points) {
8556
- drawPoints(path, this.__.points, false, true);
8547
+ const data = this.__;
8548
+ const path = data.path = [];
8549
+ if (data.points) {
8550
+ drawPoints$1(path, data.points, data.curve, true);
8557
8551
  } else {
8558
- const {width: width, height: height, sides: sides} = this.__;
8552
+ const {width: width, height: height, sides: sides} = data;
8559
8553
  const rx = width / 2, ry = height / 2;
8560
- moveTo$1(path, rx, 0);
8554
+ moveTo$2(path, rx, 0);
8561
8555
  for (let i = 1; i < sides; i++) {
8562
- lineTo$1(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
8556
+ lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
8563
8557
  }
8564
8558
  closePath$1(path);
8565
8559
  }
8566
8560
  }
8567
- __updateRenderPath() {}
8568
- __updateBoxBounds() {}
8569
8561
  };
8570
8562
  __decorate([ dataProcessor(PolygonData) ], exports.Polygon.prototype, "__", void 0);
8571
8563
  __decorate([ pathType(3) ], exports.Polygon.prototype, "sides", void 0);
8572
8564
  __decorate([ pathType() ], exports.Polygon.prototype, "points", void 0);
8573
8565
  __decorate([ pathType(0) ], exports.Polygon.prototype, "curve", void 0);
8574
- __decorate([ rewrite(line.__updateRenderPath) ], exports.Polygon.prototype, "__updateRenderPath", null);
8575
- __decorate([ rewrite(line.__updateBoxBounds) ], exports.Polygon.prototype, "__updateBoxBounds", null);
8576
8566
  exports.Polygon = __decorate([ rewriteAble(), registerUI() ], exports.Polygon);
8577
8567
  const {sin: sin, cos: cos, PI: PI} = Math;
8578
- const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
8568
+ const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
8579
8569
  exports.Star = class Star extends exports.UI {
8580
8570
  get __tag() {
8581
8571
  return "Star";
8582
8572
  }
8583
- constructor(data) {
8584
- super(data);
8585
- }
8586
8573
  __updatePath() {
8587
8574
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
8588
8575
  const rx = width / 2, ry = height / 2;
8589
8576
  const path = this.__.path = [];
8590
- moveTo(path, rx, 0);
8577
+ moveTo$1(path, rx, 0);
8591
8578
  for (let i = 1; i < corners * 2; i++) {
8592
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
8579
+ 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));
8593
8580
  }
8594
8581
  closePath(path);
8595
8582
  }
@@ -8598,6 +8585,42 @@ var LeaferUI = function(exports) {
8598
8585
  __decorate([ pathType(5) ], exports.Star.prototype, "corners", void 0);
8599
8586
  __decorate([ pathType(.382) ], exports.Star.prototype, "innerRadius", void 0);
8600
8587
  exports.Star = __decorate([ registerUI() ], exports.Star);
8588
+ const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
8589
+ const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8590
+ exports.Line = class Line extends exports.UI {
8591
+ get __tag() {
8592
+ return "Line";
8593
+ }
8594
+ get toPoint() {
8595
+ const {width: width, rotation: rotation} = this.__;
8596
+ const to = getPointData();
8597
+ if (width) to.x = width;
8598
+ if (rotation) rotate$1(to, rotation);
8599
+ return to;
8600
+ }
8601
+ set toPoint(value) {
8602
+ this.width = getDistance$2(defaultPoint, value);
8603
+ this.rotation = getAngle$1(defaultPoint, value);
8604
+ if (this.height) this.height = 0;
8605
+ }
8606
+ __updatePath() {
8607
+ const data = this.__;
8608
+ const path = data.path = [];
8609
+ if (data.points) {
8610
+ drawPoints(path, data.points, data.curve, data.closed);
8611
+ } else {
8612
+ moveTo(path, 0, 0);
8613
+ lineTo(path, this.width, 0);
8614
+ }
8615
+ }
8616
+ };
8617
+ __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8618
+ __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
8619
+ __decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
8620
+ __decorate([ pathType() ], exports.Line.prototype, "points", void 0);
8621
+ __decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
8622
+ __decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
8623
+ exports.Line = __decorate([ registerUI() ], exports.Line);
8601
8624
  exports.Image = class Image extends exports.Rect {
8602
8625
  get __tag() {
8603
8626
  return "Image";
@@ -8610,9 +8633,6 @@ var LeaferUI = function(exports) {
8610
8633
  const {fill: fill} = this.__;
8611
8634
  return isArray(fill) && fill[0].image;
8612
8635
  }
8613
- constructor(data) {
8614
- super(data);
8615
- }
8616
8636
  };
8617
8637
  __decorate([ dataProcessor(ImageData) ], exports.Image.prototype, "__", void 0);
8618
8638
  __decorate([ boundsType("") ], exports.Image.prototype, "url", void 0);
@@ -8697,9 +8717,6 @@ var LeaferUI = function(exports) {
8697
8717
  this.updateLayout();
8698
8718
  return this.__.__textDrawData;
8699
8719
  }
8700
- constructor(data) {
8701
- super(data);
8702
- }
8703
8720
  __updateTextDrawData() {
8704
8721
  const data = this.__;
8705
8722
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -8736,10 +8753,6 @@ var LeaferUI = function(exports) {
8736
8753
  DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
8737
8754
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
8738
8755
  }
8739
- __onUpdateSize() {
8740
- if (this.__box) this.__box.__onUpdateSize();
8741
- super.__onUpdateSize();
8742
- }
8743
8756
  __updateRenderSpread() {
8744
8757
  let width = super.__updateRenderSpread();
8745
8758
  if (!width) width = this.isOverflow ? 1 : 0;
@@ -8750,6 +8763,11 @@ var LeaferUI = function(exports) {
8750
8763
  copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
8751
8764
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
8752
8765
  }
8766
+ __updateChange() {
8767
+ super.__updateChange();
8768
+ const box = this.__box;
8769
+ if (box) box.__onUpdateSize(), box.__updateChange();
8770
+ }
8753
8771
  __drawRenderPath(canvas) {
8754
8772
  canvas.font = this.__.__font;
8755
8773
  }
@@ -8803,9 +8821,6 @@ var LeaferUI = function(exports) {
8803
8821
  get __tag() {
8804
8822
  return "Path";
8805
8823
  }
8806
- constructor(data) {
8807
- super(data);
8808
- }
8809
8824
  };
8810
8825
  __decorate([ dataProcessor(PathData) ], exports.Path.prototype, "__", void 0);
8811
8826
  __decorate([ affectStrokeBoundsType("center") ], exports.Path.prototype, "strokeAlign", void 0);
@@ -8814,9 +8829,6 @@ var LeaferUI = function(exports) {
8814
8829
  get __tag() {
8815
8830
  return "Pen";
8816
8831
  }
8817
- constructor(data) {
8818
- super(data);
8819
- }
8820
8832
  setStyle(data) {
8821
8833
  const path = this.pathElement = new exports.Path(data);
8822
8834
  this.pathStyle = data;
@@ -9462,7 +9474,7 @@ var LeaferUI = function(exports) {
9462
9474
  if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
9463
9475
  }
9464
9476
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
9465
- const {floor: floor, max: max, abs: abs} = Math;
9477
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
9466
9478
  function createPattern(ui, paint, pixelRatio) {
9467
9479
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
9468
9480
  const id = scaleX + "-" + scaleY + "-" + pixelRatio;
@@ -9471,8 +9483,6 @@ var LeaferUI = function(exports) {
9471
9483
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
9472
9484
  scaleX *= pixelRatio;
9473
9485
  scaleY *= pixelRatio;
9474
- const xGap = gap && gap.x * scaleX;
9475
- const yGap = gap && gap.y * scaleY;
9476
9486
  if (sx) {
9477
9487
  sx = abs(sx);
9478
9488
  sy = abs(sy);
@@ -9489,7 +9499,10 @@ var LeaferUI = function(exports) {
9489
9499
  if (size > Platform.image.maxCacheSize) return false;
9490
9500
  }
9491
9501
  let maxSize = Platform.image.maxPatternSize;
9492
- if (!image.isSVG) {
9502
+ if (image.isSVG) {
9503
+ const ws = width / image.width;
9504
+ if (ws > 1) imageScale = ws / ceil(ws);
9505
+ } else {
9493
9506
  const imageSize = image.width * image.height;
9494
9507
  if (maxSize > imageSize) maxSize = imageSize;
9495
9508
  }
@@ -9504,18 +9517,20 @@ var LeaferUI = function(exports) {
9504
9517
  scaleX /= sx;
9505
9518
  scaleY /= sy;
9506
9519
  }
9520
+ const xGap = gap && gap.x * scaleX;
9521
+ const yGap = gap && gap.y * scaleY;
9507
9522
  if (transform || scaleX !== 1 || scaleY !== 1) {
9523
+ const canvasWidth = width + (xGap || 0);
9524
+ const canvasHeight = height + (yGap || 0);
9525
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
9526
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
9508
9527
  if (!imageMatrix) {
9509
9528
  imageMatrix = get$1();
9510
9529
  if (transform) copy$1(imageMatrix, transform);
9511
9530
  }
9512
9531
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
9513
9532
  }
9514
- if (imageMatrix) {
9515
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
9516
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
9517
- }
9518
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
9533
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
9519
9534
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
9520
9535
  paint.style = pattern;
9521
9536
  paint.patternId = id;
@@ -9731,11 +9746,16 @@ var LeaferUI = function(exports) {
9731
9746
  }
9732
9747
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
9733
9748
  }
9734
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9749
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9735
9750
  if (end && index < end) other.clearWorld(copyBounds);
9736
9751
  });
9737
9752
  other.recycle(copyBounds);
9738
9753
  }
9754
+ function getShadowSpread(_ui, shadow) {
9755
+ let width = 0;
9756
+ 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));
9757
+ return width;
9758
+ }
9739
9759
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
9740
9760
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
9741
9761
  if (Platform.fullImageShadow) {
@@ -9807,7 +9827,11 @@ var LeaferUI = function(exports) {
9807
9827
  shadow: shadow,
9808
9828
  innerShadow: innerShadow,
9809
9829
  blur: blur,
9810
- backgroundBlur: backgroundBlur
9830
+ backgroundBlur: backgroundBlur,
9831
+ getShadowSpread: getShadowSpread,
9832
+ isTransformShadow(_shadow) {
9833
+ return undefined;
9834
+ }
9811
9835
  };
9812
9836
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
9813
9837
  let usedGrayscaleAlpha;
@@ -10263,16 +10287,17 @@ var LeaferUI = function(exports) {
10263
10287
  row.data = null;
10264
10288
  }
10265
10289
  function decorationText(drawData, style) {
10266
- let type;
10290
+ let type, offset = 0;
10267
10291
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
10268
10292
  drawData.decorationHeight = fontSize / 11;
10269
10293
  if (isObject(textDecoration)) {
10270
10294
  type = textDecoration.type;
10271
10295
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
10296
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
10272
10297
  } else type = textDecoration;
10273
10298
  switch (type) {
10274
10299
  case "under":
10275
- drawData.decorationY = [ fontSize * .15 ];
10300
+ drawData.decorationY = [ fontSize * .15 + offset ];
10276
10301
  break;
10277
10302
 
10278
10303
  case "delete":
@@ -10280,7 +10305,7 @@ var LeaferUI = function(exports) {
10280
10305
  break;
10281
10306
 
10282
10307
  case "under-delete":
10283
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
10308
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
10284
10309
  }
10285
10310
  }
10286
10311
  const {top: top, right: right, bottom: bottom, left: left} = exports.Direction4;
@@ -10511,6 +10536,7 @@ var LeaferUI = function(exports) {
10511
10536
  exports.maskType = maskType;
10512
10537
  exports.naturalBoundsType = naturalBoundsType;
10513
10538
  exports.opacityType = opacityType;
10539
+ exports.path = path;
10514
10540
  exports.pathInputType = pathInputType;
10515
10541
  exports.pathType = pathType;
10516
10542
  exports.pen = pen;