leafer-game 2.1.0 → 2.1.2
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 +47 -26
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +47 -26
- 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
|
@@ -2872,7 +2872,7 @@ var LeaferUI = function(exports) {
|
|
|
2872
2872
|
return needConvert ? PathConvert.toCanvasData(data, curveMode) : data;
|
|
2873
2873
|
},
|
|
2874
2874
|
toCanvasData(old, curveMode) {
|
|
2875
|
-
let x = 0, y = 0, x1 = 0, y1 = 0, i = 0, len = old.length, controlX, controlY, command, lastCommand, smooth;
|
|
2875
|
+
let x = 0, y = 0, x1 = 0, y1 = 0, startX = 0, startY = 0, i = 0, len = old.length, controlX, controlY, command, lastCommand, smooth;
|
|
2876
2876
|
const data = [];
|
|
2877
2877
|
while (i < len) {
|
|
2878
2878
|
command = old[i];
|
|
@@ -2884,7 +2884,8 @@ var LeaferUI = function(exports) {
|
|
|
2884
2884
|
case M$5:
|
|
2885
2885
|
x = old[i + 1];
|
|
2886
2886
|
y = old[i + 2];
|
|
2887
|
-
data.push(M$5, x, y)
|
|
2887
|
+
if (lastCommand === command) data.push(L$6, x, y); else data.push(M$5, x, y), startX = x,
|
|
2888
|
+
startY = y;
|
|
2888
2889
|
i += 3;
|
|
2889
2890
|
break;
|
|
2890
2891
|
|
|
@@ -2999,6 +3000,8 @@ var LeaferUI = function(exports) {
|
|
|
2999
3000
|
case z:
|
|
3000
3001
|
case Z$5:
|
|
3001
3002
|
data.push(Z$5);
|
|
3003
|
+
x = startX;
|
|
3004
|
+
y = startY;
|
|
3002
3005
|
i++;
|
|
3003
3006
|
break;
|
|
3004
3007
|
|
|
@@ -5680,12 +5683,13 @@ var LeaferUI = function(exports) {
|
|
|
5680
5683
|
if (this.__hasWorldEvent) BoundsEvent.emitWorld(this);
|
|
5681
5684
|
},
|
|
5682
5685
|
__updateLocalBounds() {
|
|
5683
|
-
const layout = this.__layout;
|
|
5686
|
+
const layout = this.__layout, data = this.__;
|
|
5684
5687
|
if (layout.boxChanged) {
|
|
5685
|
-
if (!
|
|
5688
|
+
if (!data.__pathInputed) this.__updatePath();
|
|
5686
5689
|
this.__updateRenderPath();
|
|
5687
5690
|
this.__updateBoxBounds();
|
|
5688
5691
|
layout.resized = "inner";
|
|
5692
|
+
if (data.__strokeGeometry) data.__strokeGeometry = undefined;
|
|
5689
5693
|
}
|
|
5690
5694
|
if (layout.localBoxChanged) {
|
|
5691
5695
|
if (this.__local) this.__updateLocalBoxBounds();
|
|
@@ -5708,6 +5712,7 @@ var LeaferUI = function(exports) {
|
|
|
5708
5712
|
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread) layout.renderChanged = true;
|
|
5709
5713
|
if (this.parent) this.parent.__layout.strokeChange();
|
|
5710
5714
|
layout.resized = "inner";
|
|
5715
|
+
if (data.__strokeGeometry) data.__strokeGeometry = undefined;
|
|
5711
5716
|
}
|
|
5712
5717
|
if (layout.renderChanged) {
|
|
5713
5718
|
layout.renderSpread = this.__updateRenderSpread();
|
|
@@ -6663,7 +6668,7 @@ var LeaferUI = function(exports) {
|
|
|
6663
6668
|
this.levelMap = null;
|
|
6664
6669
|
}
|
|
6665
6670
|
}
|
|
6666
|
-
const version = "2.1.
|
|
6671
|
+
const version = "2.1.2";
|
|
6667
6672
|
const debug$5 = Debug.get("LeaferCanvas");
|
|
6668
6673
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6669
6674
|
set zIndex(zIndex) {
|
|
@@ -7875,7 +7880,7 @@ var LeaferUI = function(exports) {
|
|
|
7875
7880
|
const isStr = isString(value);
|
|
7876
7881
|
if (isStr || value && isObject(value[0])) {
|
|
7877
7882
|
this.__setInput("path", value);
|
|
7878
|
-
this._path = isStr ? parse(value) : objectToCanvasData(value);
|
|
7883
|
+
this._path = isStr ? parse(value, this.__useArrow) : objectToCanvasData(value);
|
|
7879
7884
|
} else {
|
|
7880
7885
|
if (this.__input) this.__removeInput("path");
|
|
7881
7886
|
this._path = value;
|
|
@@ -7981,7 +7986,11 @@ var LeaferUI = function(exports) {
|
|
|
7981
7986
|
return !this.__pathInputed;
|
|
7982
7987
|
}
|
|
7983
7988
|
}
|
|
7984
|
-
class PolygonData extends
|
|
7989
|
+
class PolygonData extends UIData {
|
|
7990
|
+
get __usePathBox() {
|
|
7991
|
+
return this.points || this.__pathInputed;
|
|
7992
|
+
}
|
|
7993
|
+
}
|
|
7985
7994
|
class StarData extends UIData {
|
|
7986
7995
|
get __boxStroke() {
|
|
7987
7996
|
return !this.__pathInputed;
|
|
@@ -8083,7 +8092,7 @@ var LeaferUI = function(exports) {
|
|
|
8083
8092
|
if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
|
|
8084
8093
|
boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
|
|
8085
8094
|
if (!data.__boxStroke || data.__useArrow) {
|
|
8086
|
-
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
|
|
8095
|
+
const miterLimitAddWidth = data.__isLinePath ? 0 : (data.strokeJoin === "miter" ? 10 : 1) * spread;
|
|
8087
8096
|
const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
|
|
8088
8097
|
spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
|
|
8089
8098
|
}
|
|
@@ -9220,7 +9229,7 @@ var LeaferUI = function(exports) {
|
|
|
9220
9229
|
__decorate([ dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
|
|
9221
9230
|
__decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
|
|
9222
9231
|
exports.Canvas = __decorate([ registerUI() ], exports.Canvas);
|
|
9223
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes,
|
|
9232
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9224
9233
|
exports.Text = class Text extends exports.UI {
|
|
9225
9234
|
get __tag() {
|
|
9226
9235
|
return "Text";
|
|
@@ -9249,7 +9258,7 @@ var LeaferUI = function(exports) {
|
|
|
9249
9258
|
const {bounds: contentBounds} = data.__textDrawData;
|
|
9250
9259
|
const b = layout.boxBounds;
|
|
9251
9260
|
layout.contentBounds = contentBounds;
|
|
9252
|
-
if (data.__lineHeight < fontSize)
|
|
9261
|
+
if (data.__lineHeight < fontSize) layout.renderChanged = true;
|
|
9253
9262
|
if (autoWidth || autoHeight) {
|
|
9254
9263
|
b.x = autoWidth ? contentBounds.x : 0;
|
|
9255
9264
|
b.y = autoHeight ? contentBounds.y : 0;
|
|
@@ -9269,6 +9278,8 @@ var LeaferUI = function(exports) {
|
|
|
9269
9278
|
__updateRenderSpread() {
|
|
9270
9279
|
let spread = super.__updateRenderSpread();
|
|
9271
9280
|
if (!spread) spread = this.isOverflow ? 1 : 0;
|
|
9281
|
+
const {__lineHeight: __lineHeight, fontSize: fontSize} = this.__;
|
|
9282
|
+
if (__lineHeight < fontSize) spread = FourNumberHelper.max(spread, (fontSize - __lineHeight) / 2);
|
|
9272
9283
|
return spread;
|
|
9273
9284
|
}
|
|
9274
9285
|
__updateRenderBounds() {
|
|
@@ -11388,8 +11399,8 @@ var LeaferUI = function(exports) {
|
|
|
11388
11399
|
}
|
|
11389
11400
|
}
|
|
11390
11401
|
}
|
|
11391
|
-
data["_" + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
11392
11402
|
if (leafPaints.length) {
|
|
11403
|
+
data["_" + attrName] = leafPaints;
|
|
11393
11404
|
if (leafPaints.every(item => item.isTransparent)) {
|
|
11394
11405
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
11395
11406
|
isTransparent = true;
|
|
@@ -11404,6 +11415,7 @@ var LeaferUI = function(exports) {
|
|
|
11404
11415
|
}
|
|
11405
11416
|
} else {
|
|
11406
11417
|
data.__removePaint(attrName, false);
|
|
11418
|
+
data["_" + attrName] = "";
|
|
11407
11419
|
}
|
|
11408
11420
|
}
|
|
11409
11421
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -11547,11 +11559,12 @@ var LeaferUI = function(exports) {
|
|
|
11547
11559
|
needUpdate = false;
|
|
11548
11560
|
}
|
|
11549
11561
|
}
|
|
11562
|
+
if (paint.mode === "brush") PaintImage.brush(leafPaint);
|
|
11550
11563
|
if (!leafPaint.data) {
|
|
11551
11564
|
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
11552
|
-
const {transform: transform} = leafPaint.data, {opacity: opacity
|
|
11553
|
-
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
11554
|
-
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
11565
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity} = paint;
|
|
11566
|
+
const clip = (transform && !transform.onlyScale || data.path || data.cornerRadius) && !leafPaint.brush;
|
|
11567
|
+
if (clip || opacity && opacity < 1 || paint.blendMode) leafPaint.complex = clip ? 2 : true;
|
|
11555
11568
|
}
|
|
11556
11569
|
if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
|
|
11557
11570
|
return needUpdate;
|
|
@@ -11630,6 +11643,7 @@ var LeaferUI = function(exports) {
|
|
|
11630
11643
|
break;
|
|
11631
11644
|
|
|
11632
11645
|
case "repeat":
|
|
11646
|
+
case "brush":
|
|
11633
11647
|
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
11634
11648
|
if (!repeat) data.repeat = "repeat";
|
|
11635
11649
|
const count = isObject(repeat);
|
|
@@ -11757,7 +11771,7 @@ var LeaferUI = function(exports) {
|
|
|
11757
11771
|
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
11758
11772
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
11759
11773
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
11760
|
-
const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
11774
|
+
const {image: image, brush: brush, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
11761
11775
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
11762
11776
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
11763
11777
|
width *= scaleX;
|
|
@@ -11765,6 +11779,10 @@ var LeaferUI = function(exports) {
|
|
|
11765
11779
|
if (gap) {
|
|
11766
11780
|
xGap = gap.x * scaleX / abs$2(data.scaleX || 1);
|
|
11767
11781
|
yGap = gap.y * scaleY / abs$2(data.scaleY || 1);
|
|
11782
|
+
if (brush) {
|
|
11783
|
+
const brushScale = PaintImage.getBrushScale(paint, ui);
|
|
11784
|
+
xGap /= brushScale, yGap /= brushScale;
|
|
11785
|
+
}
|
|
11768
11786
|
}
|
|
11769
11787
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
11770
11788
|
scaleX *= getFloorScale(width + (xGap || 0));
|
|
@@ -11774,7 +11792,7 @@ var LeaferUI = function(exports) {
|
|
|
11774
11792
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
11775
11793
|
}
|
|
11776
11794
|
const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
11777
|
-
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
11795
|
+
const pattern = brush ? imageCanvas : image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
11778
11796
|
paint.style = pattern;
|
|
11779
11797
|
paint.patternId = id;
|
|
11780
11798
|
}
|
|
@@ -11793,9 +11811,9 @@ var LeaferUI = function(exports) {
|
|
|
11793
11811
|
}
|
|
11794
11812
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
11795
11813
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
11796
|
-
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
11814
|
+
const {image: image, brush: brush, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
11797
11815
|
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
11798
|
-
return false;
|
|
11816
|
+
if (!(brush && paint.style)) return false;
|
|
11799
11817
|
} else {
|
|
11800
11818
|
if (drawImage) {
|
|
11801
11819
|
if (data.repeat) {
|
|
@@ -11809,17 +11827,17 @@ var LeaferUI = function(exports) {
|
|
|
11809
11827
|
canvas.fillStyle = paint.style || "#000";
|
|
11810
11828
|
canvas.fill();
|
|
11811
11829
|
}
|
|
11812
|
-
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
11813
|
-
return true;
|
|
11814
11830
|
} else {
|
|
11815
11831
|
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
11816
|
-
return false;
|
|
11832
|
+
if (!(brush && paint.style)) return false;
|
|
11817
11833
|
}
|
|
11818
11834
|
}
|
|
11835
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
11836
|
+
return true;
|
|
11819
11837
|
}
|
|
11820
11838
|
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
11821
|
-
const {data: data, image: image, complex: complex} = paint;
|
|
11822
|
-
let {width: width, height: height} = image;
|
|
11839
|
+
const {data: data, image: image, brush: brush, complex: complex} = paint;
|
|
11840
|
+
let {width: width, height: height} = image, view = brush || image;
|
|
11823
11841
|
if (complex) {
|
|
11824
11842
|
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
11825
11843
|
canvas.save();
|
|
@@ -11827,15 +11845,16 @@ var LeaferUI = function(exports) {
|
|
|
11827
11845
|
blendMode && (canvas.blendMode = blendMode);
|
|
11828
11846
|
opacity && (canvas.opacity *= opacity);
|
|
11829
11847
|
transform && canvas.transform(transform);
|
|
11830
|
-
|
|
11848
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
11831
11849
|
canvas.restore();
|
|
11832
11850
|
} else {
|
|
11833
11851
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
11834
|
-
|
|
11852
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
11835
11853
|
}
|
|
11836
11854
|
}
|
|
11837
11855
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
11838
11856
|
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
11857
|
+
if (paint.brush) PaintImage.addBrushScale(scaleData, paint, ui);
|
|
11839
11858
|
if (canvas) {
|
|
11840
11859
|
const {pixelRatio: pixelRatio} = canvas;
|
|
11841
11860
|
scaleData.scaleX *= pixelRatio;
|
|
@@ -11851,6 +11870,7 @@ var LeaferUI = function(exports) {
|
|
|
11851
11870
|
const paints = data["_" + attrName];
|
|
11852
11871
|
if (isArray(paints)) {
|
|
11853
11872
|
let paint, image, recycleMap, input, url;
|
|
11873
|
+
const ui = data.__leaf;
|
|
11854
11874
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
11855
11875
|
paint = paints[i];
|
|
11856
11876
|
image = paint.image;
|
|
@@ -11859,7 +11879,8 @@ var LeaferUI = function(exports) {
|
|
|
11859
11879
|
if (!recycleMap) recycleMap = {};
|
|
11860
11880
|
recycleMap[url] = true;
|
|
11861
11881
|
ImageManager.recyclePaint(paint);
|
|
11862
|
-
if (
|
|
11882
|
+
if (paint.brush) PaintImage.recycleBrush(paint, ui);
|
|
11883
|
+
if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, ui);
|
|
11863
11884
|
if (image.loading) {
|
|
11864
11885
|
if (!input) {
|
|
11865
11886
|
input = data.__input && data.__input[attrName] || [];
|