leafer-game 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.
- package/dist/web.js +85 -34
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +89 -34
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +12 -12
package/dist/web.module.js
CHANGED
|
@@ -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.
|
|
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$5.__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 (
|
|
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:
|
|
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
|
|
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,
|
|
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
|
|
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 =
|
|
13274
|
-
if (row.isOverflow && !
|
|
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];
|
|
@@ -15266,7 +15276,7 @@ const HighCurveHelper = {
|
|
|
15266
15276
|
},
|
|
15267
15277
|
getMotionPathData(data) {
|
|
15268
15278
|
let total = 0, distance, segments = [];
|
|
15269
|
-
let i = 0, x = 0, y = 0, toX, toY, command;
|
|
15279
|
+
let i = 0, x = 0, y = 0, toX, toY, command, closed;
|
|
15270
15280
|
const len = data.length;
|
|
15271
15281
|
while (i < len) {
|
|
15272
15282
|
command = data[i];
|
|
@@ -15291,6 +15301,7 @@ const HighCurveHelper = {
|
|
|
15291
15301
|
break;
|
|
15292
15302
|
|
|
15293
15303
|
case Z:
|
|
15304
|
+
closed = true;
|
|
15294
15305
|
i += 1;
|
|
15295
15306
|
|
|
15296
15307
|
default:
|
|
@@ -15302,13 +15313,16 @@ const HighCurveHelper = {
|
|
|
15302
15313
|
return {
|
|
15303
15314
|
total: total,
|
|
15304
15315
|
segments: segments,
|
|
15305
|
-
data: data
|
|
15316
|
+
data: data,
|
|
15317
|
+
closed: closed
|
|
15306
15318
|
};
|
|
15307
15319
|
},
|
|
15308
|
-
getDistancePoint(distanceData, motionDistance, motionPrecision) {
|
|
15309
|
-
const {segments: segments, data: data} = distanceData;
|
|
15310
|
-
motionDistance = UnitConvert.number(motionDistance,
|
|
15311
|
-
|
|
15320
|
+
getDistancePoint(distanceData, motionDistance, motionPrecision, offsetX) {
|
|
15321
|
+
const {segments: segments, data: data, total: total} = distanceData;
|
|
15322
|
+
motionDistance = UnitConvert.number(motionDistance, total);
|
|
15323
|
+
if (offsetX) motionDistance += offsetX;
|
|
15324
|
+
if (motionDistance > total) motionDistance = motionDistance % total;
|
|
15325
|
+
let nowDistance = 0, distance, to = {};
|
|
15312
15326
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
15313
15327
|
let x1, y1, x2, y2, t;
|
|
15314
15328
|
const len = data.length;
|
|
@@ -15320,15 +15334,20 @@ const HighCurveHelper = {
|
|
|
15320
15334
|
toX = data[i + 1];
|
|
15321
15335
|
toY = data[i + 2];
|
|
15322
15336
|
distance = segments[index];
|
|
15323
|
-
if (
|
|
15324
|
-
if (!i) x = toX, y = toY;
|
|
15325
|
-
tempFrom.x = x;
|
|
15326
|
-
tempFrom.y = y;
|
|
15337
|
+
if (nowDistance + distance >= motionDistance || !distanceData.total) {
|
|
15327
15338
|
to.x = toX;
|
|
15328
15339
|
to.y = toY;
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
|
|
15340
|
+
if (i) {
|
|
15341
|
+
tempFrom.x = x;
|
|
15342
|
+
tempFrom.y = y;
|
|
15343
|
+
PointHelper.getDistancePoint(tempFrom, to, motionDistance - nowDistance, true);
|
|
15344
|
+
to.rotation = PointHelper.getAngle(tempFrom, to);
|
|
15345
|
+
return to;
|
|
15346
|
+
} else {
|
|
15347
|
+
const nextPoint = HighCurveHelper.getDistancePoint(distanceData, motionPrecision, motionPrecision, offsetX);
|
|
15348
|
+
to.rotation = nextPoint.rotation;
|
|
15349
|
+
return to;
|
|
15350
|
+
}
|
|
15332
15351
|
}
|
|
15333
15352
|
x = toX;
|
|
15334
15353
|
y = toY;
|
|
@@ -15339,9 +15358,9 @@ const HighCurveHelper = {
|
|
|
15339
15358
|
toX = data[i + 5];
|
|
15340
15359
|
toY = data[i + 6];
|
|
15341
15360
|
distance = segments[index];
|
|
15342
|
-
if (
|
|
15361
|
+
if (nowDistance + distance >= motionDistance) {
|
|
15343
15362
|
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
15344
|
-
t = HighBezierHelper.getT(motionDistance -
|
|
15363
|
+
t = HighBezierHelper.getT(motionDistance - nowDistance, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
15345
15364
|
BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
|
|
15346
15365
|
to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
|
|
15347
15366
|
return to;
|
|
@@ -15358,7 +15377,7 @@ const HighCurveHelper = {
|
|
|
15358
15377
|
distance = 0;
|
|
15359
15378
|
}
|
|
15360
15379
|
index++;
|
|
15361
|
-
|
|
15380
|
+
nowDistance += distance;
|
|
15362
15381
|
}
|
|
15363
15382
|
return to;
|
|
15364
15383
|
},
|
|
@@ -15457,26 +15476,57 @@ const {updateMatrix: updateMatrix, updateAllMatrix: updateAllMatrix} = LeafHelpe
|
|
|
15457
15476
|
|
|
15458
15477
|
const {updateBounds: updateBounds} = BranchHelper;
|
|
15459
15478
|
|
|
15479
|
+
const {toVertical: toVertical} = PointHelper;
|
|
15480
|
+
|
|
15460
15481
|
UI.addAttr("motionPath", undefined, motionPathType);
|
|
15461
15482
|
|
|
15462
15483
|
UI.addAttr("motionPrecision", 1, motionPathType);
|
|
15463
15484
|
|
|
15464
15485
|
UI.addAttr("motion", undefined, motionPathType);
|
|
15465
15486
|
|
|
15487
|
+
UI.addAttr("motionVertical", "below", motionPathType);
|
|
15488
|
+
|
|
15466
15489
|
UI.addAttr("motionRotation", true, motionPathType);
|
|
15467
15490
|
|
|
15491
|
+
ui$1.getMotionPath = function() {
|
|
15492
|
+
return getMotionPath(this);
|
|
15493
|
+
};
|
|
15494
|
+
|
|
15468
15495
|
ui$1.getMotionPathData = function() {
|
|
15469
15496
|
return getMotionPathData(getMotionPath(this));
|
|
15470
15497
|
};
|
|
15471
15498
|
|
|
15472
|
-
ui$1.
|
|
15473
|
-
|
|
15474
|
-
|
|
15499
|
+
ui$1.getMotionContentHeight = function() {
|
|
15500
|
+
return this.__layout.boxBounds.height;
|
|
15501
|
+
};
|
|
15502
|
+
|
|
15503
|
+
ui$1.getMotionPoint = function(motionDistance, motionVertical, pathElement, offsetX = 0, offsetY = 0) {
|
|
15504
|
+
if (!pathElement) pathElement = getMotionPath(this);
|
|
15505
|
+
const data = getMotionPathData(pathElement);
|
|
15475
15506
|
if (!data.total) return {};
|
|
15476
|
-
const point = HighCurveHelper.getDistancePoint(data, motionDistance,
|
|
15477
|
-
MatrixHelper.toOuterPoint(path.localTransform, point);
|
|
15507
|
+
const point = HighCurveHelper.getDistancePoint(data, motionDistance, pathElement.motionPrecision, offsetX);
|
|
15478
15508
|
const {motionRotation: motionRotation} = this;
|
|
15479
|
-
if (
|
|
15509
|
+
if (isNumber(motionRotation)) point.rotation += motionRotation;
|
|
15510
|
+
let verticalType, verticalOffset;
|
|
15511
|
+
if (isObject(motionVertical)) verticalType = motionVertical.type, verticalOffset = motionVertical.offset; else if (isNumber(motionVertical)) verticalOffset = motionVertical; else verticalType = motionVertical;
|
|
15512
|
+
if (verticalType !== "below" || offsetY) {
|
|
15513
|
+
const {rotation: rotation} = point, height = this.getMotionContentHeight();
|
|
15514
|
+
if (verticalOffset) offsetY += verticalType === "above" ? -verticalOffset : verticalOffset;
|
|
15515
|
+
switch (verticalType) {
|
|
15516
|
+
case "above":
|
|
15517
|
+
toVertical(point, rotation, -height + offsetY);
|
|
15518
|
+
break;
|
|
15519
|
+
|
|
15520
|
+
case "center":
|
|
15521
|
+
toVertical(point, rotation, -height / 2 + offsetY);
|
|
15522
|
+
break;
|
|
15523
|
+
|
|
15524
|
+
case "below":
|
|
15525
|
+
default:
|
|
15526
|
+
toVertical(point, rotation, offsetY);
|
|
15527
|
+
}
|
|
15528
|
+
}
|
|
15529
|
+
MatrixHelper.toOuterPoint(pathElement.localTransform, point);
|
|
15480
15530
|
return point;
|
|
15481
15531
|
};
|
|
15482
15532
|
|
|
@@ -15508,7 +15558,11 @@ function updateMotion(leaf) {
|
|
|
15508
15558
|
const data = getMotionPathData(leaf);
|
|
15509
15559
|
if (data.total) leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
|
|
15510
15560
|
} else {
|
|
15511
|
-
leaf.
|
|
15561
|
+
if (leaf.motionText) leaf.__updateMotionText(); else {
|
|
15562
|
+
const point = leaf.getMotionPoint(motion);
|
|
15563
|
+
if (leaf.motionRotation === false) delete point.rotation;
|
|
15564
|
+
leaf.set(point);
|
|
15565
|
+
}
|
|
15512
15566
|
if (!leaf.__hasAutoLayout) {
|
|
15513
15567
|
if (leaf.isBranch) updateAllMatrix(leaf), updateBounds(leaf, leaf); else updateMatrix(leaf);
|
|
15514
15568
|
}
|
|
@@ -15530,7 +15584,8 @@ function getMotionPath(leaf) {
|
|
|
15530
15584
|
function getMotionPathData(leaf) {
|
|
15531
15585
|
const data = leaf.__;
|
|
15532
15586
|
if (data.__pathForMotion) return data.__pathForMotion;
|
|
15533
|
-
|
|
15587
|
+
const path = data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true));
|
|
15588
|
+
return path;
|
|
15534
15589
|
}
|
|
15535
15590
|
|
|
15536
15591
|
const {Yes: Yes, NoAndSkip: NoAndSkip, YesAndSkip: YesAndSkip} = Answer;
|