@leafer-draw/worker 1.9.5 → 1.9.7

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
@@ -344,7 +344,7 @@ var LeaferUI = function(exports) {
344
344
  };
345
345
  }
346
346
  const {sin: sin$5, cos: cos$5, acos: acos, sqrt: sqrt$3} = Math;
347
- const {float: float$1} = MathHelper;
347
+ const {float: float$2} = MathHelper;
348
348
  const tempPoint$3 = {};
349
349
  function getWorld() {
350
350
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), {
@@ -392,6 +392,15 @@ var LeaferUI = function(exports) {
392
392
  t.c *= scaleY;
393
393
  t.d *= scaleY;
394
394
  },
395
+ pixelScale(t, pixelRatio, to) {
396
+ to || (to = t);
397
+ to.a = t.a * pixelRatio;
398
+ to.b = t.b * pixelRatio;
399
+ to.c = t.c * pixelRatio;
400
+ to.d = t.d * pixelRatio;
401
+ to.e = t.e * pixelRatio;
402
+ to.f = t.f * pixelRatio;
403
+ },
395
404
  scaleOfOuter(t, origin, scaleX, scaleY) {
396
405
  M$6.toInnerPoint(t, origin, tempPoint$3);
397
406
  M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
@@ -583,12 +592,12 @@ var LeaferUI = function(exports) {
583
592
  const cosR = c / scaleY;
584
593
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
585
594
  }
586
- const cosR = float$1(cos$5(rotation));
595
+ const cosR = float$2(cos$5(rotation));
587
596
  const sinR = sin$5(rotation);
588
- scaleX = float$1(scaleX), scaleY = float$1(scaleY);
589
- skewX = cosR ? float$1((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
590
- skewY = cosR ? float$1((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
591
- rotation = float$1(rotation / OneRadian);
597
+ scaleX = float$2(scaleX), scaleY = float$2(scaleY);
598
+ skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
599
+ skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
600
+ rotation = float$2(rotation / OneRadian);
592
601
  } else {
593
602
  scaleX = a;
594
603
  scaleY = d;
@@ -882,6 +891,10 @@ var LeaferUI = function(exports) {
882
891
  this.scaleY *= y || x;
883
892
  return this;
884
893
  }
894
+ pixelScale(pixelRatio) {
895
+ MatrixHelper.pixelScale(this, pixelRatio);
896
+ return this;
897
+ }
885
898
  scaleOfOuter(origin, x, y) {
886
899
  MatrixHelper.scaleOfOuter(this, origin, x, y);
887
900
  return this;
@@ -1085,7 +1098,7 @@ var LeaferUI = function(exports) {
1085
1098
  };
1086
1099
  const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
1087
1100
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1088
- const {float: float, fourNumber: fourNumber} = MathHelper;
1101
+ const {float: float$1, fourNumber: fourNumber} = MathHelper;
1089
1102
  const {floor: floor$2, ceil: ceil$2} = Math;
1090
1103
  let right$1, bottom$1, boundsRight, boundsBottom;
1091
1104
  const point = {};
@@ -1262,10 +1275,10 @@ var LeaferUI = function(exports) {
1262
1275
  }
1263
1276
  },
1264
1277
  float(t, maxLength) {
1265
- t.x = float(t.x, maxLength);
1266
- t.y = float(t.y, maxLength);
1267
- t.width = float(t.width, maxLength);
1268
- t.height = float(t.height, maxLength);
1278
+ t.x = float$1(t.x, maxLength);
1279
+ t.y = float$1(t.y, maxLength);
1280
+ t.width = float$1(t.width, maxLength);
1281
+ t.height = float$1(t.height, maxLength);
1269
1282
  },
1270
1283
  add(t, bounds, isPoint) {
1271
1284
  right$1 = t.x + t.width;
@@ -1991,7 +2004,7 @@ var LeaferUI = function(exports) {
1991
2004
  __decorate([ contextMethod() ], Canvas.prototype, "fillText", null);
1992
2005
  __decorate([ contextMethod() ], Canvas.prototype, "measureText", null);
1993
2006
  __decorate([ contextMethod() ], Canvas.prototype, "strokeText", null);
1994
- const {copy: copy$7, multiplyParent: multiplyParent$4} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2007
+ const {copy: copy$7, multiplyParent: multiplyParent$4, pixelScale: pixelScale} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
1995
2008
  const minSize = {
1996
2009
  width: 1,
1997
2010
  height: 1,
@@ -2089,12 +2102,7 @@ var LeaferUI = function(exports) {
2089
2102
  setWorld(matrix, parentMatrix) {
2090
2103
  const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
2091
2104
  if (parentMatrix) multiplyParent$4(matrix, parentMatrix, w);
2092
- w.a = matrix.a * pixelRatio;
2093
- w.b = matrix.b * pixelRatio;
2094
- w.c = matrix.c * pixelRatio;
2095
- w.d = matrix.d * pixelRatio;
2096
- w.e = matrix.e * pixelRatio;
2097
- w.f = matrix.f * pixelRatio;
2105
+ pixelScale(matrix, pixelRatio, w);
2098
2106
  if (pixelSnap) {
2099
2107
  if (matrix.half && matrix.half * pixelRatio % 2) w.e = round$1(w.e - .5) + .5, w.f = round$1(w.f - .5) + .5; else w.e = round$1(w.e),
2100
2108
  w.f = round$1(w.f);
@@ -4008,6 +4016,17 @@ var LeaferUI = function(exports) {
4008
4016
  }
4009
4017
  }));
4010
4018
  }
4019
+ function dimType(defaultValue) {
4020
+ return decorateLeafAttr(defaultValue, key => attr({
4021
+ set(value) {
4022
+ if (this.__setAttr(key, value)) {
4023
+ const data = this.__;
4024
+ DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
4025
+ this.__layout.surfaceChange();
4026
+ }
4027
+ }
4028
+ }));
4029
+ }
4011
4030
  function opacityType(defaultValue) {
4012
4031
  return decorateLeafAttr(defaultValue, key => attr({
4013
4032
  set(value) {
@@ -4048,7 +4067,7 @@ var LeaferUI = function(exports) {
4048
4067
  return decorateLeafAttr(defaultValue, key => attr({
4049
4068
  set(value) {
4050
4069
  if (this.__setAttr(key, value)) {
4051
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
4070
+ this.__layout.surfaceChange();
4052
4071
  this.waitParent(() => {
4053
4072
  this.parent.__layout.childrenSortChange();
4054
4073
  });
@@ -4082,7 +4101,7 @@ var LeaferUI = function(exports) {
4082
4101
  set(value) {
4083
4102
  if (this.__setAttr(key, value)) {
4084
4103
  this.__layout.hitCanvasChanged = true;
4085
- if (Debug.showBounds === "hit") this.__layout.surfaceChanged || this.__layout.surfaceChange();
4104
+ if (Debug.showBounds === "hit") this.__layout.surfaceChange();
4086
4105
  if (this.leafer) this.leafer.updateCursor();
4087
4106
  }
4088
4107
  }
@@ -5105,6 +5124,7 @@ var LeaferUI = function(exports) {
5105
5124
  LeaferEvent.STOP = "leafer.stop";
5106
5125
  LeaferEvent.RESTART = "leafer.restart";
5107
5126
  LeaferEvent.END = "leafer.end";
5127
+ LeaferEvent.UPDATE_MODE = "leafer.update_mode";
5108
5128
  LeaferEvent.TRANSFORM = "leafer.transform";
5109
5129
  LeaferEvent.MOVE = "leafer.move";
5110
5130
  LeaferEvent.SCALE = "leafer.scale";
@@ -5479,6 +5499,7 @@ var LeaferUI = function(exports) {
5479
5499
  if (options.shape) return this.__renderShape(canvas, options);
5480
5500
  if (this.__worldOpacity) {
5481
5501
  const data = this.__;
5502
+ if (data.bright && !options.topRendering) return options.topList.add(this);
5482
5503
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5483
5504
  canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5484
5505
  if (this.__.__single) {
@@ -5525,7 +5546,9 @@ var LeaferUI = function(exports) {
5525
5546
  this.__nowWorld = this.__getNowWorld(options);
5526
5547
  if (this.__worldOpacity) {
5527
5548
  const data = this.__;
5528
- if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5549
+ if (data.__useDim) {
5550
+ if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5551
+ }
5529
5552
  if (data.__single && !this.isBranchLeaf) {
5530
5553
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5531
5554
  const tempCanvas = canvas.getSameCanvas(false, true);
@@ -6350,7 +6373,7 @@ var LeaferUI = function(exports) {
6350
6373
  this.levelMap = null;
6351
6374
  }
6352
6375
  }
6353
- const version = "1.9.5";
6376
+ const version = "1.9.7";
6354
6377
  class LeaferCanvas extends LeaferCanvasBase {
6355
6378
  get allowBackgroundColor() {
6356
6379
  return true;
@@ -6877,7 +6900,7 @@ var LeaferUI = function(exports) {
6877
6900
  };
6878
6901
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
6879
6902
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
6880
- this.target.__render(canvas, options);
6903
+ Platform.render(this.target, canvas, options);
6881
6904
  this.renderBounds = realBounds = realBounds || bounds;
6882
6905
  this.renderOptions = options;
6883
6906
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
@@ -6966,6 +6989,14 @@ var LeaferUI = function(exports) {
6966
6989
  interaction: (_target, _canvas, _selector, _options) => undefined
6967
6990
  });
6968
6991
  Platform.layout = Layouter.fullLayout;
6992
+ Platform.render = function(target, canvas, options) {
6993
+ const topOptions = Object.assign(Object.assign({}, options), {
6994
+ topRendering: true
6995
+ });
6996
+ options.topList = new LeafList;
6997
+ target.__render(canvas, options);
6998
+ if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
6999
+ };
6969
7000
  function effectType(defaultValue) {
6970
7001
  return decorateLeafAttr(defaultValue, key => attr({
6971
7002
  set(value) {
@@ -7284,8 +7315,6 @@ var LeaferUI = function(exports) {
7284
7315
  if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
7285
7316
  box.set(value);
7286
7317
  if (boxLayout.strokeChanged) layout.strokeChange();
7287
- if (boxLayout.renderChanged) layout.renderChange();
7288
- box.__updateChange();
7289
7318
  } else if (box) {
7290
7319
  t.__box = box.parent = null;
7291
7320
  box.destroy();
@@ -7352,7 +7381,7 @@ var LeaferUI = function(exports) {
7352
7381
  __updateRenderSpread() {
7353
7382
  let width = 0;
7354
7383
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7355
- 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));
7384
+ if (shadow) width = Effect.getShadowSpread(this, shadow);
7356
7385
  if (blur) width = Math.max(width, blur);
7357
7386
  if (filter) width += Filter.getSpread(filter);
7358
7387
  if (renderSpread) width += renderSpread;
@@ -7364,36 +7393,67 @@ var LeaferUI = function(exports) {
7364
7393
  return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7365
7394
  }
7366
7395
  };
7396
+ const {float: float} = MathHelper;
7397
+ const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
7367
7398
  const DragBoundsHelper = {
7399
+ limitMove(leaf, move) {
7400
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7401
+ if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
7402
+ D.axisMove(leaf, move);
7403
+ },
7404
+ limitScaleOf(leaf, origin, scale) {
7405
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7406
+ if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
7407
+ },
7408
+ axisMove(leaf, move) {
7409
+ const {draggable: draggable} = leaf;
7410
+ if (draggable === "x") move.y = 0;
7411
+ if (draggable === "y") move.x = 0;
7412
+ },
7413
+ getDragBounds(leaf) {
7414
+ const {dragBounds: dragBounds} = leaf;
7415
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
7416
+ },
7417
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
7418
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
7419
+ },
7368
7420
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
7369
7421
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
7370
7422
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
7371
7423
  if (!change) move = Object.assign({}, move);
7372
- const isBiggerWidth = content.width > dragBounds.width;
7373
- const isBiggerHeight = content.height > dragBounds.height;
7374
- if (isBiggerWidth && dragBoundsType !== "outer") {
7424
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7375
7425
  if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
7376
7426
  } else {
7377
7427
  if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
7378
7428
  }
7379
- if (isBiggerHeight && dragBoundsType !== "outer") {
7429
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7380
7430
  if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
7381
7431
  } else {
7382
7432
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
7383
7433
  }
7384
- move.x = MathHelper.float(move.x);
7385
- move.y = MathHelper.float(move.y);
7434
+ move.x = float(move.x);
7435
+ move.y = float(move.y);
7386
7436
  return move;
7387
7437
  },
7388
- axisMove(leaf, move) {
7389
- const {draggable: draggable} = leaf;
7390
- if (draggable === "x") move.y = 0;
7391
- if (draggable === "y") move.x = 0;
7392
- },
7393
- limitMove(leaf, move) {
7394
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7395
- if (dragBounds) D.getValidMove(leaf.__localBoxBounds, dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds, dragBoundsType, move, true);
7396
- D.axisMove(leaf, move);
7438
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
7439
+ if (!change) scale = Object.assign({}, scale);
7440
+ let fitScaleX, fitScaleY;
7441
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
7442
+ tempMerge.set(tempContent).add(dragBounds);
7443
+ tempIntersect.set(tempContent).intersect(dragBounds);
7444
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7445
+ fitScaleX = tempMerge.width / tempContent.width;
7446
+ } else {
7447
+ fitScaleX = tempIntersect.width / tempContent.width;
7448
+ }
7449
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7450
+ fitScaleY = tempMerge.height / tempContent.height;
7451
+ } else {
7452
+ fitScaleY = tempIntersect.height / tempContent.height;
7453
+ }
7454
+ scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
7455
+ scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
7456
+ return scale;
7397
7457
  }
7398
7458
  };
7399
7459
  const D = DragBoundsHelper;
@@ -7408,7 +7468,7 @@ var LeaferUI = function(exports) {
7408
7468
  }
7409
7469
  if (data.__useEffect) {
7410
7470
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7411
- 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"));
7471
+ 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"));
7412
7472
  data.__useEffect = !!(shadow || otherEffect);
7413
7473
  }
7414
7474
  data.__checkSingle();
@@ -7654,8 +7714,8 @@ var LeaferUI = function(exports) {
7654
7714
  __decorate([ opacityType(1) ], exports.UI.prototype, "opacity", void 0);
7655
7715
  __decorate([ visibleType(true) ], exports.UI.prototype, "visible", void 0);
7656
7716
  __decorate([ surfaceType(false) ], exports.UI.prototype, "locked", void 0);
7657
- __decorate([ surfaceType(false) ], exports.UI.prototype, "dim", void 0);
7658
- __decorate([ surfaceType(false) ], exports.UI.prototype, "dimskip", void 0);
7717
+ __decorate([ dimType(false) ], exports.UI.prototype, "dim", void 0);
7718
+ __decorate([ dimType(false) ], exports.UI.prototype, "dimskip", void 0);
7659
7719
  __decorate([ sortType(0) ], exports.UI.prototype, "zIndex", void 0);
7660
7720
  __decorate([ maskType(false) ], exports.UI.prototype, "mask", void 0);
7661
7721
  __decorate([ eraserType(false) ], exports.UI.prototype, "eraser", void 0);
@@ -7960,7 +8020,9 @@ var LeaferUI = function(exports) {
7960
8020
  } else if (attrName === "zIndex") {
7961
8021
  this.canvas.zIndex = newValue;
7962
8022
  setTimeout(() => this.parent && this.parent.__updateSortChildren());
7963
- }
8023
+ } else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
8024
+ mode: newValue
8025
+ });
7964
8026
  }
7965
8027
  return super.__setAttr(attrName, newValue);
7966
8028
  }
@@ -8139,6 +8201,7 @@ var LeaferUI = function(exports) {
8139
8201
  exports.Leafer.list = new LeafList;
8140
8202
  __decorate([ dataProcessor(LeaferData) ], exports.Leafer.prototype, "__", void 0);
8141
8203
  __decorate([ boundsType() ], exports.Leafer.prototype, "pixelRatio", void 0);
8204
+ __decorate([ dataType("normal") ], exports.Leafer.prototype, "mode", void 0);
8142
8205
  exports.Leafer = Leafer_1 = __decorate([ registerUI() ], exports.Leafer);
8143
8206
  exports.Rect = class Rect extends exports.UI {
8144
8207
  get __tag() {
@@ -8298,45 +8361,8 @@ var LeaferUI = function(exports) {
8298
8361
  __decorate([ pathType(0) ], exports.Ellipse.prototype, "startAngle", void 0);
8299
8362
  __decorate([ pathType(0) ], exports.Ellipse.prototype, "endAngle", void 0);
8300
8363
  exports.Ellipse = __decorate([ registerUI() ], exports.Ellipse);
8301
- const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
8302
- const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8303
- exports.Line = class Line extends exports.UI {
8304
- get __tag() {
8305
- return "Line";
8306
- }
8307
- get toPoint() {
8308
- const {width: width, rotation: rotation} = this.__;
8309
- const to = getPointData();
8310
- if (width) to.x = width;
8311
- if (rotation) rotate$1(to, rotation);
8312
- return to;
8313
- }
8314
- set toPoint(value) {
8315
- this.width = getDistance$2(defaultPoint, value);
8316
- this.rotation = getAngle$1(defaultPoint, value);
8317
- if (this.height) this.height = 0;
8318
- }
8319
- __updatePath() {
8320
- const data = this.__;
8321
- const path = data.path = [];
8322
- if (data.points) {
8323
- drawPoints$1(path, data.points, data.curve, data.closed);
8324
- } else {
8325
- moveTo$2(path, 0, 0);
8326
- lineTo$2(path, this.width, 0);
8327
- }
8328
- }
8329
- };
8330
- __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8331
- __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
8332
- __decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
8333
- __decorate([ pathType() ], exports.Line.prototype, "points", void 0);
8334
- __decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
8335
- __decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
8336
- exports.Line = __decorate([ registerUI() ], exports.Line);
8337
8364
  const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
8338
- const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = PathCommandDataHelper;
8339
- const line = exports.Line.prototype;
8365
+ const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
8340
8366
  exports.Polygon = class Polygon extends exports.UI {
8341
8367
  get __tag() {
8342
8368
  return "Polygon";
@@ -8345,29 +8371,25 @@ var LeaferUI = function(exports) {
8345
8371
  const data = this.__;
8346
8372
  const path = data.path = [];
8347
8373
  if (data.points) {
8348
- drawPoints(path, data.points, data.curve, true);
8374
+ drawPoints$1(path, data.points, data.curve, true);
8349
8375
  } else {
8350
8376
  const {width: width, height: height, sides: sides} = data;
8351
8377
  const rx = width / 2, ry = height / 2;
8352
- moveTo$1(path, rx, 0);
8378
+ moveTo$2(path, rx, 0);
8353
8379
  for (let i = 1; i < sides; i++) {
8354
- lineTo$1(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
8380
+ lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
8355
8381
  }
8356
8382
  closePath$1(path);
8357
8383
  }
8358
8384
  }
8359
- __updateRenderPath() {}
8360
- __updateBoxBounds() {}
8361
8385
  };
8362
8386
  __decorate([ dataProcessor(PolygonData) ], exports.Polygon.prototype, "__", void 0);
8363
8387
  __decorate([ pathType(3) ], exports.Polygon.prototype, "sides", void 0);
8364
8388
  __decorate([ pathType() ], exports.Polygon.prototype, "points", void 0);
8365
8389
  __decorate([ pathType(0) ], exports.Polygon.prototype, "curve", void 0);
8366
- __decorate([ rewrite(line.__updateRenderPath) ], exports.Polygon.prototype, "__updateRenderPath", null);
8367
- __decorate([ rewrite(line.__updateBoxBounds) ], exports.Polygon.prototype, "__updateBoxBounds", null);
8368
8390
  exports.Polygon = __decorate([ rewriteAble(), registerUI() ], exports.Polygon);
8369
8391
  const {sin: sin, cos: cos, PI: PI} = Math;
8370
- const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
8392
+ const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
8371
8393
  exports.Star = class Star extends exports.UI {
8372
8394
  get __tag() {
8373
8395
  return "Star";
@@ -8376,9 +8398,9 @@ var LeaferUI = function(exports) {
8376
8398
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
8377
8399
  const rx = width / 2, ry = height / 2;
8378
8400
  const path = this.__.path = [];
8379
- moveTo(path, rx, 0);
8401
+ moveTo$1(path, rx, 0);
8380
8402
  for (let i = 1; i < corners * 2; i++) {
8381
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
8403
+ 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));
8382
8404
  }
8383
8405
  closePath(path);
8384
8406
  }
@@ -8387,6 +8409,42 @@ var LeaferUI = function(exports) {
8387
8409
  __decorate([ pathType(5) ], exports.Star.prototype, "corners", void 0);
8388
8410
  __decorate([ pathType(.382) ], exports.Star.prototype, "innerRadius", void 0);
8389
8411
  exports.Star = __decorate([ registerUI() ], exports.Star);
8412
+ const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
8413
+ const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8414
+ exports.Line = class Line extends exports.UI {
8415
+ get __tag() {
8416
+ return "Line";
8417
+ }
8418
+ get toPoint() {
8419
+ const {width: width, rotation: rotation} = this.__;
8420
+ const to = getPointData();
8421
+ if (width) to.x = width;
8422
+ if (rotation) rotate$1(to, rotation);
8423
+ return to;
8424
+ }
8425
+ set toPoint(value) {
8426
+ this.width = getDistance$2(defaultPoint, value);
8427
+ this.rotation = getAngle$1(defaultPoint, value);
8428
+ if (this.height) this.height = 0;
8429
+ }
8430
+ __updatePath() {
8431
+ const data = this.__;
8432
+ const path = data.path = [];
8433
+ if (data.points) {
8434
+ drawPoints(path, data.points, data.curve, data.closed);
8435
+ } else {
8436
+ moveTo(path, 0, 0);
8437
+ lineTo(path, this.width, 0);
8438
+ }
8439
+ }
8440
+ };
8441
+ __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8442
+ __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
8443
+ __decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
8444
+ __decorate([ pathType() ], exports.Line.prototype, "points", void 0);
8445
+ __decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
8446
+ __decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
8447
+ exports.Line = __decorate([ registerUI() ], exports.Line);
8390
8448
  exports.Image = class Image extends exports.Rect {
8391
8449
  get __tag() {
8392
8450
  return "Image";
@@ -8519,10 +8577,6 @@ var LeaferUI = function(exports) {
8519
8577
  DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
8520
8578
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
8521
8579
  }
8522
- __onUpdateSize() {
8523
- if (this.__box) this.__box.__onUpdateSize();
8524
- super.__onUpdateSize();
8525
- }
8526
8580
  __updateRenderSpread() {
8527
8581
  let width = super.__updateRenderSpread();
8528
8582
  if (!width) width = this.isOverflow ? 1 : 0;
@@ -8533,6 +8587,11 @@ var LeaferUI = function(exports) {
8533
8587
  copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
8534
8588
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
8535
8589
  }
8590
+ __updateChange() {
8591
+ super.__updateChange();
8592
+ const box = this.__box;
8593
+ if (box) box.__onUpdateSize(), box.__updateChange();
8594
+ }
8536
8595
  __drawRenderPath(canvas) {
8537
8596
  canvas.font = this.__.__font;
8538
8597
  }
@@ -9511,11 +9570,16 @@ var LeaferUI = function(exports) {
9511
9570
  }
9512
9571
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
9513
9572
  }
9514
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9573
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9515
9574
  if (end && index < end) other.clearWorld(copyBounds);
9516
9575
  });
9517
9576
  other.recycle(copyBounds);
9518
9577
  }
9578
+ function getShadowSpread(_ui, shadow) {
9579
+ let width = 0;
9580
+ 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));
9581
+ return width;
9582
+ }
9519
9583
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
9520
9584
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
9521
9585
  if (Platform.fullImageShadow) {
@@ -9587,7 +9651,11 @@ var LeaferUI = function(exports) {
9587
9651
  shadow: shadow,
9588
9652
  innerShadow: innerShadow,
9589
9653
  blur: blur,
9590
- backgroundBlur: backgroundBlur
9654
+ backgroundBlur: backgroundBlur,
9655
+ getShadowSpread: getShadowSpread,
9656
+ isTransformShadow(_shadow) {
9657
+ return undefined;
9658
+ }
9591
9659
  };
9592
9660
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
9593
9661
  let usedGrayscaleAlpha;
@@ -10043,16 +10111,17 @@ var LeaferUI = function(exports) {
10043
10111
  row.data = null;
10044
10112
  }
10045
10113
  function decorationText(drawData, style) {
10046
- let type;
10114
+ let type, offset = 0;
10047
10115
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
10048
10116
  drawData.decorationHeight = fontSize / 11;
10049
10117
  if (isObject(textDecoration)) {
10050
10118
  type = textDecoration.type;
10051
10119
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
10120
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
10052
10121
  } else type = textDecoration;
10053
10122
  switch (type) {
10054
10123
  case "under":
10055
- drawData.decorationY = [ fontSize * .15 ];
10124
+ drawData.decorationY = [ fontSize * .15 + offset ];
10056
10125
  break;
10057
10126
 
10058
10127
  case "delete":
@@ -10060,7 +10129,7 @@ var LeaferUI = function(exports) {
10060
10129
  break;
10061
10130
 
10062
10131
  case "under-delete":
10063
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
10132
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
10064
10133
  }
10065
10134
  }
10066
10135
  const {top: top, right: right, bottom: bottom, left: left} = exports.Direction4;
@@ -10266,6 +10335,7 @@ var LeaferUI = function(exports) {
10266
10335
  exports.defineDataProcessor = defineDataProcessor;
10267
10336
  exports.defineKey = defineKey;
10268
10337
  exports.defineLeafAttr = defineLeafAttr;
10338
+ exports.dimType = dimType;
10269
10339
  exports.doBoundsType = doBoundsType;
10270
10340
  exports.doStrokeType = doStrokeType;
10271
10341
  exports.effectType = effectType;