@leafer-draw/worker 1.9.4 → 1.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.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;
@@ -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
1088
  const {float: float, fourNumber: fourNumber} = MathHelper;
1086
- const {floor: floor$2, ceil: ceil$1} = Math;
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) {
@@ -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$9 = 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) {
@@ -5357,7 +5363,7 @@ var LeaferUI = function(exports) {
5357
5363
  const {updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2} = LeafHelper;
5358
5364
  const {updateBounds: updateBounds$1} = BranchHelper;
5359
5365
  const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$3} = BoundsHelper;
5360
- const {toBounds: toBounds$1} = PathBounds;
5366
+ const {toBounds: toBounds} = PathBounds;
5361
5367
  const LeafBounds = {
5362
5368
  __updateWorldBounds() {
5363
5369
  const layout = this.__layout;
@@ -5428,8 +5434,8 @@ var LeaferUI = function(exports) {
5428
5434
  __updateBoxBounds(_secondLayout, _bounds) {
5429
5435
  const b = this.__layout.boxBounds;
5430
5436
  const data = this.__;
5431
- if (data.__pathInputed) {
5432
- toBounds$1(data.path, b);
5437
+ if (data.__usePathBox) {
5438
+ toBounds(data.path, b);
5433
5439
  } else {
5434
5440
  b.x = 0;
5435
5441
  b.y = 0;
@@ -6344,7 +6350,7 @@ var LeaferUI = function(exports) {
6344
6350
  this.levelMap = null;
6345
6351
  }
6346
6352
  }
6347
- const version = "1.9.4";
6353
+ const version = "1.9.5";
6348
6354
  class LeaferCanvas extends LeaferCanvasBase {
6349
6355
  get allowBackgroundColor() {
6350
6356
  return true;
@@ -6740,7 +6746,7 @@ var LeaferUI = function(exports) {
6740
6746
  this.times = 0;
6741
6747
  this.config = {
6742
6748
  usePartRender: true,
6743
- maxFPS: 60
6749
+ maxFPS: 120
6744
6750
  };
6745
6751
  this.target = target;
6746
6752
  this.canvas = canvas;
@@ -6895,11 +6901,15 @@ var LeaferUI = function(exports) {
6895
6901
  if (this.requestTime || !target) return;
6896
6902
  if (target.parentApp) return target.parentApp.requestRender(false);
6897
6903
  const requestTime = this.requestTime = Date.now();
6898
- Platform.requestRender(() => {
6899
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
6904
+ const render = () => {
6905
+ const nowFPS = 1e3 / (Date.now() - requestTime);
6906
+ const {maxFPS: maxFPS} = this.config;
6907
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
6908
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
6900
6909
  this.requestTime = 0;
6901
6910
  this.checkRender();
6902
- });
6911
+ };
6912
+ Platform.requestRender(render);
6903
6913
  }
6904
6914
  __onResize(e) {
6905
6915
  if (this.canvas.unreal) return;
@@ -6942,7 +6952,8 @@ var LeaferUI = function(exports) {
6942
6952
  if (this.target) {
6943
6953
  this.stop();
6944
6954
  this.__removeListenEvents();
6945
- this.target = this.canvas = this.config = null;
6955
+ this.config = {};
6956
+ this.target = this.canvas = null;
6946
6957
  }
6947
6958
  }
6948
6959
  }
@@ -7219,7 +7230,11 @@ var LeaferUI = function(exports) {
7219
7230
  }
7220
7231
  }
7221
7232
  class FrameData extends BoxData {}
7222
- class LineData extends UIData {}
7233
+ class LineData extends UIData {
7234
+ get __usePathBox() {
7235
+ return this.points || this.__pathInputed;
7236
+ }
7237
+ }
7223
7238
  class RectData extends UIData {
7224
7239
  get __boxStroke() {
7225
7240
  return !this.__pathInputed;
@@ -7230,7 +7245,7 @@ var LeaferUI = function(exports) {
7230
7245
  return !this.__pathInputed;
7231
7246
  }
7232
7247
  }
7233
- class PolygonData extends UIData {}
7248
+ class PolygonData extends LineData {}
7234
7249
  class StarData extends UIData {}
7235
7250
  class PathData extends UIData {
7236
7251
  get __pathInputed() {
@@ -7524,20 +7539,9 @@ var LeaferUI = function(exports) {
7524
7539
  if (!path) this.__drawPathByBox(pen);
7525
7540
  return pen;
7526
7541
  }
7527
- constructor(data) {
7528
- super(data);
7529
- }
7530
7542
  reset(_data) {}
7531
- set(data, transition) {
7532
- if (data) {
7533
- if (transition) {
7534
- if (transition === "temp") {
7535
- this.lockNormalStyle = true;
7536
- Object.assign(this, data);
7537
- this.lockNormalStyle = false;
7538
- } else this.animate(data, transition);
7539
- } else Object.assign(this, data);
7540
- }
7543
+ set(data, _transition) {
7544
+ if (data) Object.assign(this, data);
7541
7545
  }
7542
7546
  get(name) {
7543
7547
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -7583,7 +7587,7 @@ var LeaferUI = function(exports) {
7583
7587
  const data = this.__;
7584
7588
  if (data.path) {
7585
7589
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
7586
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
7590
+ if (data.__useArrow) PathArrow.addArrows(this);
7587
7591
  } else data.__pathForRender && (data.__pathForRender = undefined);
7588
7592
  }
7589
7593
  __drawRenderPath(canvas) {
@@ -7607,7 +7611,8 @@ var LeaferUI = function(exports) {
7607
7611
  drawImagePlaceholder(canvas, _image) {
7608
7612
  Paint.fill(this.__.placeholderColor, this, canvas);
7609
7613
  }
7610
- animate(_keyframe, _options, _type, _isTemp) {
7614
+ animate(keyframe, _options, _type, _isTemp) {
7615
+ this.set(keyframe);
7611
7616
  return Plugin.need("animate");
7612
7617
  }
7613
7618
  killAnimate(_type, _nextStyle) {}
@@ -7721,9 +7726,6 @@ var LeaferUI = function(exports) {
7721
7726
  get isBranch() {
7722
7727
  return true;
7723
7728
  }
7724
- constructor(data) {
7725
- super(data);
7726
- }
7727
7729
  reset(data) {
7728
7730
  this.__setBranch();
7729
7731
  super.reset(data);
@@ -7841,7 +7843,7 @@ var LeaferUI = function(exports) {
7841
7843
  const canvas = this.canvas = Creator.canvas(config);
7842
7844
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7843
7845
  if (this.isApp) this.__setApp();
7844
- this.__checkAutoLayout(config, parentApp);
7846
+ this.__checkAutoLayout();
7845
7847
  this.view = canvas.view;
7846
7848
  if (!parentApp) {
7847
7849
  this.selector = Creator.selector(this);
@@ -7940,7 +7942,8 @@ var LeaferUI = function(exports) {
7940
7942
  this.leafer = leafer;
7941
7943
  this.__level = 1;
7942
7944
  }
7943
- __checkAutoLayout(config, parentApp) {
7945
+ __checkAutoLayout() {
7946
+ const {config: config, parentApp: parentApp} = this;
7944
7947
  if (!parentApp) {
7945
7948
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
7946
7949
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -7966,9 +7969,10 @@ var LeaferUI = function(exports) {
7966
7969
  return super.__getAttr(attrName);
7967
7970
  }
7968
7971
  __changeCanvasSize(attrName, newValue) {
7969
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
7970
- data[attrName] = this.config[attrName] = newValue;
7971
- if (newValue) this.canvas.stopAutoLayout();
7972
+ const {config: config, canvas: canvas} = this;
7973
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
7974
+ data[attrName] = config[attrName] = newValue;
7975
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
7972
7976
  this.__doResize(data);
7973
7977
  }
7974
7978
  __changeFill(newValue) {
@@ -8115,9 +8119,9 @@ var LeaferUI = function(exports) {
8115
8119
  if (!this.parent) {
8116
8120
  if (this.selector) this.selector.destroy();
8117
8121
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
8118
- this.canvasManager.destroy();
8122
+ if (this.canvasManager) this.canvasManager.destroy();
8119
8123
  }
8120
- this.canvas.destroy();
8124
+ if (this.canvas) this.canvas.destroy();
8121
8125
  this.config.view = this.view = this.parentApp = null;
8122
8126
  if (this.userConfig) this.userConfig.view = null;
8123
8127
  super.destroy();
@@ -8140,9 +8144,6 @@ var LeaferUI = function(exports) {
8140
8144
  get __tag() {
8141
8145
  return "Rect";
8142
8146
  }
8143
- constructor(data) {
8144
- super(data);
8145
- }
8146
8147
  };
8147
8148
  __decorate([ dataProcessor(RectData) ], exports.Rect.prototype, "__", void 0);
8148
8149
  exports.Rect = __decorate([ useModule(RectRender), rewriteAble(), registerUI() ], exports.Rect);
@@ -8254,9 +8255,6 @@ var LeaferUI = function(exports) {
8254
8255
  get isFrame() {
8255
8256
  return true;
8256
8257
  }
8257
- constructor(data) {
8258
- super(data);
8259
- }
8260
8258
  };
8261
8259
  __decorate([ dataProcessor(FrameData) ], exports.Frame.prototype, "__", void 0);
8262
8260
  __decorate([ surfaceType("#FFFFFF") ], exports.Frame.prototype, "fill", void 0);
@@ -8267,9 +8265,6 @@ var LeaferUI = function(exports) {
8267
8265
  get __tag() {
8268
8266
  return "Ellipse";
8269
8267
  }
8270
- constructor(data) {
8271
- super(data);
8272
- }
8273
8268
  __updatePath() {
8274
8269
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
8275
8270
  const rx = width / 2, ry = height / 2;
@@ -8305,7 +8300,6 @@ var LeaferUI = function(exports) {
8305
8300
  exports.Ellipse = __decorate([ registerUI() ], exports.Ellipse);
8306
8301
  const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
8307
8302
  const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8308
- const {toBounds: toBounds} = PathBounds;
8309
8303
  exports.Line = class Line extends exports.UI {
8310
8304
  get __tag() {
8311
8305
  return "Line";
@@ -8322,31 +8316,16 @@ var LeaferUI = function(exports) {
8322
8316
  this.rotation = getAngle$1(defaultPoint, value);
8323
8317
  if (this.height) this.height = 0;
8324
8318
  }
8325
- constructor(data) {
8326
- super(data);
8327
- }
8328
8319
  __updatePath() {
8329
8320
  const data = this.__;
8330
8321
  const path = data.path = [];
8331
8322
  if (data.points) {
8332
- drawPoints$1(path, data.points, false, data.closed);
8323
+ drawPoints$1(path, data.points, data.curve, data.closed);
8333
8324
  } else {
8334
8325
  moveTo$2(path, 0, 0);
8335
8326
  lineTo$2(path, this.width, 0);
8336
8327
  }
8337
8328
  }
8338
- __updateRenderPath() {
8339
- const data = this.__;
8340
- if (!this.pathInputed && data.points && data.curve) {
8341
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
8342
- if (data.__useArrow) PathArrow.addArrows(this, false);
8343
- } else super.__updateRenderPath();
8344
- }
8345
- __updateBoxBounds() {
8346
- if (this.points) {
8347
- toBounds(this.__.__pathForRender, this.__layout.boxBounds);
8348
- } else super.__updateBoxBounds();
8349
- }
8350
8329
  };
8351
8330
  __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8352
8331
  __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
@@ -8362,15 +8341,13 @@ var LeaferUI = function(exports) {
8362
8341
  get __tag() {
8363
8342
  return "Polygon";
8364
8343
  }
8365
- constructor(data) {
8366
- super(data);
8367
- }
8368
8344
  __updatePath() {
8369
- const path = this.__.path = [];
8370
- if (this.__.points) {
8371
- drawPoints(path, this.__.points, false, true);
8345
+ const data = this.__;
8346
+ const path = data.path = [];
8347
+ if (data.points) {
8348
+ drawPoints(path, data.points, data.curve, true);
8372
8349
  } else {
8373
- const {width: width, height: height, sides: sides} = this.__;
8350
+ const {width: width, height: height, sides: sides} = data;
8374
8351
  const rx = width / 2, ry = height / 2;
8375
8352
  moveTo$1(path, rx, 0);
8376
8353
  for (let i = 1; i < sides; i++) {
@@ -8395,9 +8372,6 @@ var LeaferUI = function(exports) {
8395
8372
  get __tag() {
8396
8373
  return "Star";
8397
8374
  }
8398
- constructor(data) {
8399
- super(data);
8400
- }
8401
8375
  __updatePath() {
8402
8376
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
8403
8377
  const rx = width / 2, ry = height / 2;
@@ -8425,9 +8399,6 @@ var LeaferUI = function(exports) {
8425
8399
  const {fill: fill} = this.__;
8426
8400
  return isArray(fill) && fill[0].image;
8427
8401
  }
8428
- constructor(data) {
8429
- super(data);
8430
- }
8431
8402
  };
8432
8403
  __decorate([ dataProcessor(ImageData) ], exports.Image.prototype, "__", void 0);
8433
8404
  __decorate([ boundsType("") ], exports.Image.prototype, "url", void 0);
@@ -8512,9 +8483,6 @@ var LeaferUI = function(exports) {
8512
8483
  this.updateLayout();
8513
8484
  return this.__.__textDrawData;
8514
8485
  }
8515
- constructor(data) {
8516
- super(data);
8517
- }
8518
8486
  __updateTextDrawData() {
8519
8487
  const data = this.__;
8520
8488
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -8618,9 +8586,6 @@ var LeaferUI = function(exports) {
8618
8586
  get __tag() {
8619
8587
  return "Path";
8620
8588
  }
8621
- constructor(data) {
8622
- super(data);
8623
- }
8624
8589
  };
8625
8590
  __decorate([ dataProcessor(PathData) ], exports.Path.prototype, "__", void 0);
8626
8591
  __decorate([ affectStrokeBoundsType("center") ], exports.Path.prototype, "strokeAlign", void 0);
@@ -8629,9 +8594,6 @@ var LeaferUI = function(exports) {
8629
8594
  get __tag() {
8630
8595
  return "Pen";
8631
8596
  }
8632
- constructor(data) {
8633
- super(data);
8634
- }
8635
8597
  setStyle(data) {
8636
8598
  const path = this.pathElement = new exports.Path(data);
8637
8599
  this.pathStyle = data;
@@ -9277,7 +9239,7 @@ var LeaferUI = function(exports) {
9277
9239
  if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
9278
9240
  }
9279
9241
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
9280
- const {floor: floor, max: max, abs: abs} = Math;
9242
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
9281
9243
  function createPattern(ui, paint, pixelRatio) {
9282
9244
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
9283
9245
  const id = scaleX + "-" + scaleY + "-" + pixelRatio;
@@ -9286,8 +9248,6 @@ var LeaferUI = function(exports) {
9286
9248
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
9287
9249
  scaleX *= pixelRatio;
9288
9250
  scaleY *= pixelRatio;
9289
- const xGap = gap && gap.x * scaleX;
9290
- const yGap = gap && gap.y * scaleY;
9291
9251
  if (sx) {
9292
9252
  sx = abs(sx);
9293
9253
  sy = abs(sy);
@@ -9304,7 +9264,10 @@ var LeaferUI = function(exports) {
9304
9264
  if (size > Platform.image.maxCacheSize) return false;
9305
9265
  }
9306
9266
  let maxSize = Platform.image.maxPatternSize;
9307
- if (!image.isSVG) {
9267
+ if (image.isSVG) {
9268
+ const ws = width / image.width;
9269
+ if (ws > 1) imageScale = ws / ceil(ws);
9270
+ } else {
9308
9271
  const imageSize = image.width * image.height;
9309
9272
  if (maxSize > imageSize) maxSize = imageSize;
9310
9273
  }
@@ -9319,18 +9282,20 @@ var LeaferUI = function(exports) {
9319
9282
  scaleX /= sx;
9320
9283
  scaleY /= sy;
9321
9284
  }
9285
+ const xGap = gap && gap.x * scaleX;
9286
+ const yGap = gap && gap.y * scaleY;
9322
9287
  if (transform || scaleX !== 1 || scaleY !== 1) {
9288
+ const canvasWidth = width + (xGap || 0);
9289
+ const canvasHeight = height + (yGap || 0);
9290
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
9291
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
9323
9292
  if (!imageMatrix) {
9324
9293
  imageMatrix = get$1();
9325
9294
  if (transform) copy$1(imageMatrix, transform);
9326
9295
  }
9327
9296
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
9328
9297
  }
9329
- if (imageMatrix) {
9330
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
9331
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
9332
- }
9333
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
9298
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
9334
9299
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
9335
9300
  paint.style = pattern;
9336
9301
  paint.patternId = id;
@@ -10326,6 +10291,7 @@ var LeaferUI = function(exports) {
10326
10291
  exports.maskType = maskType;
10327
10292
  exports.naturalBoundsType = naturalBoundsType;
10328
10293
  exports.opacityType = opacityType;
10294
+ exports.path = path;
10329
10295
  exports.pathInputType = pathInputType;
10330
10296
  exports.pathType = pathType;
10331
10297
  exports.pen = pen;