leafer-ui 2.1.11 → 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,
@@ -6985,7 +6990,7 @@ class LeafLevelList {
6985
6990
  }
6986
6991
  }
6987
6992
 
6988
- const version = "2.1.11";
6993
+ const version = "2.2.0";
6989
6994
 
6990
6995
  const debug$5 = Debug.get("LeaferCanvas");
6991
6996
 
@@ -9823,7 +9828,7 @@ let Text = class Text extends UI {
9823
9828
  data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
9824
9829
  stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
9825
9830
  stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
9826
- stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
9831
+ stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
9827
9832
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
9828
9833
  }
9829
9834
  __updateBoxBounds() {
@@ -9848,7 +9853,7 @@ let Text = class Text extends UI {
9848
9853
  this.__updateNaturalSize();
9849
9854
  } else super.__updateBoxBounds();
9850
9855
  if (italic) b.width += fontSize * .16;
9851
- DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9856
+ DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds) && !data.motionText);
9852
9857
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9853
9858
  }
9854
9859
  __updateRenderSpread() {
@@ -11451,8 +11456,10 @@ ui$1.__hit = function(inner, forceHitFill) {
11451
11456
  if (!needHitFillPath && !needHitStrokePath) return false;
11452
11457
  const radiusWidth = inner.radiusX * 2;
11453
11458
  let hitWidth = radiusWidth;
11459
+ let {strokeAlign: strokeAlign} = data;
11460
+ if (data.motionText) hitWidth += data.fontSize / 2, strokeAlign = "center";
11454
11461
  if (needHitStrokePath) {
11455
- switch (data.strokeAlign) {
11462
+ switch (strokeAlign) {
11456
11463
  case "inside":
11457
11464
  hitWidth += strokeWidth * 2;
11458
11465
  if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth)) return true;
@@ -11486,9 +11493,9 @@ rect.__hitFill = box$1.__hitFill = function(inner) {
11486
11493
  };
11487
11494
 
11488
11495
  Text.prototype.__drawHitPath = function(canvas) {
11489
- 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;
11490
11497
  canvas.beginPath();
11491
- 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));
11492
11499
  };
11493
11500
 
11494
11501
  Group.prototype.pick = function(hitPoint, options) {
@@ -11895,7 +11902,8 @@ function fillPathOrText(ui, canvas, renderOptions) {
11895
11902
  ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
11896
11903
  }
11897
11904
 
11898
- function fillText(ui, canvas, _renderOptions) {
11905
+ function fillText(ui, canvas, renderOptions) {
11906
+ if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
11899
11907
  const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
11900
11908
  if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
11901
11909
  let row;
@@ -13257,7 +13265,8 @@ const TextMode = 2;
13257
13265
 
13258
13266
  function layoutChar(drawData, style, width, _height) {
13259
13267
  const {rows: rows} = drawData;
13260
- const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
13268
+ const {textAlign: textAlign, paraIndent: paraIndent} = style;
13269
+ const useLetter = style.__letterSpacing || style.motionText;
13261
13270
  const justifyLast = width && textAlign.includes("both");
13262
13271
  const justify = justifyLast || width && textAlign.includes("justify");
13263
13272
  const justifyLetter = justify && textAlign.includes("letter");
@@ -13270,8 +13279,8 @@ function layoutChar(drawData, style, width, _height) {
13270
13279
  remainingWidth = width - row.width - indentWidth;
13271
13280
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
13272
13281
  }
13273
- mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
13274
- 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;
13275
13284
  if (mode === TextMode) {
13276
13285
  row.x += indentWidth;
13277
13286
  toTextChar$1(row);
@@ -13472,6 +13481,7 @@ function getDrawData(content, style) {
13472
13481
  let width = style.__getInput("width") || 0;
13473
13482
  let height = style.__getInput("height") || 0;
13474
13483
  const {__padding: padding} = style;
13484
+ if (style.motionText) width = height = 0;
13475
13485
  if (padding) {
13476
13486
  if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
13477
13487
  if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];