@leafer/worker 2.0.8 → 2.1.0

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.
@@ -7079,7 +7079,7 @@ class LeafLevelList {
7079
7079
  }
7080
7080
  }
7081
7081
 
7082
- const version = "2.0.8";
7082
+ const version = "2.1.0";
7083
7083
 
7084
7084
  class LeaferCanvas extends LeaferCanvasBase {
7085
7085
  get allowBackgroundColor() {
@@ -8085,8 +8085,8 @@ class UIData extends LeafData {
8085
8085
  return this.__getRealStrokeWidth();
8086
8086
  }
8087
8087
  get __maxStrokeWidth() {
8088
- const t = this;
8089
- return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth;
8088
+ const t = this, strokeWidth = t.__hasStrokeSides || t.strokeWidth;
8089
+ return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, strokeWidth) : strokeWidth;
8090
8090
  }
8091
8091
  get __hasMultiPaint() {
8092
8092
  const t = this;
@@ -8187,6 +8187,10 @@ class UIData extends LeafData {
8187
8187
  }
8188
8188
  return strokeWidth;
8189
8189
  }
8190
+ __checkComplex() {
8191
+ const t = this;
8192
+ stintSet$5(t, "__complex", t.__isFills || t.__isStrokes || t.cornerRadius || t.__useEffect);
8193
+ }
8190
8194
  __setPaint(attrName, value) {
8191
8195
  this.__setInput(attrName, value);
8192
8196
  const layout = this.__leaf.__layout;
@@ -8421,7 +8425,7 @@ const UIRender = {
8421
8425
  data.__useEffect = !!(shadow || otherEffect);
8422
8426
  }
8423
8427
  data.__checkSingle();
8424
- stintSet$4(data, "__complex", data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
8428
+ data.__checkComplex();
8425
8429
  },
8426
8430
  __drawFast(canvas, options) {
8427
8431
  drawFast(this, canvas, options);
@@ -9470,11 +9474,16 @@ let Polygon = class Polygon extends UI {
9470
9474
  if (data.points) {
9471
9475
  drawPoints$1(path, data.points, data.curve, data.closed);
9472
9476
  } else {
9473
- const {width: width, height: height, sides: sides} = data;
9477
+ const {width: width, height: height, sides: sides, startAngle: startAngle} = data;
9474
9478
  const rx = width / 2, ry = height / 2;
9475
- moveTo$2(path, rx, 0);
9479
+ let startRadian = 0, radian;
9480
+ if (startAngle) {
9481
+ startRadian = startAngle * OneRadian;
9482
+ moveTo$2(path, rx + rx * sin$2(startRadian), ry - ry * cos$2(startRadian));
9483
+ } else moveTo$2(path, rx, 0);
9476
9484
  for (let i = 1; i < sides; i++) {
9477
- lineTo$2(path, rx + rx * sin$2(i * 2 * PI$2 / sides), ry - ry * cos$2(i * 2 * PI$2 / sides));
9485
+ radian = i * 2 * PI$2 / sides + startRadian;
9486
+ lineTo$2(path, rx + rx * sin$2(radian), ry - ry * cos$2(radian));
9478
9487
  }
9479
9488
  closePath$1(path);
9480
9489
  }
@@ -9485,6 +9494,8 @@ __decorate([ dataProcessor(PolygonData) ], Polygon.prototype, "__", void 0);
9485
9494
 
9486
9495
  __decorate([ pathType(3) ], Polygon.prototype, "sides", void 0);
9487
9496
 
9497
+ __decorate([ pathType(0) ], Polygon.prototype, "startAngle", void 0);
9498
+
9488
9499
  __decorate([ pathType() ], Polygon.prototype, "points", void 0);
9489
9500
 
9490
9501
  __decorate([ pathType(0) ], Polygon.prototype, "curve", void 0);
@@ -9500,12 +9511,17 @@ let Star = class Star extends UI {
9500
9511
  return "Star";
9501
9512
  }
9502
9513
  __updatePath() {
9503
- const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9514
+ const {width: width, height: height, corners: corners, innerRadius: innerRadius, startAngle: startAngle} = this.__;
9504
9515
  const rx = width / 2, ry = height / 2;
9505
9516
  const path = this.__.path = [];
9506
- moveTo$1(path, rx, 0);
9517
+ let startRadian = 0, radian;
9518
+ if (startAngle) {
9519
+ startRadian = startAngle * OneRadian;
9520
+ moveTo$1(path, rx + rx * sin$1(startRadian), ry - ry * cos$1(startRadian));
9521
+ } else moveTo$1(path, rx, 0);
9507
9522
  for (let i = 1; i < corners * 2; i++) {
9508
- lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin$1(i * PI$1 / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos$1(i * PI$1 / corners));
9523
+ radian = i * PI$1 / corners + startRadian;
9524
+ lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin$1(radian), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos$1(radian));
9509
9525
  }
9510
9526
  closePath(path);
9511
9527
  }
@@ -9517,6 +9533,8 @@ __decorate([ pathType(5) ], Star.prototype, "corners", void 0);
9517
9533
 
9518
9534
  __decorate([ pathType(.382) ], Star.prototype, "innerRadius", void 0);
9519
9535
 
9536
+ __decorate([ pathType(0) ], Star.prototype, "startAngle", void 0);
9537
+
9520
9538
  Star = __decorate([ registerUI() ], Star);
9521
9539
 
9522
9540
  const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
@@ -9875,7 +9893,8 @@ let Pen = class Pen extends Group {
9875
9893
  return this;
9876
9894
  }
9877
9895
  paint() {
9878
- if (!this.pathElement.__layout.boxChanged) this.pathElement.forceUpdate("path");
9896
+ const {pathElement: pathElement} = this;
9897
+ if (!pathElement.__layout.boxChanged) pathElement.forceUpdate("path");
9879
9898
  }
9880
9899
  };
9881
9900
 
@@ -10117,7 +10136,7 @@ const DragBoundsHelper = {
10117
10136
  return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
10118
10137
  },
10119
10138
  isInnerMode(content, dragBounds, dragBoundsType, sideType) {
10120
- return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
10139
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && float$3(content[sideType]) > float$3(dragBounds[sideType]);
10121
10140
  },
10122
10141
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
10123
10142
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
@@ -11475,6 +11494,8 @@ function stroke(stroke, ui, canvas, renderOptions) {
11475
11494
  if (!data.__strokeWidth) return;
11476
11495
  if (data.__font) {
11477
11496
  Paint.strokeText(stroke, ui, canvas, renderOptions);
11497
+ } else if (data.__pathForStroke) {
11498
+ Paint.fillStroke(stroke, ui, canvas, renderOptions);
11478
11499
  } else {
11479
11500
  switch (data.strokeAlign) {
11480
11501
  case "center":
@@ -15725,10 +15746,22 @@ function scaleResizeFontSize(leaf, scaleX, scaleY, direction) {
15725
15746
  }
15726
15747
  }
15727
15748
  leaf.fontSize *= fontScale;
15728
- const data = leaf.__, {padding: padding} = data;
15749
+ const data = leaf.__, {padding: padding, lineHeight: lineHeight, letterSpacing: letterSpacing} = data;
15729
15750
  if (padding) leaf.padding = isArray(padding) ? padding.map(item => item * fontScale) : padding * fontScale;
15730
15751
  if (!data.__autoWidth) leaf.width *= fontScale;
15731
15752
  if (!data.__autoHeight) leaf.height *= fontScale;
15753
+ if (isObject(lineHeight)) {
15754
+ if (lineHeight.type === "px") data.lineHeight = {
15755
+ type: "px",
15756
+ value: lineHeight.value * fontScale
15757
+ };
15758
+ } else if (lineHeight) data.lineHeight = lineHeight * fontScale;
15759
+ if (isObject(letterSpacing)) {
15760
+ if (letterSpacing.type === "px") data.letterSpacing = {
15761
+ type: "px",
15762
+ value: letterSpacing.value * fontScale
15763
+ };
15764
+ } else if (letterSpacing) data.letterSpacing = letterSpacing * fontScale;
15732
15765
  }
15733
15766
 
15734
15767
  function scaleResizePath(leaf, scaleX, scaleY) {