leafer-ui 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$1, 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
  const debug$5 = Debug.get("LeaferCanvas");
6991
6996
 
@@ -8723,8 +8728,9 @@ let UI = UI_1 = class UI extends Leaf {
8723
8728
  this.__drawPathByData(canvas, data.__pathForRender);
8724
8729
  }
8725
8730
  __drawPath(canvas) {
8731
+ const data = this.__;
8726
8732
  canvas.beginPath();
8727
- this.__drawPathByData(canvas, this.__.path, true);
8733
+ data.__usePointsMode ? PathDrawer.drawPathByPoints(canvas, data.points, data.closed) : this.__drawPathByData(canvas, data.path, true);
8728
8734
  }
8729
8735
  __drawPathByData(drawer, data, ignoreCornerRadius) {
8730
8736
  data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, ignoreCornerRadius);
@@ -9581,6 +9587,9 @@ let Polygon = class Polygon extends UI {
9581
9587
  get __tag() {
9582
9588
  return "Polygon";
9583
9589
  }
9590
+ get isPointsMode() {
9591
+ return this.points && !this.pathInputed;
9592
+ }
9584
9593
  __updatePath() {
9585
9594
  const data = this.__;
9586
9595
  const path = data.path = [];
@@ -9658,6 +9667,9 @@ let Line = class Line extends UI {
9658
9667
  get __tag() {
9659
9668
  return "Line";
9660
9669
  }
9670
+ get isPointsMode() {
9671
+ return this.points && !this.pathInputed;
9672
+ }
9661
9673
  get toPoint() {
9662
9674
  const {width: width, rotation: rotation} = this.__;
9663
9675
  const to = getPointData();
@@ -9816,7 +9828,7 @@ let Text = class Text extends UI {
9816
9828
  data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
9817
9829
  stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
9818
9830
  stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
9819
- stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
9831
+ stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
9820
9832
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
9821
9833
  }
9822
9834
  __updateBoxBounds() {
@@ -9841,7 +9853,7 @@ let Text = class Text extends UI {
9841
9853
  this.__updateNaturalSize();
9842
9854
  } else super.__updateBoxBounds();
9843
9855
  if (italic) b.width += fontSize * .16;
9844
- DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9856
+ DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds) && !data.motionText);
9845
9857
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9846
9858
  }
9847
9859
  __updateRenderSpread() {
@@ -11444,8 +11456,10 @@ ui$1.__hit = function(inner, forceHitFill) {
11444
11456
  if (!needHitFillPath && !needHitStrokePath) return false;
11445
11457
  const radiusWidth = inner.radiusX * 2;
11446
11458
  let hitWidth = radiusWidth;
11459
+ let {strokeAlign: strokeAlign} = data;
11460
+ if (data.motionText) hitWidth += data.fontSize / 2, strokeAlign = "center";
11447
11461
  if (needHitStrokePath) {
11448
- switch (data.strokeAlign) {
11462
+ switch (strokeAlign) {
11449
11463
  case "inside":
11450
11464
  hitWidth += strokeWidth * 2;
11451
11465
  if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth)) return true;
@@ -11479,9 +11493,9 @@ rect.__hitFill = box$1.__hitFill = function(inner) {
11479
11493
  };
11480
11494
 
11481
11495
  Text.prototype.__drawHitPath = function(canvas) {
11482
- const {__lineHeight: __lineHeight, fontSize: fontSize, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __textDrawData: data} = this.__;
11496
+ const data = this.__, {__lineHeight: __lineHeight, fontSize: fontSize, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __textDrawData: drawData} = data;
11483
11497
  canvas.beginPath();
11484
- if (__letterSpacing < 0) this.__drawPathByBox(canvas); else data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
11498
+ if (data.motionText) this.__drawPathByData(canvas, data.__pathForMotionText); else if (__letterSpacing < 0) this.__drawPathByBox(canvas); else drawData.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
11485
11499
  };
11486
11500
 
11487
11501
  Group.prototype.pick = function(hitPoint, options) {
@@ -11841,8 +11855,7 @@ class Interaction extends InteractionBase {
11841
11855
  destroy() {
11842
11856
  if (this.view) {
11843
11857
  super.destroy();
11844
- this.view = null;
11845
- this.touches = null;
11858
+ this.view = this.touches = null;
11846
11859
  }
11847
11860
  }
11848
11861
  }
@@ -11889,7 +11902,8 @@ function fillPathOrText(ui, canvas, renderOptions) {
11889
11902
  ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
11890
11903
  }
11891
11904
 
11892
- function fillText(ui, canvas, _renderOptions) {
11905
+ function fillText(ui, canvas, renderOptions) {
11906
+ if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
11893
11907
  const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
11894
11908
  if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
11895
11909
  let row;
@@ -13251,7 +13265,8 @@ const TextMode = 2;
13251
13265
 
13252
13266
  function layoutChar(drawData, style, width, _height) {
13253
13267
  const {rows: rows} = drawData;
13254
- const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
13268
+ const {textAlign: textAlign, paraIndent: paraIndent} = style;
13269
+ const useLetter = style.__letterSpacing || style.motionText;
13255
13270
  const justifyLast = width && textAlign.includes("both");
13256
13271
  const justify = justifyLast || width && textAlign.includes("justify");
13257
13272
  const justifyLetter = justify && textAlign.includes("letter");
@@ -13264,8 +13279,8 @@ function layoutChar(drawData, style, width, _height) {
13264
13279
  remainingWidth = width - row.width - indentWidth;
13265
13280
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
13266
13281
  }
13267
- mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
13268
- if (row.isOverflow && !__letterSpacing) row.textMode = true;
13282
+ mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
13283
+ if (row.isOverflow && !useLetter) row.textMode = true;
13269
13284
  if (mode === TextMode) {
13270
13285
  row.x += indentWidth;
13271
13286
  toTextChar$1(row);
@@ -13466,6 +13481,7 @@ function getDrawData(content, style) {
13466
13481
  let width = style.__getInput("width") || 0;
13467
13482
  let height = style.__getInput("height") || 0;
13468
13483
  const {__padding: padding} = style;
13484
+ if (style.motionText) width = height = 0;
13469
13485
  if (padding) {
13470
13486
  if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
13471
13487
  if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];