leafer-game 2.2.8 → 2.2.10
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 +68 -57
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +69 -58
- 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
|
@@ -2800,7 +2800,7 @@ var LeaferUI = function(exports) {
|
|
|
2800
2800
|
toCommand(_nodes) {
|
|
2801
2801
|
return [];
|
|
2802
2802
|
},
|
|
2803
|
-
toNode(_data) {
|
|
2803
|
+
toNode(_data, _filterSamePoint) {
|
|
2804
2804
|
return [];
|
|
2805
2805
|
}
|
|
2806
2806
|
};
|
|
@@ -6626,7 +6626,7 @@ var LeaferUI = function(exports) {
|
|
|
6626
6626
|
this.levelMap = null;
|
|
6627
6627
|
}
|
|
6628
6628
|
}
|
|
6629
|
-
const version = "2.2.
|
|
6629
|
+
const version = "2.2.10";
|
|
6630
6630
|
const debug$5 = Debug.get("LeaferCanvas");
|
|
6631
6631
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6632
6632
|
set zIndex(zIndex) {
|
|
@@ -8285,7 +8285,7 @@ var LeaferUI = function(exports) {
|
|
|
8285
8285
|
getPath(curve, pathForRender) {
|
|
8286
8286
|
this.__layout.update();
|
|
8287
8287
|
let path = pathForRender ? this.__.__pathForRender : this.__.path;
|
|
8288
|
-
if (!path) pen.set(path = []), this.__drawPathByBox(pen, !pathForRender);
|
|
8288
|
+
if (!path) pen.set(path = []), this.__drawPathByBox(pen, "box", !pathForRender);
|
|
8289
8289
|
return curve ? PathConvert.toCanvasData(path, true) : path;
|
|
8290
8290
|
}
|
|
8291
8291
|
getPathString(curve, pathForRender, floatLength) {
|
|
@@ -8323,10 +8323,10 @@ var LeaferUI = function(exports) {
|
|
|
8323
8323
|
data.__usePointsMode ? PathDrawer.drawPathByPoints(canvas, data.points, data.closed) : this.__drawPathByData(canvas, data.path, true);
|
|
8324
8324
|
}
|
|
8325
8325
|
__drawPathByData(drawer, data, ignoreCornerRadius) {
|
|
8326
|
-
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, ignoreCornerRadius);
|
|
8326
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, "box", ignoreCornerRadius);
|
|
8327
8327
|
}
|
|
8328
|
-
__drawPathByBox(drawer, ignoreCornerRadius) {
|
|
8329
|
-
const {x: x, y: y, width: width, height: height} = this.__layout
|
|
8328
|
+
__drawPathByBox(drawer, boundsType = "box", ignoreCornerRadius) {
|
|
8329
|
+
const {x: x, y: y, width: width, height: height} = this.__layout[boundsType + "Bounds"];
|
|
8330
8330
|
if (this.__.cornerRadius && !ignoreCornerRadius) {
|
|
8331
8331
|
const {cornerRadius: cornerRadius} = this.__;
|
|
8332
8332
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
@@ -9246,14 +9246,15 @@ var LeaferUI = function(exports) {
|
|
|
9246
9246
|
}
|
|
9247
9247
|
__updateTextDrawData() {
|
|
9248
9248
|
const data = this.__;
|
|
9249
|
-
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
9249
|
+
const {lineHeight: lineHeight, letterSpacing: letterSpacing, wordSpacing: wordSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
9250
9250
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
9251
9251
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
9252
|
+
data.__wordSpacing = UnitConvert.number(wordSpacing, fontSize);
|
|
9252
9253
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
|
|
9253
9254
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9254
9255
|
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9255
9256
|
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9256
|
-
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
|
|
9257
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.__wordSpacing || data.motionText || textCase !== "none");
|
|
9257
9258
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9258
9259
|
}
|
|
9259
9260
|
__updateBoxBounds() {
|
|
@@ -9333,6 +9334,7 @@ var LeaferUI = function(exports) {
|
|
|
9333
9334
|
__decorate([ boundsType("none") ], exports.Text.prototype, "textCase", void 0);
|
|
9334
9335
|
__decorate([ boundsType("none") ], exports.Text.prototype, "textDecoration", void 0);
|
|
9335
9336
|
__decorate([ boundsType(0) ], exports.Text.prototype, "letterSpacing", void 0);
|
|
9337
|
+
__decorate([ boundsType(0) ], exports.Text.prototype, "wordSpacing", void 0);
|
|
9336
9338
|
__decorate([ boundsType({
|
|
9337
9339
|
type: "percent",
|
|
9338
9340
|
value: 1.5
|
|
@@ -11143,7 +11145,7 @@ var LeaferUI = function(exports) {
|
|
|
11143
11145
|
if (scaleX !== 1) canvas.scale(scaleX, scaleY);
|
|
11144
11146
|
}
|
|
11145
11147
|
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
|
|
11146
|
-
fillPathOrText(ui, canvas, renderOptions);
|
|
11148
|
+
fillPathOrText(ui, canvas, renderOptions, true);
|
|
11147
11149
|
canvas.restore();
|
|
11148
11150
|
} else {
|
|
11149
11151
|
if (originPaint.blendMode) {
|
|
@@ -11154,24 +11156,45 @@ var LeaferUI = function(exports) {
|
|
|
11154
11156
|
}
|
|
11155
11157
|
}
|
|
11156
11158
|
}
|
|
11157
|
-
function fillPathOrText(ui, canvas, renderOptions) {
|
|
11158
|
-
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11159
|
+
function fillPathOrText(ui, canvas, renderOptions, complexPaint) {
|
|
11160
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions, complexPaint) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11159
11161
|
}
|
|
11160
|
-
function fillText(ui, canvas, renderOptions) {
|
|
11161
|
-
|
|
11162
|
-
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11162
|
+
function fillText(ui, canvas, renderOptions, complexPaint) {
|
|
11163
|
+
const data = ui.__;
|
|
11163
11164
|
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11164
|
-
let
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11165
|
+
let originCanvas;
|
|
11166
|
+
if (complexPaint) {
|
|
11167
|
+
originCanvas = canvas;
|
|
11168
|
+
canvas = canvas.getSameCanvas(true, true);
|
|
11169
|
+
canvas.font = ui.__.__font;
|
|
11170
|
+
canvas.fillStyle = "#000";
|
|
11171
|
+
}
|
|
11172
|
+
if (ui.motionText) {
|
|
11173
|
+
Paint.fillMotionText(ui, canvas, renderOptions);
|
|
11174
|
+
} else {
|
|
11175
|
+
let row;
|
|
11176
|
+
const {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11177
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
11178
|
+
row = rows[i];
|
|
11179
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
11180
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
11181
|
+
});
|
|
11182
|
+
}
|
|
11183
|
+
if (decorationY) {
|
|
11184
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
11185
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
11186
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
11187
|
+
}
|
|
11170
11188
|
}
|
|
11171
|
-
if (
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11189
|
+
if (complexPaint) {
|
|
11190
|
+
canvas.beginPath();
|
|
11191
|
+
ui.__drawPathByBox(canvas, "render");
|
|
11192
|
+
canvas.fillStyle = originCanvas.fillStyle;
|
|
11193
|
+
canvas.setTransform(originCanvas.getTransform());
|
|
11194
|
+
canvas.blendMode = "source-in";
|
|
11195
|
+
canvas.fill();
|
|
11196
|
+
originCanvas.copyWorldByReset(canvas, ui.__nowWorld);
|
|
11197
|
+
canvas.recycle(ui.__nowWorld);
|
|
11175
11198
|
}
|
|
11176
11199
|
}
|
|
11177
11200
|
function stroke(stroke, ui, canvas, renderOptions) {
|
|
@@ -12189,8 +12212,8 @@ var LeaferUI = function(exports) {
|
|
|
12189
12212
|
const afterChar = ">)]}%!?,.:;'\"" + langAfter;
|
|
12190
12213
|
const symbolChar = afterChar + "_#~&*+\\=|" + langSymbol;
|
|
12191
12214
|
const breakChar = "- " + langBreak$1;
|
|
12192
|
-
const cjkRangeList = [ [ 19968, 40959 ], [ 13312, 19903 ], [ 131072, 173791 ], [ 173824, 177983 ], [ 177984, 178207 ], [ 178208, 183983 ], [ 183984, 191471 ], [ 196608, 201551 ], [ 201552, 205743 ], [ 11904, 12031 ], [ 12032, 12255 ], [ 12272, 12287 ], [ 12288, 12351 ], [ 12736, 12783 ], [ 12800, 13055 ], [ 13056, 13311 ], [ 63744, 64255 ], [ 65072, 65103 ], [ 127488, 127743 ], [ 194560, 195103 ] ];
|
|
12193
|
-
const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u${start.toString(16)}-\\u${end.toString(16)}]`).join("|"));
|
|
12215
|
+
const cjkRangeList = [ [ 19968, 40959 ], [ 13312, 19903 ], [ 131072, 173791 ], [ 173824, 177983 ], [ 177984, 178207 ], [ 178208, 183983 ], [ 183984, 191471 ], [ 196608, 201551 ], [ 201552, 205743 ], [ 11904, 12031 ], [ 12032, 12255 ], [ 12272, 12287 ], [ 12288, 12351 ], [ 4352, 4607 ], [ 12352, 12447 ], [ 12448, 12543 ], [ 12544, 12591 ], [ 12592, 12687 ], [ 12688, 12703 ], [ 12704, 12735 ], [ 12784, 12799 ], [ 12736, 12783 ], [ 12800, 13055 ], [ 13056, 13311 ], [ 63744, 64255 ], [ 65072, 65103 ], [ 127488, 127743 ], [ 194560, 195103 ] ];
|
|
12216
|
+
const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u{${start.toString(16)}}-\\u{${end.toString(16)}}]`).join("|"), "u");
|
|
12194
12217
|
function mapChar(str) {
|
|
12195
12218
|
const map = {};
|
|
12196
12219
|
str.split("").forEach(char => map[char] = true);
|
|
@@ -12269,11 +12292,13 @@ var LeaferUI = function(exports) {
|
|
|
12269
12292
|
rows = drawData.rows;
|
|
12270
12293
|
bounds = drawData.bounds;
|
|
12271
12294
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
12272
|
-
const {
|
|
12295
|
+
const {paraIndent: paraIndent, textCase: textCase} = style;
|
|
12273
12296
|
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
12274
12297
|
if (style.__isCharMode) {
|
|
12275
12298
|
const wrap = style.textWrap !== "none";
|
|
12276
12299
|
const breakAll = style.textWrap === "break";
|
|
12300
|
+
const letterSpacing = style.__letterSpacing;
|
|
12301
|
+
const wordSpacing = style.__wordSpacing;
|
|
12277
12302
|
paraStart = true;
|
|
12278
12303
|
lastCharType = null;
|
|
12279
12304
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
@@ -12294,9 +12319,9 @@ var LeaferUI = function(exports) {
|
|
|
12294
12319
|
charType = getCharType(char);
|
|
12295
12320
|
if (charType === Letter && textCase !== "none") char = getTextCase(char, textCase, !wordWidth);
|
|
12296
12321
|
charWidth = canvas.measureText(char).width;
|
|
12297
|
-
if (
|
|
12298
|
-
if (
|
|
12299
|
-
charWidth +=
|
|
12322
|
+
if (letterSpacing) {
|
|
12323
|
+
if (letterSpacing < 0) charSize = charWidth;
|
|
12324
|
+
charWidth += letterSpacing;
|
|
12300
12325
|
}
|
|
12301
12326
|
langBreak = charType === Single && (lastCharType === Single || lastCharType === Letter) || lastCharType === Single && charType !== After;
|
|
12302
12327
|
afterBreak = (charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After);
|
|
@@ -12317,11 +12342,11 @@ var LeaferUI = function(exports) {
|
|
|
12317
12342
|
}
|
|
12318
12343
|
if (char === " " && paraStart !== true && rowWidth + wordWidth === 0) ; else {
|
|
12319
12344
|
if (charType === Break) {
|
|
12320
|
-
if (char === " " && wordWidth) addWord();
|
|
12345
|
+
if (char === " " && wordWidth) addWord(wordSpacing);
|
|
12321
12346
|
addChar(char, charWidth);
|
|
12322
12347
|
addWord();
|
|
12323
12348
|
} else if (langBreak || afterBreak) {
|
|
12324
|
-
if (wordWidth) addWord();
|
|
12349
|
+
if (wordWidth) addWord(wordSpacing);
|
|
12325
12350
|
addChar(char, charWidth);
|
|
12326
12351
|
} else {
|
|
12327
12352
|
addChar(char, charWidth);
|
|
@@ -12355,7 +12380,11 @@ var LeaferUI = function(exports) {
|
|
|
12355
12380
|
});
|
|
12356
12381
|
wordWidth += width;
|
|
12357
12382
|
}
|
|
12358
|
-
function addWord() {
|
|
12383
|
+
function addWord(wordSpacing) {
|
|
12384
|
+
if (wordSpacing) {
|
|
12385
|
+
rowWidth += wordSpacing;
|
|
12386
|
+
word.addWidth = wordSpacing;
|
|
12387
|
+
}
|
|
12359
12388
|
rowWidth += wordWidth;
|
|
12360
12389
|
word.width = wordWidth;
|
|
12361
12390
|
row.words.push(word);
|
|
@@ -12393,6 +12422,7 @@ var LeaferUI = function(exports) {
|
|
|
12393
12422
|
const {rows: rows} = drawData;
|
|
12394
12423
|
const {textAlign: textAlign, paraIndent: paraIndent} = style;
|
|
12395
12424
|
const useLetter = style.__letterSpacing || style.motionText;
|
|
12425
|
+
const wordSpacing = style.__wordSpacing;
|
|
12396
12426
|
const justifyLast = width && textAlign.includes("both");
|
|
12397
12427
|
const justify = justifyLast || width && textAlign.includes("justify");
|
|
12398
12428
|
const justifyLetter = justify && textAlign.includes("letter");
|
|
@@ -12405,7 +12435,7 @@ var LeaferUI = function(exports) {
|
|
|
12405
12435
|
remainingWidth = width - row.width - indentWidth;
|
|
12406
12436
|
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
12407
12437
|
}
|
|
12408
|
-
mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
12438
|
+
mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth || wordSpacing ? WordMode : TextMode;
|
|
12409
12439
|
if (row.isOverflow && !useLetter) row.textMode = true;
|
|
12410
12440
|
if (mode === TextMode) {
|
|
12411
12441
|
row.x += indentWidth;
|
|
@@ -12425,6 +12455,7 @@ var LeaferUI = function(exports) {
|
|
|
12425
12455
|
} else {
|
|
12426
12456
|
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
12427
12457
|
}
|
|
12458
|
+
if (word.addWidth) charX += word.addWidth;
|
|
12428
12459
|
if (canJustify) {
|
|
12429
12460
|
isLastWord = index === wordsLength - 1;
|
|
12430
12461
|
if (addWordWidth) {
|
|
@@ -14271,6 +14302,7 @@ var LeaferUI = function(exports) {
|
|
|
14271
14302
|
motionDistance = UnitConvert.number(motionDistance, total);
|
|
14272
14303
|
if (offsetX) motionDistance += offsetX;
|
|
14273
14304
|
if (motionDistance > total) motionDistance = motionDistance % total;
|
|
14305
|
+
if (motionDistance < 0) motionDistance = total + motionDistance;
|
|
14274
14306
|
let nowDistance = 0, distance, to = {};
|
|
14275
14307
|
let i = 0, index = 0, x = 0, y = 0, startX = 0, startY = 0, toX, toY, command;
|
|
14276
14308
|
let x1, y1, x2, y2, t;
|
|
@@ -14461,10 +14493,7 @@ var LeaferUI = function(exports) {
|
|
|
14461
14493
|
ui$1.getMotionPathData = function() {
|
|
14462
14494
|
return getMotionPathData(getMotionPath(this));
|
|
14463
14495
|
};
|
|
14464
|
-
ui$1.
|
|
14465
|
-
return this.__layout.boxBounds.height;
|
|
14466
|
-
};
|
|
14467
|
-
ui$1.getMotionPoint = function(motionDistance, motionAround, motionVertical, offsetX = 0, offsetY = 0, pathElement) {
|
|
14496
|
+
ui$1.getMotionPoint = function(motionDistance, motionAround, offsetX = 0, offsetY = 0, pathElement) {
|
|
14468
14497
|
if (!pathElement) pathElement = getMotionPath(this);
|
|
14469
14498
|
const data = getMotionPathData(pathElement);
|
|
14470
14499
|
if (!data.total) return {};
|
|
@@ -14477,25 +14506,7 @@ var LeaferUI = function(exports) {
|
|
|
14477
14506
|
if (point.rotation) PointHelper.rotate(tempPoint, point.rotation, point);
|
|
14478
14507
|
PointHelper.copy(point, tempPoint);
|
|
14479
14508
|
}
|
|
14480
|
-
|
|
14481
|
-
if (isObject(motionVertical)) verticalType = motionVertical.type, verticalOffset = motionVertical.offset; else if (isNumber(motionVertical)) verticalOffset = motionVertical; else verticalType = motionVertical;
|
|
14482
|
-
if (verticalType !== "below" || offsetY) {
|
|
14483
|
-
const {rotation: rotation} = point, height = this.getMotionContentHeight();
|
|
14484
|
-
if (verticalOffset) offsetY += verticalType === "above" ? -verticalOffset : verticalOffset;
|
|
14485
|
-
switch (verticalType) {
|
|
14486
|
-
case "above":
|
|
14487
|
-
toVertical(point, rotation, -height + offsetY);
|
|
14488
|
-
break;
|
|
14489
|
-
|
|
14490
|
-
case "center":
|
|
14491
|
-
toVertical(point, rotation, -height / 2 + offsetY);
|
|
14492
|
-
break;
|
|
14493
|
-
|
|
14494
|
-
case "below":
|
|
14495
|
-
default:
|
|
14496
|
-
toVertical(point, rotation, offsetY);
|
|
14497
|
-
}
|
|
14498
|
-
}
|
|
14509
|
+
if (offsetY) toVertical(point, point.rotation, offsetY);
|
|
14499
14510
|
MatrixHelper.toOuterPoint(pathElement.localTransform, point);
|
|
14500
14511
|
return point;
|
|
14501
14512
|
};
|