@leafer-draw/worker 1.9.3 → 1.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,7 +54,7 @@ function isUndefined(value) {
54
54
  }
55
55
 
56
56
  function isNull(value) {
57
- return value === undefined || value === null;
57
+ return value == null;
58
58
  }
59
59
 
60
60
  function isString(value) {
@@ -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;
@@ -304,6 +307,9 @@ const MathHelper = {
304
307
  num = round$3(num * a) / a;
305
308
  return num === -0 ? 0 : num;
306
309
  },
310
+ sign(num) {
311
+ return num < 0 ? -1 : 1;
312
+ },
307
313
  getScaleData(scale, size, originSize, scaleData) {
308
314
  if (!scaleData) scaleData = {};
309
315
  if (size) {
@@ -1131,13 +1137,13 @@ const AlignHelper = {
1131
1137
  }
1132
1138
  };
1133
1139
 
1134
- 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;
1135
1141
 
1136
1142
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1137
1143
 
1138
1144
  const {float: float, fourNumber: fourNumber} = MathHelper;
1139
1145
 
1140
- const {floor: floor$2, ceil: ceil$1} = Math;
1146
+ const {floor: floor$2, ceil: ceil$2} = Math;
1141
1147
 
1142
1148
  let right$1, bottom$1, boundsRight, boundsBottom;
1143
1149
 
@@ -1266,7 +1272,7 @@ const BoundsHelper = {
1266
1272
  point.x = t.x;
1267
1273
  toOuterPoint$2(matrix, point, toPoint$4);
1268
1274
  addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
1269
- toBounds$3(tempPointBounds$1, to);
1275
+ toBounds$2(tempPointBounds$1, to);
1270
1276
  }
1271
1277
  },
1272
1278
  toInnerOf(t, matrix, to) {
@@ -1304,8 +1310,8 @@ const BoundsHelper = {
1304
1310
  const {x: x, y: y} = t;
1305
1311
  t.x = floor$2(t.x);
1306
1312
  t.y = floor$2(t.y);
1307
- t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
1308
- 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);
1309
1315
  },
1310
1316
  unsign(t) {
1311
1317
  if (t.width < 0) {
@@ -1365,7 +1371,7 @@ const BoundsHelper = {
1365
1371
  },
1366
1372
  setPoints(t, points) {
1367
1373
  points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
1368
- toBounds$3(tempPointBounds$1, t);
1374
+ toBounds$2(tempPointBounds$1, t);
1369
1375
  },
1370
1376
  setPoint(t, point) {
1371
1377
  B.set(t, point.x, point.y);
@@ -2218,15 +2224,15 @@ class LeaferCanvasBase extends Canvas$1 {
2218
2224
  DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2219
2225
  canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2220
2226
  this.bounds = new Bounds(0, 0, this.width, this.height);
2221
- if (this.context && !this.unreal) {
2222
- this.updateViewSize();
2223
- this.smooth = this.config.smooth;
2224
- }
2227
+ this.updateViewSize();
2225
2228
  this.updateClientBounds();
2226
- if (this.context && !this.unreal && takeCanvas) {
2227
- this.clearWorld(takeCanvas.bounds);
2228
- this.copyWorld(takeCanvas);
2229
- 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
+ }
2230
2236
  }
2231
2237
  }
2232
2238
  updateViewSize() {}
@@ -2540,7 +2546,7 @@ const RectHelper = {
2540
2546
  }
2541
2547
  };
2542
2548
 
2543
- 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;
2544
2550
 
2545
2551
  const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
2546
2552
 
@@ -2611,9 +2617,11 @@ const BezierHelper = {
2611
2617
  const CBy = toY - y1;
2612
2618
  let startRadian = atan2$1(BAy, BAx);
2613
2619
  let endRadian = atan2$1(CBy, CBx);
2620
+ const lenBA = hypot(BAx, BAy);
2621
+ const lenCB = hypot(CBx, CBy);
2614
2622
  let totalRadian = endRadian - startRadian;
2615
2623
  if (totalRadian < 0) totalRadian += PI2;
2616
- 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) {
2617
2625
  if (data) data.push(L$6, x1, y1);
2618
2626
  if (setPointBounds) {
2619
2627
  setPoint$1(setPointBounds, fromX, fromY);
@@ -2646,7 +2654,7 @@ const BezierHelper = {
2646
2654
  let totalRadian = endRadian - startRadian;
2647
2655
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2648
2656
  if (anticlockwise) totalRadian -= PI2;
2649
- const parts = ceil(abs$2(totalRadian / PI_2));
2657
+ const parts = ceil$1(abs$2(totalRadian / PI_2));
2650
2658
  const partRadian = totalRadian / parts;
2651
2659
  const partRadian4Sin = sin$3(partRadian / 4);
2652
2660
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -3205,11 +3213,7 @@ class PathCreator {
3205
3213
  this.set(path);
3206
3214
  }
3207
3215
  set(path) {
3208
- if (path) {
3209
- this.__path = isString(path) ? PathHelper.parse(path) : path;
3210
- } else {
3211
- this.__path = [];
3212
- }
3216
+ this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
3213
3217
  return this;
3214
3218
  }
3215
3219
  beginPath() {
@@ -3377,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:
3377
3381
 
3378
3382
  const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
3379
3383
 
3380
- 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;
3381
3385
 
3382
3386
  const debug$9 = Debug.get("PathBounds");
3383
3387
 
@@ -3392,7 +3396,7 @@ const setEndPoint = {};
3392
3396
  const PathBounds = {
3393
3397
  toBounds(data, setBounds) {
3394
3398
  PathBounds.toTwoPointBounds(data, setPointBounds);
3395
- toBounds$2(setPointBounds, setBounds);
3399
+ toBounds$1(setPointBounds, setBounds);
3396
3400
  },
3397
3401
  toTwoPointBounds(data, setPointBounds) {
3398
3402
  if (!data || !data.length) return setPoint(setPointBounds, 0, 0);
@@ -3579,14 +3583,18 @@ const PathCorner = {
3579
3583
  }
3580
3584
  };
3581
3585
 
3582
- PathHelper.creator = new PathCreator;
3586
+ function path(path) {
3587
+ return new PathCreator(path);
3588
+ }
3589
+
3590
+ const pen = path();
3591
+
3592
+ PathHelper.creator = path();
3583
3593
 
3584
3594
  PathHelper.parse = PathConvert.parse;
3585
3595
 
3586
3596
  PathHelper.convertToCanvasData = PathConvert.toCanvasData;
3587
3597
 
3588
- const pen = new PathCreator;
3589
-
3590
3598
  const {drawRoundRect: drawRoundRect} = RectHelper;
3591
3599
 
3592
3600
  function roundRect(drawer) {
@@ -3951,7 +3959,7 @@ const ImageManager = {
3951
3959
  return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
3952
3960
  },
3953
3961
  isFormat(format, config) {
3954
- if (config.format === format) return true;
3962
+ if (config.format) return config.format === format;
3955
3963
  const {url: url} = config;
3956
3964
  if (url.startsWith("data:")) {
3957
3965
  if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
@@ -4045,7 +4053,7 @@ class LeaferImage {
4045
4053
  getFull(_filters) {
4046
4054
  return this.view;
4047
4055
  }
4048
- getCanvas(width, height, opacity, _filters, xGap, yGap) {
4056
+ getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
4049
4057
  width || (width = this.width);
4050
4058
  height || (height = this.height);
4051
4059
  if (this.cache) {
@@ -4061,6 +4069,7 @@ class LeaferImage {
4061
4069
  const canvas = Platform.origin.createCanvas(max$1(floor$1(width + (xGap || 0)), 1), max$1(floor$1(height + (yGap || 0)), 1));
4062
4070
  const ctx = canvas.getContext("2d");
4063
4071
  if (opacity) ctx.globalAlpha = opacity;
4072
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
4064
4073
  ctx.drawImage(this.view, 0, 0, width, height);
4065
4074
  this.cache = this.use > 1 ? {
4066
4075
  data: canvas,
@@ -4102,7 +4111,7 @@ function createDescriptor(key, defaultValue) {
4102
4111
  return {
4103
4112
  get() {
4104
4113
  const v = this[privateKey];
4105
- return isUndefined(v) ? defaultValue : v;
4114
+ return v == null ? defaultValue : v;
4106
4115
  },
4107
4116
  set(value) {
4108
4117
  this[privateKey] = value;
@@ -4388,21 +4397,21 @@ function defineDataProcessor(target, key, defaultValue) {
4388
4397
  };
4389
4398
  } else if (typeof defaultValue === "function") {
4390
4399
  property.get = function() {
4391
- let v = this[computedKey];
4392
- return v === undefined ? defaultValue(this.__leaf) : v;
4400
+ const v = this[computedKey];
4401
+ return v == null ? defaultValue(this.__leaf) : v;
4393
4402
  };
4394
4403
  } else if (isObject(defaultValue)) {
4395
4404
  const isEmpty = isEmptyData(defaultValue);
4396
4405
  property.get = function() {
4397
- let v = this[computedKey];
4398
- return v === undefined ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4406
+ const v = this[computedKey];
4407
+ return v == null ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4399
4408
  };
4400
4409
  }
4401
4410
  const isBox = target.isBranchLeaf;
4402
4411
  if (key === "width") {
4403
4412
  property.get = function() {
4404
4413
  const v = this[computedKey];
4405
- if (v === undefined) {
4414
+ if (v == null) {
4406
4415
  const t = this, naturalWidth = t.__naturalWidth, leaf = t.__leaf;
4407
4416
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.width;
4408
4417
  if (naturalWidth) return t._height && t.__useNaturalRatio ? t._height * naturalWidth / t.__naturalHeight : naturalWidth;
@@ -4412,7 +4421,7 @@ function defineDataProcessor(target, key, defaultValue) {
4412
4421
  } else if (key === "height") {
4413
4422
  property.get = function() {
4414
4423
  const v = this[computedKey];
4415
- if (v === undefined) {
4424
+ if (v == null) {
4416
4425
  const t = this, naturalHeight = t.__naturalHeight, leaf = t.__leaf;
4417
4426
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.height;
4418
4427
  if (naturalHeight) return t._width && t.__useNaturalRatio ? t._width * naturalHeight / t.__naturalWidth : naturalHeight;
@@ -4712,8 +4721,9 @@ const L = LeafHelper;
4712
4721
 
4713
4722
  const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L;
4714
4723
 
4715
- function getTempLocal(t, world) {
4716
- 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;
4717
4727
  }
4718
4728
 
4719
4729
  const LeafBoundsHelper = {
@@ -5172,7 +5182,7 @@ class LeafLayout {
5172
5182
  }
5173
5183
  boxChange() {
5174
5184
  this.boxChanged = true;
5175
- this.localBoxChanged || this.localBoxChange();
5185
+ this.localBoxChanged ? this.boundsChanged || (this.boundsChanged = true) : this.localBoxChange();
5176
5186
  this.hitCanvasChanged = true;
5177
5187
  }
5178
5188
  localBoxChange() {
@@ -5206,7 +5216,7 @@ class LeafLayout {
5206
5216
  }
5207
5217
  matrixChange() {
5208
5218
  this.matrixChanged = true;
5209
- this.localBoxChanged || this.localBoxChange();
5219
+ this.localBoxChanged ? this.boundsChanged || (this.boundsChanged = true) : this.localBoxChange();
5210
5220
  }
5211
5221
  surfaceChange() {
5212
5222
  this.surfaceChanged = true;
@@ -5731,7 +5741,7 @@ const {updateBounds: updateBounds$1} = BranchHelper;
5731
5741
 
5732
5742
  const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$3} = BoundsHelper;
5733
5743
 
5734
- const {toBounds: toBounds$1} = PathBounds;
5744
+ const {toBounds: toBounds} = PathBounds;
5735
5745
 
5736
5746
  const LeafBounds = {
5737
5747
  __updateWorldBounds() {
@@ -5803,8 +5813,8 @@ const LeafBounds = {
5803
5813
  __updateBoxBounds(_secondLayout, _bounds) {
5804
5814
  const b = this.__layout.boxBounds;
5805
5815
  const data = this.__;
5806
- if (data.__pathInputed) {
5807
- toBounds$1(data.path, b);
5816
+ if (data.__usePathBox) {
5817
+ toBounds(data.path, b);
5808
5818
  } else {
5809
5819
  b.x = 0;
5810
5820
  b.y = 0;
@@ -6272,10 +6282,10 @@ let Leaf = class Leaf {
6272
6282
  relative.innerToWorld(world, to, distance);
6273
6283
  world = to ? to : world;
6274
6284
  }
6275
- toInnerPoint(this.worldTransform, world, to, distance);
6285
+ toInnerPoint(this.scrollWorldTransform, world, to, distance);
6276
6286
  }
6277
6287
  innerToWorld(inner, to, distance, relative) {
6278
- toOuterPoint(this.worldTransform, inner, to, distance);
6288
+ toOuterPoint(this.scrollWorldTransform, inner, to, distance);
6279
6289
  if (relative) relative.worldToInner(to ? to : inner, null, distance);
6280
6290
  }
6281
6291
  getBoxPoint(world, relative, distance, change) {
@@ -6739,7 +6749,7 @@ class LeafLevelList {
6739
6749
  }
6740
6750
  }
6741
6751
 
6742
- const version = "1.9.3";
6752
+ const version = "1.9.5";
6743
6753
 
6744
6754
  class LeaferCanvas extends LeaferCanvasBase {
6745
6755
  get allowBackgroundColor() {
@@ -7162,7 +7172,7 @@ class Renderer {
7162
7172
  this.times = 0;
7163
7173
  this.config = {
7164
7174
  usePartRender: true,
7165
- maxFPS: 60
7175
+ maxFPS: 120
7166
7176
  };
7167
7177
  this.target = target;
7168
7178
  this.canvas = canvas;
@@ -7317,11 +7327,15 @@ class Renderer {
7317
7327
  if (this.requestTime || !target) return;
7318
7328
  if (target.parentApp) return target.parentApp.requestRender(false);
7319
7329
  const requestTime = this.requestTime = Date.now();
7320
- Platform.requestRender(() => {
7321
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7330
+ const render = () => {
7331
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7332
+ const {maxFPS: maxFPS} = this.config;
7333
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7334
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7322
7335
  this.requestTime = 0;
7323
7336
  this.checkRender();
7324
- });
7337
+ };
7338
+ Platform.requestRender(render);
7325
7339
  }
7326
7340
  __onResize(e) {
7327
7341
  if (this.canvas.unreal) return;
@@ -7364,7 +7378,8 @@ class Renderer {
7364
7378
  if (this.target) {
7365
7379
  this.stop();
7366
7380
  this.__removeListenEvents();
7367
- this.target = this.canvas = this.config = null;
7381
+ this.config = {};
7382
+ this.target = this.canvas = null;
7368
7383
  }
7369
7384
  }
7370
7385
  }
@@ -7672,7 +7687,11 @@ class LeaferData extends GroupData {
7672
7687
 
7673
7688
  class FrameData extends BoxData {}
7674
7689
 
7675
- class LineData extends UIData {}
7690
+ class LineData extends UIData {
7691
+ get __usePathBox() {
7692
+ return this.points || this.__pathInputed;
7693
+ }
7694
+ }
7676
7695
 
7677
7696
  class RectData extends UIData {
7678
7697
  get __boxStroke() {
@@ -7686,7 +7705,7 @@ class EllipseData extends UIData {
7686
7705
  }
7687
7706
  }
7688
7707
 
7689
- class PolygonData extends UIData {}
7708
+ class PolygonData extends LineData {}
7690
7709
 
7691
7710
  class StarData extends UIData {}
7692
7711
 
@@ -7996,20 +8015,9 @@ let UI = UI_1 = class UI extends Leaf {
7996
8015
  if (!path) this.__drawPathByBox(pen);
7997
8016
  return pen;
7998
8017
  }
7999
- constructor(data) {
8000
- super(data);
8001
- }
8002
8018
  reset(_data) {}
8003
- set(data, transition) {
8004
- if (data) {
8005
- if (transition) {
8006
- if (transition === "temp") {
8007
- this.lockNormalStyle = true;
8008
- Object.assign(this, data);
8009
- this.lockNormalStyle = false;
8010
- } else this.animate(data, transition);
8011
- } else Object.assign(this, data);
8012
- }
8019
+ set(data, _transition) {
8020
+ if (data) Object.assign(this, data);
8013
8021
  }
8014
8022
  get(name) {
8015
8023
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -8055,7 +8063,7 @@ let UI = UI_1 = class UI extends Leaf {
8055
8063
  const data = this.__;
8056
8064
  if (data.path) {
8057
8065
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8058
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
8066
+ if (data.__useArrow) PathArrow.addArrows(this);
8059
8067
  } else data.__pathForRender && (data.__pathForRender = undefined);
8060
8068
  }
8061
8069
  __drawRenderPath(canvas) {
@@ -8079,7 +8087,8 @@ let UI = UI_1 = class UI extends Leaf {
8079
8087
  drawImagePlaceholder(canvas, _image) {
8080
8088
  Paint.fill(this.__.placeholderColor, this, canvas);
8081
8089
  }
8082
- animate(_keyframe, _options, _type, _isTemp) {
8090
+ animate(keyframe, _options, _type, _isTemp) {
8091
+ this.set(keyframe);
8083
8092
  return Plugin.need("animate");
8084
8093
  }
8085
8094
  killAnimate(_type, _nextStyle) {}
@@ -8268,9 +8277,6 @@ let Group = class Group extends UI {
8268
8277
  get isBranch() {
8269
8278
  return true;
8270
8279
  }
8271
- constructor(data) {
8272
- super(data);
8273
- }
8274
8280
  reset(data) {
8275
8281
  this.__setBranch();
8276
8282
  super.reset(data);
@@ -8395,7 +8401,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8395
8401
  const canvas = this.canvas = Creator.canvas(config);
8396
8402
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8397
8403
  if (this.isApp) this.__setApp();
8398
- this.__checkAutoLayout(config, parentApp);
8404
+ this.__checkAutoLayout();
8399
8405
  this.view = canvas.view;
8400
8406
  if (!parentApp) {
8401
8407
  this.selector = Creator.selector(this);
@@ -8494,7 +8500,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8494
8500
  this.leafer = leafer;
8495
8501
  this.__level = 1;
8496
8502
  }
8497
- __checkAutoLayout(config, parentApp) {
8503
+ __checkAutoLayout() {
8504
+ const {config: config, parentApp: parentApp} = this;
8498
8505
  if (!parentApp) {
8499
8506
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8500
8507
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8520,9 +8527,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8520
8527
  return super.__getAttr(attrName);
8521
8528
  }
8522
8529
  __changeCanvasSize(attrName, newValue) {
8523
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8524
- data[attrName] = this.config[attrName] = newValue;
8525
- if (newValue) this.canvas.stopAutoLayout();
8530
+ const {config: config, canvas: canvas} = this;
8531
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8532
+ data[attrName] = config[attrName] = newValue;
8533
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8526
8534
  this.__doResize(data);
8527
8535
  }
8528
8536
  __changeFill(newValue) {
@@ -8669,9 +8677,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8669
8677
  if (!this.parent) {
8670
8678
  if (this.selector) this.selector.destroy();
8671
8679
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
8672
- this.canvasManager.destroy();
8680
+ if (this.canvasManager) this.canvasManager.destroy();
8673
8681
  }
8674
- this.canvas.destroy();
8682
+ if (this.canvas) this.canvas.destroy();
8675
8683
  this.config.view = this.view = this.parentApp = null;
8676
8684
  if (this.userConfig) this.userConfig.view = null;
8677
8685
  super.destroy();
@@ -8699,9 +8707,6 @@ let Rect = class Rect extends UI {
8699
8707
  get __tag() {
8700
8708
  return "Rect";
8701
8709
  }
8702
- constructor(data) {
8703
- super(data);
8704
- }
8705
8710
  };
8706
8711
 
8707
8712
  __decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
@@ -8755,29 +8760,24 @@ let Box = class Box extends Group {
8755
8760
  }
8756
8761
  __updateStrokeBounds() {}
8757
8762
  __updateRenderBounds() {
8758
- let isOverflow;
8763
+ let isOverflow, isScrollMode;
8759
8764
  if (this.children.length) {
8760
- const data = this.__, layout = this.__layout, {renderBounds: renderBounds, boxBounds: boxBounds} = layout;
8765
+ const data = this.__, layout = this.__layout, {renderBounds: renderBounds, boxBounds: boxBounds} = layout, {overflow: overflow} = data;
8761
8766
  const childrenRenderBounds = layout.childrenRenderBounds || (layout.childrenRenderBounds = getBoundsData());
8762
8767
  super.__updateRenderBounds(childrenRenderBounds);
8763
- if (data.overflow.includes("scroll")) {
8768
+ if (isScrollMode = overflow.includes("scroll")) {
8764
8769
  add(childrenRenderBounds, boxBounds);
8765
8770
  scroll(childrenRenderBounds, data);
8766
8771
  }
8767
8772
  this.__updateRectRenderBounds();
8768
8773
  isOverflow = !includes$1(boxBounds, childrenRenderBounds);
8769
- if (isOverflow && data.overflow === "show") add(renderBounds, childrenRenderBounds);
8774
+ if (isOverflow && overflow === "show") add(renderBounds, childrenRenderBounds);
8770
8775
  } else this.__updateRectRenderBounds();
8771
8776
  DataHelper.stintSet(this, "isOverflow", isOverflow);
8772
- this.__checkScroll();
8777
+ this.__checkScroll(isScrollMode);
8773
8778
  }
8774
8779
  __updateRectRenderBounds() {}
8775
- __updateWorldBounds() {
8776
- if (this.hasScroller) this.__updateScroll();
8777
- super.__updateWorldBounds();
8778
- }
8779
- __checkScroll() {}
8780
- __updateScroll() {}
8780
+ __checkScroll(_isScrollMode) {}
8781
8781
  __updateRectChange() {}
8782
8782
  __updateChange() {
8783
8783
  super.__updateChange();
@@ -8838,9 +8838,6 @@ let Frame = class Frame extends Box {
8838
8838
  get isFrame() {
8839
8839
  return true;
8840
8840
  }
8841
- constructor(data) {
8842
- super(data);
8843
- }
8844
8841
  };
8845
8842
 
8846
8843
  __decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
@@ -8857,9 +8854,6 @@ let Ellipse = class Ellipse extends UI {
8857
8854
  get __tag() {
8858
8855
  return "Ellipse";
8859
8856
  }
8860
- constructor(data) {
8861
- super(data);
8862
- }
8863
8857
  __updatePath() {
8864
8858
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
8865
8859
  const rx = width / 2, ry = height / 2;
@@ -8903,8 +8897,6 @@ const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathComma
8903
8897
 
8904
8898
  const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8905
8899
 
8906
- const {toBounds: toBounds} = PathBounds;
8907
-
8908
8900
  let Line = class Line extends UI {
8909
8901
  get __tag() {
8910
8902
  return "Line";
@@ -8921,31 +8913,16 @@ let Line = class Line extends UI {
8921
8913
  this.rotation = getAngle$1(defaultPoint, value);
8922
8914
  if (this.height) this.height = 0;
8923
8915
  }
8924
- constructor(data) {
8925
- super(data);
8926
- }
8927
8916
  __updatePath() {
8928
8917
  const data = this.__;
8929
8918
  const path = data.path = [];
8930
8919
  if (data.points) {
8931
- drawPoints$1(path, data.points, false, data.closed);
8920
+ drawPoints$1(path, data.points, data.curve, data.closed);
8932
8921
  } else {
8933
8922
  moveTo$2(path, 0, 0);
8934
8923
  lineTo$2(path, this.width, 0);
8935
8924
  }
8936
8925
  }
8937
- __updateRenderPath() {
8938
- const data = this.__;
8939
- if (!this.pathInputed && data.points && data.curve) {
8940
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
8941
- if (data.__useArrow) PathArrow.addArrows(this, false);
8942
- } else super.__updateRenderPath();
8943
- }
8944
- __updateBoxBounds() {
8945
- if (this.points) {
8946
- toBounds(this.__.__pathForRender, this.__layout.boxBounds);
8947
- } else super.__updateBoxBounds();
8948
- }
8949
8926
  };
8950
8927
 
8951
8928
  __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
@@ -8972,15 +8949,13 @@ let Polygon = class Polygon extends UI {
8972
8949
  get __tag() {
8973
8950
  return "Polygon";
8974
8951
  }
8975
- constructor(data) {
8976
- super(data);
8977
- }
8978
8952
  __updatePath() {
8979
- const path = this.__.path = [];
8980
- if (this.__.points) {
8981
- drawPoints(path, this.__.points, false, true);
8953
+ const data = this.__;
8954
+ const path = data.path = [];
8955
+ if (data.points) {
8956
+ drawPoints(path, data.points, data.curve, true);
8982
8957
  } else {
8983
- const {width: width, height: height, sides: sides} = this.__;
8958
+ const {width: width, height: height, sides: sides} = data;
8984
8959
  const rx = width / 2, ry = height / 2;
8985
8960
  moveTo$1(path, rx, 0);
8986
8961
  for (let i = 1; i < sides; i++) {
@@ -9015,9 +8990,6 @@ let Star = class Star extends UI {
9015
8990
  get __tag() {
9016
8991
  return "Star";
9017
8992
  }
9018
- constructor(data) {
9019
- super(data);
9020
- }
9021
8993
  __updatePath() {
9022
8994
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9023
8995
  const rx = width / 2, ry = height / 2;
@@ -9050,9 +9022,6 @@ let Image = class Image extends Rect {
9050
9022
  const {fill: fill} = this.__;
9051
9023
  return isArray(fill) && fill[0].image;
9052
9024
  }
9053
- constructor(data) {
9054
- super(data);
9055
- }
9056
9025
  };
9057
9026
 
9058
9027
  __decorate([ dataProcessor(ImageData) ], Image.prototype, "__", void 0);
@@ -9152,9 +9121,6 @@ let Text = class Text extends UI {
9152
9121
  this.updateLayout();
9153
9122
  return this.__.__textDrawData;
9154
9123
  }
9155
- constructor(data) {
9156
- super(data);
9157
- }
9158
9124
  __updateTextDrawData() {
9159
9125
  const data = this.__;
9160
9126
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -9287,9 +9253,6 @@ let Path = class Path extends UI {
9287
9253
  get __tag() {
9288
9254
  return "Path";
9289
9255
  }
9290
- constructor(data) {
9291
- super(data);
9292
- }
9293
9256
  };
9294
9257
 
9295
9258
  __decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
@@ -9302,9 +9265,6 @@ let Pen = class Pen extends Group {
9302
9265
  get __tag() {
9303
9266
  return "Pen";
9304
9267
  }
9305
- constructor(data) {
9306
- super(data);
9307
- }
9308
9268
  setStyle(data) {
9309
9269
  const path = this.pathElement = new Path(data);
9310
9270
  this.pathStyle = data;
@@ -10000,7 +9960,7 @@ function ignoreRender(ui, value) {
10000
9960
 
10001
9961
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
10002
9962
 
10003
- const {floor: floor, max: max, abs: abs} = Math;
9963
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
10004
9964
 
10005
9965
  function createPattern(ui, paint, pixelRatio) {
10006
9966
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -10010,8 +9970,6 @@ function createPattern(ui, paint, pixelRatio) {
10010
9970
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
10011
9971
  scaleX *= pixelRatio;
10012
9972
  scaleY *= pixelRatio;
10013
- const xGap = gap && gap.x * scaleX;
10014
- const yGap = gap && gap.y * scaleY;
10015
9973
  if (sx) {
10016
9974
  sx = abs(sx);
10017
9975
  sy = abs(sy);
@@ -10028,7 +9986,10 @@ function createPattern(ui, paint, pixelRatio) {
10028
9986
  if (size > Platform.image.maxCacheSize) return false;
10029
9987
  }
10030
9988
  let maxSize = Platform.image.maxPatternSize;
10031
- if (!image.isSVG) {
9989
+ if (image.isSVG) {
9990
+ const ws = width / image.width;
9991
+ if (ws > 1) imageScale = ws / ceil(ws);
9992
+ } else {
10032
9993
  const imageSize = image.width * image.height;
10033
9994
  if (maxSize > imageSize) maxSize = imageSize;
10034
9995
  }
@@ -10043,18 +10004,20 @@ function createPattern(ui, paint, pixelRatio) {
10043
10004
  scaleX /= sx;
10044
10005
  scaleY /= sy;
10045
10006
  }
10007
+ const xGap = gap && gap.x * scaleX;
10008
+ const yGap = gap && gap.y * scaleY;
10046
10009
  if (transform || scaleX !== 1 || scaleY !== 1) {
10010
+ const canvasWidth = width + (xGap || 0);
10011
+ const canvasHeight = height + (yGap || 0);
10012
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
10013
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
10047
10014
  if (!imageMatrix) {
10048
10015
  imageMatrix = get$1();
10049
10016
  if (transform) copy$1(imageMatrix, transform);
10050
10017
  }
10051
10018
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
10052
10019
  }
10053
- if (imageMatrix) {
10054
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
10055
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
10056
- }
10057
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
10020
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
10058
10021
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
10059
10022
  paint.style = pattern;
10060
10023
  paint.patternId = id;
@@ -11002,4 +10965,4 @@ Object.assign(Effect, EffectModule);
11002
10965
 
11003
10966
  useCanvas();
11004
10967
 
11005
- 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 };
10968
+ 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 };