leafer-game 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.
- package/dist/web.js +96 -39
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +100 -39
- 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,
|
|
@@ -1223,7 +1228,6 @@ var LeaferUI = function(exports) {
|
|
|
1223
1228
|
},
|
|
1224
1229
|
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
1225
1230
|
const {x: x, y: y, width: width, height: height} = bounds;
|
|
1226
|
-
if (!spread) spread = 0;
|
|
1227
1231
|
if (isArray(spread)) {
|
|
1228
1232
|
const four = fourNumber$1(spread);
|
|
1229
1233
|
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]);
|
|
@@ -3367,7 +3371,8 @@ var LeaferUI = function(exports) {
|
|
|
3367
3371
|
return;
|
|
3368
3372
|
}
|
|
3369
3373
|
}
|
|
3370
|
-
}
|
|
3374
|
+
},
|
|
3375
|
+
drawPathByPoints(_drawer, _points, _closed) {}
|
|
3371
3376
|
};
|
|
3372
3377
|
const {M: M$2, L: L$3, C: C$1, Q: Q, Z: Z$2, N: N, D: D$1, X: X, G: G, F: F$1, O: O, P: P, U: U} = PathCommandMap;
|
|
3373
3378
|
const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
|
|
@@ -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) {
|
|
@@ -8226,8 +8231,9 @@ var LeaferUI = function(exports) {
|
|
|
8226
8231
|
this.__drawPathByData(canvas, data.__pathForRender);
|
|
8227
8232
|
}
|
|
8228
8233
|
__drawPath(canvas) {
|
|
8234
|
+
const data = this.__;
|
|
8229
8235
|
canvas.beginPath();
|
|
8230
|
-
this.__drawPathByData(canvas,
|
|
8236
|
+
data.__usePointsMode ? PathDrawer.drawPathByPoints(canvas, data.points, data.closed) : this.__drawPathByData(canvas, data.path, true);
|
|
8231
8237
|
}
|
|
8232
8238
|
__drawPathByData(drawer, data, ignoreCornerRadius) {
|
|
8233
8239
|
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, ignoreCornerRadius);
|
|
@@ -8963,6 +8969,9 @@ var LeaferUI = function(exports) {
|
|
|
8963
8969
|
get __tag() {
|
|
8964
8970
|
return "Polygon";
|
|
8965
8971
|
}
|
|
8972
|
+
get isPointsMode() {
|
|
8973
|
+
return this.points && !this.pathInputed;
|
|
8974
|
+
}
|
|
8966
8975
|
__updatePath() {
|
|
8967
8976
|
const data = this.__;
|
|
8968
8977
|
const path = data.path = [];
|
|
@@ -9023,6 +9032,9 @@ var LeaferUI = function(exports) {
|
|
|
9023
9032
|
get __tag() {
|
|
9024
9033
|
return "Line";
|
|
9025
9034
|
}
|
|
9035
|
+
get isPointsMode() {
|
|
9036
|
+
return this.points && !this.pathInputed;
|
|
9037
|
+
}
|
|
9026
9038
|
get toPoint() {
|
|
9027
9039
|
const {width: width, rotation: rotation} = this.__;
|
|
9028
9040
|
const to = getPointData();
|
|
@@ -9158,7 +9170,7 @@ var LeaferUI = function(exports) {
|
|
|
9158
9170
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9159
9171
|
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9160
9172
|
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9161
|
-
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
9173
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
|
|
9162
9174
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9163
9175
|
}
|
|
9164
9176
|
__updateBoxBounds() {
|
|
@@ -9183,7 +9195,7 @@ var LeaferUI = function(exports) {
|
|
|
9183
9195
|
this.__updateNaturalSize();
|
|
9184
9196
|
} else super.__updateBoxBounds();
|
|
9185
9197
|
if (italic) b.width += fontSize * .16;
|
|
9186
|
-
DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
|
|
9198
|
+
DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds) && !data.motionText);
|
|
9187
9199
|
if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
|
|
9188
9200
|
}
|
|
9189
9201
|
__updateRenderSpread() {
|
|
@@ -10631,8 +10643,10 @@ var LeaferUI = function(exports) {
|
|
|
10631
10643
|
if (!needHitFillPath && !needHitStrokePath) return false;
|
|
10632
10644
|
const radiusWidth = inner.radiusX * 2;
|
|
10633
10645
|
let hitWidth = radiusWidth;
|
|
10646
|
+
let {strokeAlign: strokeAlign} = data;
|
|
10647
|
+
if (data.motionText) hitWidth += data.fontSize / 2, strokeAlign = "center";
|
|
10634
10648
|
if (needHitStrokePath) {
|
|
10635
|
-
switch (
|
|
10649
|
+
switch (strokeAlign) {
|
|
10636
10650
|
case "inside":
|
|
10637
10651
|
hitWidth += strokeWidth * 2;
|
|
10638
10652
|
if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth)) return true;
|
|
@@ -10662,9 +10676,9 @@ var LeaferUI = function(exports) {
|
|
|
10662
10676
|
return this.__hitCanvas ? ui$4.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10663
10677
|
};
|
|
10664
10678
|
exports.Text.prototype.__drawHitPath = function(canvas) {
|
|
10665
|
-
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;
|
|
10666
10680
|
canvas.beginPath();
|
|
10667
|
-
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));
|
|
10668
10682
|
};
|
|
10669
10683
|
exports.Group.prototype.pick = function(hitPoint, options) {
|
|
10670
10684
|
options || (options = emptyData);
|
|
@@ -11015,8 +11029,7 @@ var LeaferUI = function(exports) {
|
|
|
11015
11029
|
destroy() {
|
|
11016
11030
|
if (this.view) {
|
|
11017
11031
|
super.destroy();
|
|
11018
|
-
this.view = null;
|
|
11019
|
-
this.touches = null;
|
|
11032
|
+
this.view = this.touches = null;
|
|
11020
11033
|
}
|
|
11021
11034
|
}
|
|
11022
11035
|
}
|
|
@@ -11059,7 +11072,8 @@ var LeaferUI = function(exports) {
|
|
|
11059
11072
|
function fillPathOrText(ui, canvas, renderOptions) {
|
|
11060
11073
|
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11061
11074
|
}
|
|
11062
|
-
function fillText(ui, canvas,
|
|
11075
|
+
function fillText(ui, canvas, renderOptions) {
|
|
11076
|
+
if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
|
|
11063
11077
|
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11064
11078
|
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11065
11079
|
let row;
|
|
@@ -12292,7 +12306,8 @@ var LeaferUI = function(exports) {
|
|
|
12292
12306
|
const TextMode = 2;
|
|
12293
12307
|
function layoutChar(drawData, style, width, _height) {
|
|
12294
12308
|
const {rows: rows} = drawData;
|
|
12295
|
-
const {textAlign: textAlign, paraIndent: paraIndent
|
|
12309
|
+
const {textAlign: textAlign, paraIndent: paraIndent} = style;
|
|
12310
|
+
const useLetter = style.__letterSpacing || style.motionText;
|
|
12296
12311
|
const justifyLast = width && textAlign.includes("both");
|
|
12297
12312
|
const justify = justifyLast || width && textAlign.includes("justify");
|
|
12298
12313
|
const justifyLetter = justify && textAlign.includes("letter");
|
|
@@ -12305,8 +12320,8 @@ var LeaferUI = function(exports) {
|
|
|
12305
12320
|
remainingWidth = width - row.width - indentWidth;
|
|
12306
12321
|
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
12307
12322
|
}
|
|
12308
|
-
mode =
|
|
12309
|
-
if (row.isOverflow && !
|
|
12323
|
+
mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
12324
|
+
if (row.isOverflow && !useLetter) row.textMode = true;
|
|
12310
12325
|
if (mode === TextMode) {
|
|
12311
12326
|
row.x += indentWidth;
|
|
12312
12327
|
toTextChar$1(row);
|
|
@@ -12498,6 +12513,7 @@ var LeaferUI = function(exports) {
|
|
|
12498
12513
|
let width = style.__getInput("width") || 0;
|
|
12499
12514
|
let height = style.__getInput("height") || 0;
|
|
12500
12515
|
const {__padding: padding} = style;
|
|
12516
|
+
if (style.motionText) width = height = 0;
|
|
12501
12517
|
if (padding) {
|
|
12502
12518
|
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
12503
12519
|
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
@@ -14119,7 +14135,7 @@ var LeaferUI = function(exports) {
|
|
|
14119
14135
|
},
|
|
14120
14136
|
getMotionPathData(data) {
|
|
14121
14137
|
let total = 0, distance, segments = [];
|
|
14122
|
-
let i = 0, x = 0, y = 0, toX, toY, command;
|
|
14138
|
+
let i = 0, x = 0, y = 0, toX, toY, command, closed;
|
|
14123
14139
|
const len = data.length;
|
|
14124
14140
|
while (i < len) {
|
|
14125
14141
|
command = data[i];
|
|
@@ -14144,6 +14160,7 @@ var LeaferUI = function(exports) {
|
|
|
14144
14160
|
break;
|
|
14145
14161
|
|
|
14146
14162
|
case Z:
|
|
14163
|
+
closed = true;
|
|
14147
14164
|
i += 1;
|
|
14148
14165
|
|
|
14149
14166
|
default:
|
|
@@ -14155,13 +14172,16 @@ var LeaferUI = function(exports) {
|
|
|
14155
14172
|
return {
|
|
14156
14173
|
total: total,
|
|
14157
14174
|
segments: segments,
|
|
14158
|
-
data: data
|
|
14175
|
+
data: data,
|
|
14176
|
+
closed: closed
|
|
14159
14177
|
};
|
|
14160
14178
|
},
|
|
14161
|
-
getDistancePoint(distanceData, motionDistance, motionPrecision) {
|
|
14162
|
-
const {segments: segments, data: data} = distanceData;
|
|
14163
|
-
motionDistance = UnitConvert.number(motionDistance,
|
|
14164
|
-
|
|
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 = {};
|
|
14165
14185
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
14166
14186
|
let x1, y1, x2, y2, t;
|
|
14167
14187
|
const len = data.length;
|
|
@@ -14173,15 +14193,20 @@ var LeaferUI = function(exports) {
|
|
|
14173
14193
|
toX = data[i + 1];
|
|
14174
14194
|
toY = data[i + 2];
|
|
14175
14195
|
distance = segments[index];
|
|
14176
|
-
if (
|
|
14177
|
-
if (!i) x = toX, y = toY;
|
|
14178
|
-
tempFrom.x = x;
|
|
14179
|
-
tempFrom.y = y;
|
|
14196
|
+
if (nowDistance + distance >= motionDistance || !distanceData.total) {
|
|
14180
14197
|
to.x = toX;
|
|
14181
14198
|
to.y = toY;
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
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
|
+
}
|
|
14185
14210
|
}
|
|
14186
14211
|
x = toX;
|
|
14187
14212
|
y = toY;
|
|
@@ -14192,9 +14217,9 @@ var LeaferUI = function(exports) {
|
|
|
14192
14217
|
toX = data[i + 5];
|
|
14193
14218
|
toY = data[i + 6];
|
|
14194
14219
|
distance = segments[index];
|
|
14195
|
-
if (
|
|
14220
|
+
if (nowDistance + distance >= motionDistance) {
|
|
14196
14221
|
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
14197
|
-
t = HighBezierHelper.getT(motionDistance -
|
|
14222
|
+
t = HighBezierHelper.getT(motionDistance - nowDistance, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
14198
14223
|
BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
|
|
14199
14224
|
to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
|
|
14200
14225
|
return to;
|
|
@@ -14211,7 +14236,7 @@ var LeaferUI = function(exports) {
|
|
|
14211
14236
|
distance = 0;
|
|
14212
14237
|
}
|
|
14213
14238
|
index++;
|
|
14214
|
-
|
|
14239
|
+
nowDistance += distance;
|
|
14215
14240
|
}
|
|
14216
14241
|
return to;
|
|
14217
14242
|
},
|
|
@@ -14302,21 +14327,48 @@ var LeaferUI = function(exports) {
|
|
|
14302
14327
|
const ui$1 = exports.UI.prototype;
|
|
14303
14328
|
const {updateMatrix: updateMatrix, updateAllMatrix: updateAllMatrix} = LeafHelper;
|
|
14304
14329
|
const {updateBounds: updateBounds} = BranchHelper;
|
|
14330
|
+
const {toVertical: toVertical} = PointHelper;
|
|
14305
14331
|
exports.UI.addAttr("motionPath", undefined, motionPathType);
|
|
14306
14332
|
exports.UI.addAttr("motionPrecision", 1, motionPathType);
|
|
14307
14333
|
exports.UI.addAttr("motion", undefined, motionPathType);
|
|
14334
|
+
exports.UI.addAttr("motionVertical", "below", motionPathType);
|
|
14308
14335
|
exports.UI.addAttr("motionRotation", true, motionPathType);
|
|
14336
|
+
ui$1.getMotionPath = function() {
|
|
14337
|
+
return getMotionPath(this);
|
|
14338
|
+
};
|
|
14309
14339
|
ui$1.getMotionPathData = function() {
|
|
14310
14340
|
return getMotionPathData(getMotionPath(this));
|
|
14311
14341
|
};
|
|
14312
|
-
ui$1.
|
|
14313
|
-
|
|
14314
|
-
|
|
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);
|
|
14315
14348
|
if (!data.total) return {};
|
|
14316
|
-
const point = HighCurveHelper.getDistancePoint(data, motionDistance,
|
|
14317
|
-
MatrixHelper.toOuterPoint(path.localTransform, point);
|
|
14349
|
+
const point = HighCurveHelper.getDistancePoint(data, motionDistance, pathElement.motionPrecision, offsetX);
|
|
14318
14350
|
const {motionRotation: motionRotation} = this;
|
|
14319
|
-
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);
|
|
14320
14372
|
return point;
|
|
14321
14373
|
};
|
|
14322
14374
|
ui$1.getMotionTotal = function() {
|
|
@@ -14345,7 +14397,11 @@ var LeaferUI = function(exports) {
|
|
|
14345
14397
|
const data = getMotionPathData(leaf);
|
|
14346
14398
|
if (data.total) leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
|
|
14347
14399
|
} else {
|
|
14348
|
-
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
|
+
}
|
|
14349
14405
|
if (!leaf.__hasAutoLayout) {
|
|
14350
14406
|
if (leaf.isBranch) updateAllMatrix(leaf), updateBounds(leaf, leaf); else updateMatrix(leaf);
|
|
14351
14407
|
}
|
|
@@ -14365,7 +14421,8 @@ var LeaferUI = function(exports) {
|
|
|
14365
14421
|
function getMotionPathData(leaf) {
|
|
14366
14422
|
const data = leaf.__;
|
|
14367
14423
|
if (data.__pathForMotion) return data.__pathForMotion;
|
|
14368
|
-
|
|
14424
|
+
const path = data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true));
|
|
14425
|
+
return path;
|
|
14369
14426
|
}
|
|
14370
14427
|
const {Yes: Yes, NoAndSkip: NoAndSkip, YesAndSkip: YesAndSkip} = exports.Answer;
|
|
14371
14428
|
const idCondition = {}, classNameCondition = {}, tagCondition = {};
|