@leafer-draw/worker 2.1.10 → 2.2.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.
@@ -856,6 +856,11 @@ const PointHelper = {
856
856
  toOuterOf(t, matrix, to) {
857
857
  toOuterPoint$3(matrix, t, to);
858
858
  },
859
+ toVertical(t, rotation, verticalDistance, to) {
860
+ const r = rotation * OneRadian;
861
+ t.x += -Math.sin(r) * verticalDistance;
862
+ t.y += Math.cos(r) * verticalDistance;
863
+ },
859
864
  getCenter(t, to) {
860
865
  return {
861
866
  x: t.x + (to.x - t.x) / 2,
@@ -1295,7 +1300,6 @@ const BoundsHelper = {
1295
1300
  },
1296
1301
  copyAndSpread(t, bounds, spread, isShrink, side) {
1297
1302
  const {x: x, y: y, width: width, height: height} = bounds;
1298
- if (!spread) spread = 0;
1299
1303
  if (isArray(spread)) {
1300
1304
  const four = fourNumber(spread);
1301
1305
  isShrink ? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0]) : B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
@@ -3577,7 +3581,8 @@ const PathDrawer = {
3577
3581
  return;
3578
3582
  }
3579
3583
  }
3580
- }
3584
+ },
3585
+ drawPathByPoints(_drawer, _points, _closed) {}
3581
3586
  };
3582
3587
 
3583
3588
  const {M: M$1, L: L$2, C: C, Q: Q, Z: Z$1, N: N, D: D, X: X, G: G, F: F$1, O: O, P: P, U: U} = PathCommandMap;
@@ -6985,7 +6990,7 @@ class LeafLevelList {
6985
6990
  }
6986
6991
  }
6987
6992
 
6988
- const version = "2.1.10";
6993
+ const version = "2.2.0";
6989
6994
 
6990
6995
  class LeaferCanvas extends LeaferCanvasBase {
6991
6996
  get allowBackgroundColor() {
@@ -8329,8 +8334,9 @@ let UI = UI_1 = class UI extends Leaf {
8329
8334
  this.__drawPathByData(canvas, data.__pathForRender);
8330
8335
  }
8331
8336
  __drawPath(canvas) {
8337
+ const data = this.__;
8332
8338
  canvas.beginPath();
8333
- this.__drawPathByData(canvas, this.__.path, true);
8339
+ data.__usePointsMode ? PathDrawer.drawPathByPoints(canvas, data.points, data.closed) : this.__drawPathByData(canvas, data.path, true);
8334
8340
  }
8335
8341
  __drawPathByData(drawer, data, ignoreCornerRadius) {
8336
8342
  data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, ignoreCornerRadius);
@@ -9187,6 +9193,9 @@ let Polygon = class Polygon extends UI {
9187
9193
  get __tag() {
9188
9194
  return "Polygon";
9189
9195
  }
9196
+ get isPointsMode() {
9197
+ return this.points && !this.pathInputed;
9198
+ }
9190
9199
  __updatePath() {
9191
9200
  const data = this.__;
9192
9201
  const path = data.path = [];
@@ -9264,6 +9273,9 @@ let Line = class Line extends UI {
9264
9273
  get __tag() {
9265
9274
  return "Line";
9266
9275
  }
9276
+ get isPointsMode() {
9277
+ return this.points && !this.pathInputed;
9278
+ }
9267
9279
  get toPoint() {
9268
9280
  const {width: width, rotation: rotation} = this.__;
9269
9281
  const to = getPointData();
@@ -9422,7 +9434,7 @@ let Text = class Text extends UI {
9422
9434
  data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
9423
9435
  stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
9424
9436
  stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
9425
- stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
9437
+ stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
9426
9438
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
9427
9439
  }
9428
9440
  __updateBoxBounds() {
@@ -9447,7 +9459,7 @@ let Text = class Text extends UI {
9447
9459
  this.__updateNaturalSize();
9448
9460
  } else super.__updateBoxBounds();
9449
9461
  if (italic) b.width += fontSize * .16;
9450
- DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9462
+ DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds) && !data.motionText);
9451
9463
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9452
9464
  }
9453
9465
  __updateRenderSpread() {
@@ -9632,7 +9644,8 @@ function fillPathOrText(ui, canvas, renderOptions) {
9632
9644
  ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
9633
9645
  }
9634
9646
 
9635
- function fillText(ui, canvas, _renderOptions) {
9647
+ function fillText(ui, canvas, renderOptions) {
9648
+ if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
9636
9649
  const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
9637
9650
  if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
9638
9651
  let row;
@@ -10994,7 +11007,8 @@ const TextMode = 2;
10994
11007
 
10995
11008
  function layoutChar(drawData, style, width, _height) {
10996
11009
  const {rows: rows} = drawData;
10997
- const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
11010
+ const {textAlign: textAlign, paraIndent: paraIndent} = style;
11011
+ const useLetter = style.__letterSpacing || style.motionText;
10998
11012
  const justifyLast = width && textAlign.includes("both");
10999
11013
  const justify = justifyLast || width && textAlign.includes("justify");
11000
11014
  const justifyLetter = justify && textAlign.includes("letter");
@@ -11007,8 +11021,8 @@ function layoutChar(drawData, style, width, _height) {
11007
11021
  remainingWidth = width - row.width - indentWidth;
11008
11022
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
11009
11023
  }
11010
- mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
11011
- if (row.isOverflow && !__letterSpacing) row.textMode = true;
11024
+ mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
11025
+ if (row.isOverflow && !useLetter) row.textMode = true;
11012
11026
  if (mode === TextMode) {
11013
11027
  row.x += indentWidth;
11014
11028
  toTextChar$1(row);
@@ -11209,6 +11223,7 @@ function getDrawData(content, style) {
11209
11223
  let width = style.__getInput("width") || 0;
11210
11224
  let height = style.__getInput("height") || 0;
11211
11225
  const {__padding: padding} = style;
11226
+ if (style.motionText) width = height = 0;
11212
11227
  if (padding) {
11213
11228
  if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
11214
11229
  if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];