@leafer-draw/miniapp 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.
@@ -817,6 +817,11 @@ const PointHelper = {
817
817
  toOuterOf(t, matrix, to) {
818
818
  toOuterPoint$3(matrix, t, to);
819
819
  },
820
+ toVertical(t, rotation, verticalDistance, to) {
821
+ const r = rotation * OneRadian;
822
+ t.x += -Math.sin(r) * verticalDistance;
823
+ t.y += Math.cos(r) * verticalDistance;
824
+ },
820
825
  getCenter(t, to) {
821
826
  return {
822
827
  x: t.x + (to.x - t.x) / 2,
@@ -1256,7 +1261,6 @@ const BoundsHelper = {
1256
1261
  },
1257
1262
  copyAndSpread(t, bounds, spread, isShrink, side) {
1258
1263
  const {x: x, y: y, width: width, height: height} = bounds;
1259
- if (!spread) spread = 0;
1260
1264
  if (isArray(spread)) {
1261
1265
  const four = fourNumber(spread);
1262
1266
  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() {
@@ -8488,8 +8493,9 @@ let UI = UI_1 = class UI extends Leaf {
8488
8493
  this.__drawPathByData(canvas, data.__pathForRender);
8489
8494
  }
8490
8495
  __drawPath(canvas) {
8496
+ const data = this.__;
8491
8497
  canvas.beginPath();
8492
- this.__drawPathByData(canvas, this.__.path, true);
8498
+ data.__usePointsMode ? PathDrawer.drawPathByPoints(canvas, data.points, data.closed) : this.__drawPathByData(canvas, data.path, true);
8493
8499
  }
8494
8500
  __drawPathByData(drawer, data, ignoreCornerRadius) {
8495
8501
  data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, ignoreCornerRadius);
@@ -9346,6 +9352,9 @@ let Polygon = class Polygon extends UI {
9346
9352
  get __tag() {
9347
9353
  return "Polygon";
9348
9354
  }
9355
+ get isPointsMode() {
9356
+ return this.points && !this.pathInputed;
9357
+ }
9349
9358
  __updatePath() {
9350
9359
  const data = this.__;
9351
9360
  const path = data.path = [];
@@ -9423,6 +9432,9 @@ let Line = class Line extends UI {
9423
9432
  get __tag() {
9424
9433
  return "Line";
9425
9434
  }
9435
+ get isPointsMode() {
9436
+ return this.points && !this.pathInputed;
9437
+ }
9426
9438
  get toPoint() {
9427
9439
  const {width: width, rotation: rotation} = this.__;
9428
9440
  const to = getPointData();
@@ -9581,7 +9593,7 @@ let Text = class Text extends UI {
9581
9593
  data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
9582
9594
  stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
9583
9595
  stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
9584
- stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
9596
+ stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
9585
9597
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
9586
9598
  }
9587
9599
  __updateBoxBounds() {
@@ -9606,7 +9618,7 @@ let Text = class Text extends UI {
9606
9618
  this.__updateNaturalSize();
9607
9619
  } else super.__updateBoxBounds();
9608
9620
  if (italic) b.width += fontSize * .16;
9609
- DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9621
+ DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds) && !data.motionText);
9610
9622
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9611
9623
  }
9612
9624
  __updateRenderSpread() {
@@ -9791,7 +9803,8 @@ function fillPathOrText(ui, canvas, renderOptions) {
9791
9803
  ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
9792
9804
  }
9793
9805
 
9794
- function fillText(ui, canvas, _renderOptions) {
9806
+ function fillText(ui, canvas, renderOptions) {
9807
+ if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
9795
9808
  const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
9796
9809
  if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
9797
9810
  let row;
@@ -11153,7 +11166,8 @@ const TextMode = 2;
11153
11166
 
11154
11167
  function layoutChar(drawData, style, width, _height) {
11155
11168
  const {rows: rows} = drawData;
11156
- const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
11169
+ const {textAlign: textAlign, paraIndent: paraIndent} = style;
11170
+ const useLetter = style.__letterSpacing || style.motionText;
11157
11171
  const justifyLast = width && textAlign.includes("both");
11158
11172
  const justify = justifyLast || width && textAlign.includes("justify");
11159
11173
  const justifyLetter = justify && textAlign.includes("letter");
@@ -11166,8 +11180,8 @@ function layoutChar(drawData, style, width, _height) {
11166
11180
  remainingWidth = width - row.width - indentWidth;
11167
11181
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
11168
11182
  }
11169
- mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
11170
- if (row.isOverflow && !__letterSpacing) row.textMode = true;
11183
+ mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
11184
+ if (row.isOverflow && !useLetter) row.textMode = true;
11171
11185
  if (mode === TextMode) {
11172
11186
  row.x += indentWidth;
11173
11187
  toTextChar$1(row);
@@ -11368,6 +11382,7 @@ function getDrawData(content, style) {
11368
11382
  let width = style.__getInput("width") || 0;
11369
11383
  let height = style.__getInput("height") || 0;
11370
11384
  const {__padding: padding} = style;
11385
+ if (style.motionText) width = height = 0;
11371
11386
  if (padding) {
11372
11387
  if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
11373
11388
  if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];