@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.module.js
CHANGED
|
@@ -3082,7 +3082,7 @@ const PathConvert = {
|
|
|
3082
3082
|
case M$5:
|
|
3083
3083
|
x = old[i + 1];
|
|
3084
3084
|
y = old[i + 2];
|
|
3085
|
-
data.push(M$5, x, y);
|
|
3085
|
+
data.push(lastCommand === command ? L$6 : M$5, x, y);
|
|
3086
3086
|
i += 3;
|
|
3087
3087
|
break;
|
|
3088
3088
|
|
|
@@ -6075,12 +6075,13 @@ const LeafBounds = {
|
|
|
6075
6075
|
if (this.__hasWorldEvent) BoundsEvent.emitWorld(this);
|
|
6076
6076
|
},
|
|
6077
6077
|
__updateLocalBounds() {
|
|
6078
|
-
const layout = this.__layout;
|
|
6078
|
+
const layout = this.__layout, data = this.__;
|
|
6079
6079
|
if (layout.boxChanged) {
|
|
6080
|
-
if (!
|
|
6080
|
+
if (!data.__pathInputed) this.__updatePath();
|
|
6081
6081
|
this.__updateRenderPath();
|
|
6082
6082
|
this.__updateBoxBounds();
|
|
6083
6083
|
layout.resized = "inner";
|
|
6084
|
+
if (data.__strokeGeometry) data.__strokeGeometry = undefined;
|
|
6084
6085
|
}
|
|
6085
6086
|
if (layout.localBoxChanged) {
|
|
6086
6087
|
if (this.__local) this.__updateLocalBoxBounds();
|
|
@@ -6103,6 +6104,7 @@ const LeafBounds = {
|
|
|
6103
6104
|
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread) layout.renderChanged = true;
|
|
6104
6105
|
if (this.parent) this.parent.__layout.strokeChange();
|
|
6105
6106
|
layout.resized = "inner";
|
|
6107
|
+
if (data.__strokeGeometry) data.__strokeGeometry = undefined;
|
|
6106
6108
|
}
|
|
6107
6109
|
if (layout.renderChanged) {
|
|
6108
6110
|
layout.renderSpread = this.__updateRenderSpread();
|
|
@@ -7079,7 +7081,7 @@ class LeafLevelList {
|
|
|
7079
7081
|
}
|
|
7080
7082
|
}
|
|
7081
7083
|
|
|
7082
|
-
const version = "2.
|
|
7084
|
+
const version = "2.1.1";
|
|
7083
7085
|
|
|
7084
7086
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
7085
7087
|
get allowBackgroundColor() {
|
|
@@ -8085,8 +8087,8 @@ class UIData extends LeafData {
|
|
|
8085
8087
|
return this.__getRealStrokeWidth();
|
|
8086
8088
|
}
|
|
8087
8089
|
get __maxStrokeWidth() {
|
|
8088
|
-
const t = this;
|
|
8089
|
-
return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle,
|
|
8090
|
+
const t = this, strokeWidth = t.__hasStrokeSides || t.strokeWidth;
|
|
8091
|
+
return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, strokeWidth) : strokeWidth;
|
|
8090
8092
|
}
|
|
8091
8093
|
get __hasMultiPaint() {
|
|
8092
8094
|
const t = this;
|
|
@@ -8154,7 +8156,7 @@ class UIData extends LeafData {
|
|
|
8154
8156
|
const isStr = isString(value);
|
|
8155
8157
|
if (isStr || value && isObject(value[0])) {
|
|
8156
8158
|
this.__setInput("path", value);
|
|
8157
|
-
this._path = isStr ? parse(value) : objectToCanvasData(value);
|
|
8159
|
+
this._path = isStr ? parse(value, this.__useArrow) : objectToCanvasData(value);
|
|
8158
8160
|
} else {
|
|
8159
8161
|
if (this.__input) this.__removeInput("path");
|
|
8160
8162
|
this._path = value;
|
|
@@ -8187,6 +8189,10 @@ class UIData extends LeafData {
|
|
|
8187
8189
|
}
|
|
8188
8190
|
return strokeWidth;
|
|
8189
8191
|
}
|
|
8192
|
+
__checkComplex() {
|
|
8193
|
+
const t = this;
|
|
8194
|
+
stintSet$3(t, "__complex", t.__isFills || t.__isStrokes || t.cornerRadius || t.__useEffect);
|
|
8195
|
+
}
|
|
8190
8196
|
__setPaint(attrName, value) {
|
|
8191
8197
|
this.__setInput(attrName, value);
|
|
8192
8198
|
const layout = this.__leaf.__layout;
|
|
@@ -8265,7 +8271,11 @@ class EllipseData extends UIData {
|
|
|
8265
8271
|
}
|
|
8266
8272
|
}
|
|
8267
8273
|
|
|
8268
|
-
class PolygonData extends
|
|
8274
|
+
class PolygonData extends UIData {
|
|
8275
|
+
get __usePathBox() {
|
|
8276
|
+
return this.points || this.__pathInputed;
|
|
8277
|
+
}
|
|
8278
|
+
}
|
|
8269
8279
|
|
|
8270
8280
|
class StarData extends UIData {
|
|
8271
8281
|
get __boxStroke() {
|
|
@@ -8376,7 +8386,7 @@ const UIBounds = {
|
|
|
8376
8386
|
if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
|
|
8377
8387
|
boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
|
|
8378
8388
|
if (!data.__boxStroke || data.__useArrow) {
|
|
8379
|
-
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
|
|
8389
|
+
const miterLimitAddWidth = data.__isLinePath ? 0 : (data.strokeJoin === "miter" ? 10 : 1) * spread;
|
|
8380
8390
|
const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
|
|
8381
8391
|
spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
|
|
8382
8392
|
}
|
|
@@ -8421,7 +8431,7 @@ const UIRender = {
|
|
|
8421
8431
|
data.__useEffect = !!(shadow || otherEffect);
|
|
8422
8432
|
}
|
|
8423
8433
|
data.__checkSingle();
|
|
8424
|
-
|
|
8434
|
+
data.__checkComplex();
|
|
8425
8435
|
},
|
|
8426
8436
|
__drawFast(canvas, options) {
|
|
8427
8437
|
drawFast(this, canvas, options);
|
|
@@ -9680,7 +9690,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9680
9690
|
|
|
9681
9691
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9682
9692
|
|
|
9683
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes,
|
|
9693
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9684
9694
|
|
|
9685
9695
|
let Text = class Text extends UI {
|
|
9686
9696
|
get __tag() {
|
|
@@ -9708,9 +9718,10 @@ let Text = class Text extends UI {
|
|
|
9708
9718
|
const {fontSize: fontSize, italic: italic, padding: padding, __autoWidth: autoWidth, __autoHeight: autoHeight} = data;
|
|
9709
9719
|
this.__updateTextDrawData();
|
|
9710
9720
|
const {bounds: contentBounds} = data.__textDrawData;
|
|
9721
|
+
console.log(contentBounds);
|
|
9711
9722
|
const b = layout.boxBounds;
|
|
9712
9723
|
layout.contentBounds = contentBounds;
|
|
9713
|
-
if (data.__lineHeight < fontSize)
|
|
9724
|
+
if (data.__lineHeight < fontSize) layout.renderChanged = true;
|
|
9714
9725
|
if (autoWidth || autoHeight) {
|
|
9715
9726
|
b.x = autoWidth ? contentBounds.x : 0;
|
|
9716
9727
|
b.y = autoHeight ? contentBounds.y : 0;
|
|
@@ -9730,6 +9741,8 @@ let Text = class Text extends UI {
|
|
|
9730
9741
|
__updateRenderSpread() {
|
|
9731
9742
|
let spread = super.__updateRenderSpread();
|
|
9732
9743
|
if (!spread) spread = this.isOverflow ? 1 : 0;
|
|
9744
|
+
const {__lineHeight: __lineHeight, fontSize: fontSize} = this.__;
|
|
9745
|
+
if (__lineHeight < fontSize) spread = FourNumberHelper.max(spread, (fontSize - __lineHeight) / 2);
|
|
9733
9746
|
return spread;
|
|
9734
9747
|
}
|
|
9735
9748
|
__updateRenderBounds() {
|
|
@@ -11703,8 +11716,8 @@ function compute(attrName, ui) {
|
|
|
11703
11716
|
}
|
|
11704
11717
|
}
|
|
11705
11718
|
}
|
|
11706
|
-
data["_" + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
11707
11719
|
if (leafPaints.length) {
|
|
11720
|
+
data["_" + attrName] = leafPaints;
|
|
11708
11721
|
if (leafPaints.every(item => item.isTransparent)) {
|
|
11709
11722
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
11710
11723
|
isTransparent = true;
|
|
@@ -11719,6 +11732,7 @@ function compute(attrName, ui) {
|
|
|
11719
11732
|
}
|
|
11720
11733
|
} else {
|
|
11721
11734
|
data.__removePaint(attrName, false);
|
|
11735
|
+
data["_" + attrName] = "";
|
|
11722
11736
|
}
|
|
11723
11737
|
}
|
|
11724
11738
|
|
|
@@ -11868,11 +11882,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
11868
11882
|
needUpdate = false;
|
|
11869
11883
|
}
|
|
11870
11884
|
}
|
|
11885
|
+
if (paint.mode === "brush") PaintImage.brush(leafPaint);
|
|
11871
11886
|
if (!leafPaint.data) {
|
|
11872
11887
|
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
11873
|
-
const {transform: transform} = leafPaint.data, {opacity: opacity
|
|
11874
|
-
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
11875
|
-
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
11888
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity} = paint;
|
|
11889
|
+
const clip = (transform && !transform.onlyScale || data.path || data.cornerRadius) && !leafPaint.brush;
|
|
11890
|
+
if (clip || opacity && opacity < 1 || paint.blendMode) leafPaint.complex = clip ? 2 : true;
|
|
11876
11891
|
}
|
|
11877
11892
|
if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
|
|
11878
11893
|
return needUpdate;
|
|
@@ -11962,6 +11977,7 @@ function getPatternData(paint, box, image) {
|
|
|
11962
11977
|
break;
|
|
11963
11978
|
|
|
11964
11979
|
case "repeat":
|
|
11980
|
+
case "brush":
|
|
11965
11981
|
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
11966
11982
|
if (!repeat) data.repeat = "repeat";
|
|
11967
11983
|
const count = isObject(repeat);
|
|
@@ -12102,7 +12118,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
12102
12118
|
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
12103
12119
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
12104
12120
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
12105
|
-
const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
12121
|
+
const {image: image, brush: brush, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
12106
12122
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
12107
12123
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
12108
12124
|
width *= scaleX;
|
|
@@ -12110,6 +12126,10 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
12110
12126
|
if (gap) {
|
|
12111
12127
|
xGap = gap.x * scaleX / abs$2(data.scaleX || 1);
|
|
12112
12128
|
yGap = gap.y * scaleY / abs$2(data.scaleY || 1);
|
|
12129
|
+
if (brush) {
|
|
12130
|
+
const brushScale = PaintImage.getBrushScale(paint, ui);
|
|
12131
|
+
xGap /= brushScale, yGap /= brushScale;
|
|
12132
|
+
}
|
|
12113
12133
|
}
|
|
12114
12134
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
12115
12135
|
scaleX *= getFloorScale(width + (xGap || 0));
|
|
@@ -12119,7 +12139,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
12119
12139
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
12120
12140
|
}
|
|
12121
12141
|
const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
12122
|
-
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
12142
|
+
const pattern = brush ? imageCanvas : image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
12123
12143
|
paint.style = pattern;
|
|
12124
12144
|
paint.patternId = id;
|
|
12125
12145
|
}
|
|
@@ -12140,9 +12160,9 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
12140
12160
|
|
|
12141
12161
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
12142
12162
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
12143
|
-
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
12163
|
+
const {image: image, brush: brush, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
12144
12164
|
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
12145
|
-
return false;
|
|
12165
|
+
if (!(brush && paint.style)) return false;
|
|
12146
12166
|
} else {
|
|
12147
12167
|
if (drawImage) {
|
|
12148
12168
|
if (data.repeat) {
|
|
@@ -12156,18 +12176,18 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
12156
12176
|
canvas.fillStyle = paint.style || "#000";
|
|
12157
12177
|
canvas.fill();
|
|
12158
12178
|
}
|
|
12159
|
-
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
12160
|
-
return true;
|
|
12161
12179
|
} else {
|
|
12162
12180
|
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
12163
|
-
return false;
|
|
12181
|
+
if (!(brush && paint.style)) return false;
|
|
12164
12182
|
}
|
|
12165
12183
|
}
|
|
12184
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
12185
|
+
return true;
|
|
12166
12186
|
}
|
|
12167
12187
|
|
|
12168
12188
|
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
12169
|
-
const {data: data, image: image, complex: complex} = paint;
|
|
12170
|
-
let {width: width, height: height} = image;
|
|
12189
|
+
const {data: data, image: image, brush: brush, complex: complex} = paint;
|
|
12190
|
+
let {width: width, height: height} = image, view = brush || image;
|
|
12171
12191
|
if (complex) {
|
|
12172
12192
|
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
12173
12193
|
canvas.save();
|
|
@@ -12175,16 +12195,17 @@ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions)
|
|
|
12175
12195
|
blendMode && (canvas.blendMode = blendMode);
|
|
12176
12196
|
opacity && (canvas.opacity *= opacity);
|
|
12177
12197
|
transform && canvas.transform(transform);
|
|
12178
|
-
|
|
12198
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
12179
12199
|
canvas.restore();
|
|
12180
12200
|
} else {
|
|
12181
12201
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
12182
|
-
|
|
12202
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
12183
12203
|
}
|
|
12184
12204
|
}
|
|
12185
12205
|
|
|
12186
12206
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
12187
12207
|
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
12208
|
+
if (paint.brush) PaintImage.addBrushScale(scaleData, paint, ui);
|
|
12188
12209
|
if (canvas) {
|
|
12189
12210
|
const {pixelRatio: pixelRatio} = canvas;
|
|
12190
12211
|
scaleData.scaleX *= pixelRatio;
|
|
@@ -12201,6 +12222,7 @@ function recycleImage(attrName, data) {
|
|
|
12201
12222
|
const paints = data["_" + attrName];
|
|
12202
12223
|
if (isArray(paints)) {
|
|
12203
12224
|
let paint, image, recycleMap, input, url;
|
|
12225
|
+
const ui = data.__leaf;
|
|
12204
12226
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
12205
12227
|
paint = paints[i];
|
|
12206
12228
|
image = paint.image;
|
|
@@ -12209,7 +12231,8 @@ function recycleImage(attrName, data) {
|
|
|
12209
12231
|
if (!recycleMap) recycleMap = {};
|
|
12210
12232
|
recycleMap[url] = true;
|
|
12211
12233
|
ImageManager.recyclePaint(paint);
|
|
12212
|
-
if (
|
|
12234
|
+
if (paint.brush) PaintImage.recycleBrush(paint, ui);
|
|
12235
|
+
if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, ui);
|
|
12213
12236
|
if (image.loading) {
|
|
12214
12237
|
if (!input) {
|
|
12215
12238
|
input = data.__input && data.__input[attrName] || [];
|