@leafer-game/worker 2.0.9 → 2.1.1
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/worker.js +51 -28
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +51 -28
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +12 -12
package/dist/worker.js
CHANGED
|
@@ -2884,7 +2884,7 @@ 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
|
+
data.push(lastCommand === command ? L$6 : M$5, x, y);
|
|
2888
2888
|
i += 3;
|
|
2889
2889
|
break;
|
|
2890
2890
|
|
|
@@ -5680,12 +5680,13 @@ var LeaferUI = function(exports) {
|
|
|
5680
5680
|
if (this.__hasWorldEvent) BoundsEvent.emitWorld(this);
|
|
5681
5681
|
},
|
|
5682
5682
|
__updateLocalBounds() {
|
|
5683
|
-
const layout = this.__layout;
|
|
5683
|
+
const layout = this.__layout, data = this.__;
|
|
5684
5684
|
if (layout.boxChanged) {
|
|
5685
|
-
if (!
|
|
5685
|
+
if (!data.__pathInputed) this.__updatePath();
|
|
5686
5686
|
this.__updateRenderPath();
|
|
5687
5687
|
this.__updateBoxBounds();
|
|
5688
5688
|
layout.resized = "inner";
|
|
5689
|
+
if (data.__strokeGeometry) data.__strokeGeometry = undefined;
|
|
5689
5690
|
}
|
|
5690
5691
|
if (layout.localBoxChanged) {
|
|
5691
5692
|
if (this.__local) this.__updateLocalBoxBounds();
|
|
@@ -5708,6 +5709,7 @@ var LeaferUI = function(exports) {
|
|
|
5708
5709
|
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread) layout.renderChanged = true;
|
|
5709
5710
|
if (this.parent) this.parent.__layout.strokeChange();
|
|
5710
5711
|
layout.resized = "inner";
|
|
5712
|
+
if (data.__strokeGeometry) data.__strokeGeometry = undefined;
|
|
5711
5713
|
}
|
|
5712
5714
|
if (layout.renderChanged) {
|
|
5713
5715
|
layout.renderSpread = this.__updateRenderSpread();
|
|
@@ -6663,7 +6665,7 @@ var LeaferUI = function(exports) {
|
|
|
6663
6665
|
this.levelMap = null;
|
|
6664
6666
|
}
|
|
6665
6667
|
}
|
|
6666
|
-
const version = "2.
|
|
6668
|
+
const version = "2.1.1";
|
|
6667
6669
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6668
6670
|
get allowBackgroundColor() {
|
|
6669
6671
|
return true;
|
|
@@ -7612,8 +7614,8 @@ var LeaferUI = function(exports) {
|
|
|
7612
7614
|
return this.__getRealStrokeWidth();
|
|
7613
7615
|
}
|
|
7614
7616
|
get __maxStrokeWidth() {
|
|
7615
|
-
const t = this;
|
|
7616
|
-
return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle,
|
|
7617
|
+
const t = this, strokeWidth = t.__hasStrokeSides || t.strokeWidth;
|
|
7618
|
+
return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, strokeWidth) : strokeWidth;
|
|
7617
7619
|
}
|
|
7618
7620
|
get __hasMultiPaint() {
|
|
7619
7621
|
const t = this;
|
|
@@ -7681,7 +7683,7 @@ var LeaferUI = function(exports) {
|
|
|
7681
7683
|
const isStr = isString(value);
|
|
7682
7684
|
if (isStr || value && isObject(value[0])) {
|
|
7683
7685
|
this.__setInput("path", value);
|
|
7684
|
-
this._path = isStr ? parse(value) : objectToCanvasData(value);
|
|
7686
|
+
this._path = isStr ? parse(value, this.__useArrow) : objectToCanvasData(value);
|
|
7685
7687
|
} else {
|
|
7686
7688
|
if (this.__input) this.__removeInput("path");
|
|
7687
7689
|
this._path = value;
|
|
@@ -7714,6 +7716,10 @@ var LeaferUI = function(exports) {
|
|
|
7714
7716
|
}
|
|
7715
7717
|
return strokeWidth;
|
|
7716
7718
|
}
|
|
7719
|
+
__checkComplex() {
|
|
7720
|
+
const t = this;
|
|
7721
|
+
stintSet$3(t, "__complex", t.__isFills || t.__isStrokes || t.cornerRadius || t.__useEffect);
|
|
7722
|
+
}
|
|
7717
7723
|
__setPaint(attrName, value) {
|
|
7718
7724
|
this.__setInput(attrName, value);
|
|
7719
7725
|
const layout = this.__leaf.__layout;
|
|
@@ -7783,7 +7789,11 @@ var LeaferUI = function(exports) {
|
|
|
7783
7789
|
return !this.__pathInputed;
|
|
7784
7790
|
}
|
|
7785
7791
|
}
|
|
7786
|
-
class PolygonData extends
|
|
7792
|
+
class PolygonData extends UIData {
|
|
7793
|
+
get __usePathBox() {
|
|
7794
|
+
return this.points || this.__pathInputed;
|
|
7795
|
+
}
|
|
7796
|
+
}
|
|
7787
7797
|
class StarData extends UIData {
|
|
7788
7798
|
get __boxStroke() {
|
|
7789
7799
|
return !this.__pathInputed;
|
|
@@ -7885,7 +7895,7 @@ var LeaferUI = function(exports) {
|
|
|
7885
7895
|
if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
|
|
7886
7896
|
boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
|
|
7887
7897
|
if (!data.__boxStroke || data.__useArrow) {
|
|
7888
|
-
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
|
|
7898
|
+
const miterLimitAddWidth = data.__isLinePath ? 0 : (data.strokeJoin === "miter" ? 10 : 1) * spread;
|
|
7889
7899
|
const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
|
|
7890
7900
|
spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
|
|
7891
7901
|
}
|
|
@@ -7928,7 +7938,7 @@ var LeaferUI = function(exports) {
|
|
|
7928
7938
|
data.__useEffect = !!(shadow || otherEffect);
|
|
7929
7939
|
}
|
|
7930
7940
|
data.__checkSingle();
|
|
7931
|
-
|
|
7941
|
+
data.__checkComplex();
|
|
7932
7942
|
},
|
|
7933
7943
|
__drawFast(canvas, options) {
|
|
7934
7944
|
drawFast(this, canvas, options);
|
|
@@ -9022,7 +9032,7 @@ var LeaferUI = function(exports) {
|
|
|
9022
9032
|
__decorate([ dataType(false) ], exports.Canvas.prototype, "safeResize", void 0);
|
|
9023
9033
|
__decorate([ resizeType() ], exports.Canvas.prototype, "contextSettings", void 0);
|
|
9024
9034
|
exports.Canvas = __decorate([ registerUI() ], exports.Canvas);
|
|
9025
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes,
|
|
9035
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9026
9036
|
exports.Text = class Text extends exports.UI {
|
|
9027
9037
|
get __tag() {
|
|
9028
9038
|
return "Text";
|
|
@@ -9049,9 +9059,10 @@ var LeaferUI = function(exports) {
|
|
|
9049
9059
|
const {fontSize: fontSize, italic: italic, padding: padding, __autoWidth: autoWidth, __autoHeight: autoHeight} = data;
|
|
9050
9060
|
this.__updateTextDrawData();
|
|
9051
9061
|
const {bounds: contentBounds} = data.__textDrawData;
|
|
9062
|
+
console.log(contentBounds);
|
|
9052
9063
|
const b = layout.boxBounds;
|
|
9053
9064
|
layout.contentBounds = contentBounds;
|
|
9054
|
-
if (data.__lineHeight < fontSize)
|
|
9065
|
+
if (data.__lineHeight < fontSize) layout.renderChanged = true;
|
|
9055
9066
|
if (autoWidth || autoHeight) {
|
|
9056
9067
|
b.x = autoWidth ? contentBounds.x : 0;
|
|
9057
9068
|
b.y = autoHeight ? contentBounds.y : 0;
|
|
@@ -9071,6 +9082,8 @@ var LeaferUI = function(exports) {
|
|
|
9071
9082
|
__updateRenderSpread() {
|
|
9072
9083
|
let spread = super.__updateRenderSpread();
|
|
9073
9084
|
if (!spread) spread = this.isOverflow ? 1 : 0;
|
|
9085
|
+
const {__lineHeight: __lineHeight, fontSize: fontSize} = this.__;
|
|
9086
|
+
if (__lineHeight < fontSize) spread = FourNumberHelper.max(spread, (fontSize - __lineHeight) / 2);
|
|
9074
9087
|
return spread;
|
|
9075
9088
|
}
|
|
9076
9089
|
__updateRenderBounds() {
|
|
@@ -10861,8 +10874,8 @@ var LeaferUI = function(exports) {
|
|
|
10861
10874
|
}
|
|
10862
10875
|
}
|
|
10863
10876
|
}
|
|
10864
|
-
data["_" + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
10865
10877
|
if (leafPaints.length) {
|
|
10878
|
+
data["_" + attrName] = leafPaints;
|
|
10866
10879
|
if (leafPaints.every(item => item.isTransparent)) {
|
|
10867
10880
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
10868
10881
|
isTransparent = true;
|
|
@@ -10877,6 +10890,7 @@ var LeaferUI = function(exports) {
|
|
|
10877
10890
|
}
|
|
10878
10891
|
} else {
|
|
10879
10892
|
data.__removePaint(attrName, false);
|
|
10893
|
+
data["_" + attrName] = "";
|
|
10880
10894
|
}
|
|
10881
10895
|
}
|
|
10882
10896
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -11020,11 +11034,12 @@ var LeaferUI = function(exports) {
|
|
|
11020
11034
|
needUpdate = false;
|
|
11021
11035
|
}
|
|
11022
11036
|
}
|
|
11037
|
+
if (paint.mode === "brush") PaintImage.brush(leafPaint);
|
|
11023
11038
|
if (!leafPaint.data) {
|
|
11024
11039
|
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
11025
|
-
const {transform: transform} = leafPaint.data, {opacity: opacity
|
|
11026
|
-
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
11027
|
-
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
11040
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity} = paint;
|
|
11041
|
+
const clip = (transform && !transform.onlyScale || data.path || data.cornerRadius) && !leafPaint.brush;
|
|
11042
|
+
if (clip || opacity && opacity < 1 || paint.blendMode) leafPaint.complex = clip ? 2 : true;
|
|
11028
11043
|
}
|
|
11029
11044
|
if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
|
|
11030
11045
|
return needUpdate;
|
|
@@ -11103,6 +11118,7 @@ var LeaferUI = function(exports) {
|
|
|
11103
11118
|
break;
|
|
11104
11119
|
|
|
11105
11120
|
case "repeat":
|
|
11121
|
+
case "brush":
|
|
11106
11122
|
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
11107
11123
|
if (!repeat) data.repeat = "repeat";
|
|
11108
11124
|
const count = isObject(repeat);
|
|
@@ -11230,7 +11246,7 @@ var LeaferUI = function(exports) {
|
|
|
11230
11246
|
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
11231
11247
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
11232
11248
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
11233
|
-
const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
11249
|
+
const {image: image, brush: brush, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
11234
11250
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
11235
11251
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
11236
11252
|
width *= scaleX;
|
|
@@ -11238,6 +11254,10 @@ var LeaferUI = function(exports) {
|
|
|
11238
11254
|
if (gap) {
|
|
11239
11255
|
xGap = gap.x * scaleX / abs$2(data.scaleX || 1);
|
|
11240
11256
|
yGap = gap.y * scaleY / abs$2(data.scaleY || 1);
|
|
11257
|
+
if (brush) {
|
|
11258
|
+
const brushScale = PaintImage.getBrushScale(paint, ui);
|
|
11259
|
+
xGap /= brushScale, yGap /= brushScale;
|
|
11260
|
+
}
|
|
11241
11261
|
}
|
|
11242
11262
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
11243
11263
|
scaleX *= getFloorScale(width + (xGap || 0));
|
|
@@ -11247,7 +11267,7 @@ var LeaferUI = function(exports) {
|
|
|
11247
11267
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
11248
11268
|
}
|
|
11249
11269
|
const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
11250
|
-
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
11270
|
+
const pattern = brush ? imageCanvas : image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
11251
11271
|
paint.style = pattern;
|
|
11252
11272
|
paint.patternId = id;
|
|
11253
11273
|
}
|
|
@@ -11266,9 +11286,9 @@ var LeaferUI = function(exports) {
|
|
|
11266
11286
|
}
|
|
11267
11287
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
11268
11288
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
11269
|
-
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
11289
|
+
const {image: image, brush: brush, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
11270
11290
|
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
11271
|
-
return false;
|
|
11291
|
+
if (!(brush && paint.style)) return false;
|
|
11272
11292
|
} else {
|
|
11273
11293
|
if (drawImage) {
|
|
11274
11294
|
if (data.repeat) {
|
|
@@ -11282,17 +11302,17 @@ var LeaferUI = function(exports) {
|
|
|
11282
11302
|
canvas.fillStyle = paint.style || "#000";
|
|
11283
11303
|
canvas.fill();
|
|
11284
11304
|
}
|
|
11285
|
-
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
11286
|
-
return true;
|
|
11287
11305
|
} else {
|
|
11288
11306
|
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
11289
|
-
return false;
|
|
11307
|
+
if (!(brush && paint.style)) return false;
|
|
11290
11308
|
}
|
|
11291
11309
|
}
|
|
11310
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
11311
|
+
return true;
|
|
11292
11312
|
}
|
|
11293
11313
|
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
11294
|
-
const {data: data, image: image, complex: complex} = paint;
|
|
11295
|
-
let {width: width, height: height} = image;
|
|
11314
|
+
const {data: data, image: image, brush: brush, complex: complex} = paint;
|
|
11315
|
+
let {width: width, height: height} = image, view = brush || image;
|
|
11296
11316
|
if (complex) {
|
|
11297
11317
|
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
11298
11318
|
canvas.save();
|
|
@@ -11300,15 +11320,16 @@ var LeaferUI = function(exports) {
|
|
|
11300
11320
|
blendMode && (canvas.blendMode = blendMode);
|
|
11301
11321
|
opacity && (canvas.opacity *= opacity);
|
|
11302
11322
|
transform && canvas.transform(transform);
|
|
11303
|
-
|
|
11323
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
11304
11324
|
canvas.restore();
|
|
11305
11325
|
} else {
|
|
11306
11326
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
11307
|
-
|
|
11327
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
11308
11328
|
}
|
|
11309
11329
|
}
|
|
11310
11330
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
11311
11331
|
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
11332
|
+
if (paint.brush) PaintImage.addBrushScale(scaleData, paint, ui);
|
|
11312
11333
|
if (canvas) {
|
|
11313
11334
|
const {pixelRatio: pixelRatio} = canvas;
|
|
11314
11335
|
scaleData.scaleX *= pixelRatio;
|
|
@@ -11324,6 +11345,7 @@ var LeaferUI = function(exports) {
|
|
|
11324
11345
|
const paints = data["_" + attrName];
|
|
11325
11346
|
if (isArray(paints)) {
|
|
11326
11347
|
let paint, image, recycleMap, input, url;
|
|
11348
|
+
const ui = data.__leaf;
|
|
11327
11349
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
11328
11350
|
paint = paints[i];
|
|
11329
11351
|
image = paint.image;
|
|
@@ -11332,7 +11354,8 @@ var LeaferUI = function(exports) {
|
|
|
11332
11354
|
if (!recycleMap) recycleMap = {};
|
|
11333
11355
|
recycleMap[url] = true;
|
|
11334
11356
|
ImageManager.recyclePaint(paint);
|
|
11335
|
-
if (
|
|
11357
|
+
if (paint.brush) PaintImage.recycleBrush(paint, ui);
|
|
11358
|
+
if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, ui);
|
|
11336
11359
|
if (image.loading) {
|
|
11337
11360
|
if (!input) {
|
|
11338
11361
|
input = data.__input && data.__input[attrName] || [];
|