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.js
CHANGED
|
@@ -811,6 +811,11 @@ var LeaferUI = function(exports) {
|
|
|
811
811
|
toOuterOf(t, matrix, to) {
|
|
812
812
|
toOuterPoint$3(matrix, t, to);
|
|
813
813
|
},
|
|
814
|
+
toVertical(t, rotation, verticalDistance, to) {
|
|
815
|
+
const r = rotation * OneRadian;
|
|
816
|
+
t.x += -Math.sin(r) * verticalDistance;
|
|
817
|
+
t.y += Math.cos(r) * verticalDistance;
|
|
818
|
+
},
|
|
814
819
|
getCenter(t, to) {
|
|
815
820
|
return {
|
|
816
821
|
x: t.x + (to.x - t.x) / 2,
|
|
@@ -6569,7 +6574,7 @@ var LeaferUI = function(exports) {
|
|
|
6569
6574
|
this.levelMap = null;
|
|
6570
6575
|
}
|
|
6571
6576
|
}
|
|
6572
|
-
const version = "2.
|
|
6577
|
+
const version = "2.2.0";
|
|
6573
6578
|
const debug$5 = Debug.get("LeaferCanvas");
|
|
6574
6579
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6575
6580
|
set zIndex(zIndex) {
|
|
@@ -9165,7 +9170,7 @@ var LeaferUI = function(exports) {
|
|
|
9165
9170
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9166
9171
|
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9167
9172
|
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9168
|
-
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
9173
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
|
|
9169
9174
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9170
9175
|
}
|
|
9171
9176
|
__updateBoxBounds() {
|
|
@@ -9190,7 +9195,7 @@ var LeaferUI = function(exports) {
|
|
|
9190
9195
|
this.__updateNaturalSize();
|
|
9191
9196
|
} else super.__updateBoxBounds();
|
|
9192
9197
|
if (italic) b.width += fontSize * .16;
|
|
9193
|
-
DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
|
|
9198
|
+
DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds) && !data.motionText);
|
|
9194
9199
|
if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
|
|
9195
9200
|
}
|
|
9196
9201
|
__updateRenderSpread() {
|
|
@@ -10638,8 +10643,10 @@ var LeaferUI = function(exports) {
|
|
|
10638
10643
|
if (!needHitFillPath && !needHitStrokePath) return false;
|
|
10639
10644
|
const radiusWidth = inner.radiusX * 2;
|
|
10640
10645
|
let hitWidth = radiusWidth;
|
|
10646
|
+
let {strokeAlign: strokeAlign} = data;
|
|
10647
|
+
if (data.motionText) hitWidth += data.fontSize / 2, strokeAlign = "center";
|
|
10641
10648
|
if (needHitStrokePath) {
|
|
10642
|
-
switch (
|
|
10649
|
+
switch (strokeAlign) {
|
|
10643
10650
|
case "inside":
|
|
10644
10651
|
hitWidth += strokeWidth * 2;
|
|
10645
10652
|
if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth)) return true;
|
|
@@ -10669,9 +10676,9 @@ var LeaferUI = function(exports) {
|
|
|
10669
10676
|
return this.__hitCanvas ? ui$4.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10670
10677
|
};
|
|
10671
10678
|
exports.Text.prototype.__drawHitPath = function(canvas) {
|
|
10672
|
-
const {__lineHeight: __lineHeight, fontSize: fontSize, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __textDrawData:
|
|
10679
|
+
const data = this.__, {__lineHeight: __lineHeight, fontSize: fontSize, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __textDrawData: drawData} = data;
|
|
10673
10680
|
canvas.beginPath();
|
|
10674
|
-
if (__letterSpacing < 0) this.__drawPathByBox(canvas); else
|
|
10681
|
+
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));
|
|
10675
10682
|
};
|
|
10676
10683
|
exports.Group.prototype.pick = function(hitPoint, options) {
|
|
10677
10684
|
options || (options = emptyData);
|
|
@@ -11065,7 +11072,8 @@ var LeaferUI = function(exports) {
|
|
|
11065
11072
|
function fillPathOrText(ui, canvas, renderOptions) {
|
|
11066
11073
|
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11067
11074
|
}
|
|
11068
|
-
function fillText(ui, canvas,
|
|
11075
|
+
function fillText(ui, canvas, renderOptions) {
|
|
11076
|
+
if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
|
|
11069
11077
|
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11070
11078
|
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11071
11079
|
let row;
|
|
@@ -12298,7 +12306,8 @@ var LeaferUI = function(exports) {
|
|
|
12298
12306
|
const TextMode = 2;
|
|
12299
12307
|
function layoutChar(drawData, style, width, _height) {
|
|
12300
12308
|
const {rows: rows} = drawData;
|
|
12301
|
-
const {textAlign: textAlign, paraIndent: paraIndent
|
|
12309
|
+
const {textAlign: textAlign, paraIndent: paraIndent} = style;
|
|
12310
|
+
const useLetter = style.__letterSpacing || style.motionText;
|
|
12302
12311
|
const justifyLast = width && textAlign.includes("both");
|
|
12303
12312
|
const justify = justifyLast || width && textAlign.includes("justify");
|
|
12304
12313
|
const justifyLetter = justify && textAlign.includes("letter");
|
|
@@ -12311,8 +12320,8 @@ var LeaferUI = function(exports) {
|
|
|
12311
12320
|
remainingWidth = width - row.width - indentWidth;
|
|
12312
12321
|
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
12313
12322
|
}
|
|
12314
|
-
mode =
|
|
12315
|
-
if (row.isOverflow && !
|
|
12323
|
+
mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
12324
|
+
if (row.isOverflow && !useLetter) row.textMode = true;
|
|
12316
12325
|
if (mode === TextMode) {
|
|
12317
12326
|
row.x += indentWidth;
|
|
12318
12327
|
toTextChar$1(row);
|
|
@@ -12504,6 +12513,7 @@ var LeaferUI = function(exports) {
|
|
|
12504
12513
|
let width = style.__getInput("width") || 0;
|
|
12505
12514
|
let height = style.__getInput("height") || 0;
|
|
12506
12515
|
const {__padding: padding} = style;
|
|
12516
|
+
if (style.motionText) width = height = 0;
|
|
12507
12517
|
if (padding) {
|
|
12508
12518
|
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
12509
12519
|
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
@@ -14125,7 +14135,7 @@ var LeaferUI = function(exports) {
|
|
|
14125
14135
|
},
|
|
14126
14136
|
getMotionPathData(data) {
|
|
14127
14137
|
let total = 0, distance, segments = [];
|
|
14128
|
-
let i = 0, x = 0, y = 0, toX, toY, command;
|
|
14138
|
+
let i = 0, x = 0, y = 0, toX, toY, command, closed;
|
|
14129
14139
|
const len = data.length;
|
|
14130
14140
|
while (i < len) {
|
|
14131
14141
|
command = data[i];
|
|
@@ -14150,6 +14160,7 @@ var LeaferUI = function(exports) {
|
|
|
14150
14160
|
break;
|
|
14151
14161
|
|
|
14152
14162
|
case Z:
|
|
14163
|
+
closed = true;
|
|
14153
14164
|
i += 1;
|
|
14154
14165
|
|
|
14155
14166
|
default:
|
|
@@ -14161,13 +14172,16 @@ var LeaferUI = function(exports) {
|
|
|
14161
14172
|
return {
|
|
14162
14173
|
total: total,
|
|
14163
14174
|
segments: segments,
|
|
14164
|
-
data: data
|
|
14175
|
+
data: data,
|
|
14176
|
+
closed: closed
|
|
14165
14177
|
};
|
|
14166
14178
|
},
|
|
14167
|
-
getDistancePoint(distanceData, motionDistance, motionPrecision) {
|
|
14168
|
-
const {segments: segments, data: data} = distanceData;
|
|
14169
|
-
motionDistance = UnitConvert.number(motionDistance,
|
|
14170
|
-
|
|
14179
|
+
getDistancePoint(distanceData, motionDistance, motionPrecision, offsetX) {
|
|
14180
|
+
const {segments: segments, data: data, total: total} = distanceData;
|
|
14181
|
+
motionDistance = UnitConvert.number(motionDistance, total);
|
|
14182
|
+
if (offsetX) motionDistance += offsetX;
|
|
14183
|
+
if (motionDistance > total) motionDistance = motionDistance % total;
|
|
14184
|
+
let nowDistance = 0, distance, to = {};
|
|
14171
14185
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
14172
14186
|
let x1, y1, x2, y2, t;
|
|
14173
14187
|
const len = data.length;
|
|
@@ -14179,15 +14193,20 @@ var LeaferUI = function(exports) {
|
|
|
14179
14193
|
toX = data[i + 1];
|
|
14180
14194
|
toY = data[i + 2];
|
|
14181
14195
|
distance = segments[index];
|
|
14182
|
-
if (
|
|
14183
|
-
if (!i) x = toX, y = toY;
|
|
14184
|
-
tempFrom.x = x;
|
|
14185
|
-
tempFrom.y = y;
|
|
14196
|
+
if (nowDistance + distance >= motionDistance || !distanceData.total) {
|
|
14186
14197
|
to.x = toX;
|
|
14187
14198
|
to.y = toY;
|
|
14188
|
-
|
|
14189
|
-
|
|
14190
|
-
|
|
14199
|
+
if (i) {
|
|
14200
|
+
tempFrom.x = x;
|
|
14201
|
+
tempFrom.y = y;
|
|
14202
|
+
PointHelper.getDistancePoint(tempFrom, to, motionDistance - nowDistance, true);
|
|
14203
|
+
to.rotation = PointHelper.getAngle(tempFrom, to);
|
|
14204
|
+
return to;
|
|
14205
|
+
} else {
|
|
14206
|
+
const nextPoint = HighCurveHelper.getDistancePoint(distanceData, motionPrecision, motionPrecision, offsetX);
|
|
14207
|
+
to.rotation = nextPoint.rotation;
|
|
14208
|
+
return to;
|
|
14209
|
+
}
|
|
14191
14210
|
}
|
|
14192
14211
|
x = toX;
|
|
14193
14212
|
y = toY;
|
|
@@ -14198,9 +14217,9 @@ var LeaferUI = function(exports) {
|
|
|
14198
14217
|
toX = data[i + 5];
|
|
14199
14218
|
toY = data[i + 6];
|
|
14200
14219
|
distance = segments[index];
|
|
14201
|
-
if (
|
|
14220
|
+
if (nowDistance + distance >= motionDistance) {
|
|
14202
14221
|
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
14203
|
-
t = HighBezierHelper.getT(motionDistance -
|
|
14222
|
+
t = HighBezierHelper.getT(motionDistance - nowDistance, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
14204
14223
|
BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
|
|
14205
14224
|
to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
|
|
14206
14225
|
return to;
|
|
@@ -14217,7 +14236,7 @@ var LeaferUI = function(exports) {
|
|
|
14217
14236
|
distance = 0;
|
|
14218
14237
|
}
|
|
14219
14238
|
index++;
|
|
14220
|
-
|
|
14239
|
+
nowDistance += distance;
|
|
14221
14240
|
}
|
|
14222
14241
|
return to;
|
|
14223
14242
|
},
|
|
@@ -14308,21 +14327,48 @@ var LeaferUI = function(exports) {
|
|
|
14308
14327
|
const ui$1 = exports.UI.prototype;
|
|
14309
14328
|
const {updateMatrix: updateMatrix, updateAllMatrix: updateAllMatrix} = LeafHelper;
|
|
14310
14329
|
const {updateBounds: updateBounds} = BranchHelper;
|
|
14330
|
+
const {toVertical: toVertical} = PointHelper;
|
|
14311
14331
|
exports.UI.addAttr("motionPath", undefined, motionPathType);
|
|
14312
14332
|
exports.UI.addAttr("motionPrecision", 1, motionPathType);
|
|
14313
14333
|
exports.UI.addAttr("motion", undefined, motionPathType);
|
|
14334
|
+
exports.UI.addAttr("motionVertical", "below", motionPathType);
|
|
14314
14335
|
exports.UI.addAttr("motionRotation", true, motionPathType);
|
|
14336
|
+
ui$1.getMotionPath = function() {
|
|
14337
|
+
return getMotionPath(this);
|
|
14338
|
+
};
|
|
14315
14339
|
ui$1.getMotionPathData = function() {
|
|
14316
14340
|
return getMotionPathData(getMotionPath(this));
|
|
14317
14341
|
};
|
|
14318
|
-
ui$1.
|
|
14319
|
-
|
|
14320
|
-
|
|
14342
|
+
ui$1.getMotionContentHeight = function() {
|
|
14343
|
+
return this.__layout.boxBounds.height;
|
|
14344
|
+
};
|
|
14345
|
+
ui$1.getMotionPoint = function(motionDistance, motionVertical, pathElement, offsetX = 0, offsetY = 0) {
|
|
14346
|
+
if (!pathElement) pathElement = getMotionPath(this);
|
|
14347
|
+
const data = getMotionPathData(pathElement);
|
|
14321
14348
|
if (!data.total) return {};
|
|
14322
|
-
const point = HighCurveHelper.getDistancePoint(data, motionDistance,
|
|
14323
|
-
MatrixHelper.toOuterPoint(path.localTransform, point);
|
|
14349
|
+
const point = HighCurveHelper.getDistancePoint(data, motionDistance, pathElement.motionPrecision, offsetX);
|
|
14324
14350
|
const {motionRotation: motionRotation} = this;
|
|
14325
|
-
if (
|
|
14351
|
+
if (isNumber(motionRotation)) point.rotation += motionRotation;
|
|
14352
|
+
let verticalType, verticalOffset;
|
|
14353
|
+
if (isObject(motionVertical)) verticalType = motionVertical.type, verticalOffset = motionVertical.offset; else if (isNumber(motionVertical)) verticalOffset = motionVertical; else verticalType = motionVertical;
|
|
14354
|
+
if (verticalType !== "below" || offsetY) {
|
|
14355
|
+
const {rotation: rotation} = point, height = this.getMotionContentHeight();
|
|
14356
|
+
if (verticalOffset) offsetY += verticalType === "above" ? -verticalOffset : verticalOffset;
|
|
14357
|
+
switch (verticalType) {
|
|
14358
|
+
case "above":
|
|
14359
|
+
toVertical(point, rotation, -height + offsetY);
|
|
14360
|
+
break;
|
|
14361
|
+
|
|
14362
|
+
case "center":
|
|
14363
|
+
toVertical(point, rotation, -height / 2 + offsetY);
|
|
14364
|
+
break;
|
|
14365
|
+
|
|
14366
|
+
case "below":
|
|
14367
|
+
default:
|
|
14368
|
+
toVertical(point, rotation, offsetY);
|
|
14369
|
+
}
|
|
14370
|
+
}
|
|
14371
|
+
MatrixHelper.toOuterPoint(pathElement.localTransform, point);
|
|
14326
14372
|
return point;
|
|
14327
14373
|
};
|
|
14328
14374
|
ui$1.getMotionTotal = function() {
|
|
@@ -14351,7 +14397,11 @@ var LeaferUI = function(exports) {
|
|
|
14351
14397
|
const data = getMotionPathData(leaf);
|
|
14352
14398
|
if (data.total) leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
|
|
14353
14399
|
} else {
|
|
14354
|
-
leaf.
|
|
14400
|
+
if (leaf.motionText) leaf.__updateMotionText(); else {
|
|
14401
|
+
const point = leaf.getMotionPoint(motion);
|
|
14402
|
+
if (leaf.motionRotation === false) delete point.rotation;
|
|
14403
|
+
leaf.set(point);
|
|
14404
|
+
}
|
|
14355
14405
|
if (!leaf.__hasAutoLayout) {
|
|
14356
14406
|
if (leaf.isBranch) updateAllMatrix(leaf), updateBounds(leaf, leaf); else updateMatrix(leaf);
|
|
14357
14407
|
}
|
|
@@ -14371,7 +14421,8 @@ var LeaferUI = function(exports) {
|
|
|
14371
14421
|
function getMotionPathData(leaf) {
|
|
14372
14422
|
const data = leaf.__;
|
|
14373
14423
|
if (data.__pathForMotion) return data.__pathForMotion;
|
|
14374
|
-
|
|
14424
|
+
const path = data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true));
|
|
14425
|
+
return path;
|
|
14375
14426
|
}
|
|
14376
14427
|
const {Yes: Yes, NoAndSkip: NoAndSkip, YesAndSkip: YesAndSkip} = exports.Answer;
|
|
14377
14428
|
const idCondition = {}, classNameCondition = {}, tagCondition = {};
|