@leafer-game/worker 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/worker.js +47 -26
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +47 -26
- 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
|
@@ -3070,7 +3070,7 @@ const PathConvert = {
|
|
|
3070
3070
|
return needConvert ? PathConvert.toCanvasData(data, curveMode) : data;
|
|
3071
3071
|
},
|
|
3072
3072
|
toCanvasData(old, curveMode) {
|
|
3073
|
-
let x = 0, y = 0, x1 = 0, y1 = 0, i = 0, len = old.length, controlX, controlY, command, lastCommand, smooth;
|
|
3073
|
+
let x = 0, y = 0, x1 = 0, y1 = 0, startX = 0, startY = 0, i = 0, len = old.length, controlX, controlY, command, lastCommand, smooth;
|
|
3074
3074
|
const data = [];
|
|
3075
3075
|
while (i < len) {
|
|
3076
3076
|
command = old[i];
|
|
@@ -3082,7 +3082,8 @@ 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
|
+
if (lastCommand === command) data.push(L$6, x, y); else data.push(M$5, x, y), startX = x,
|
|
3086
|
+
startY = y;
|
|
3086
3087
|
i += 3;
|
|
3087
3088
|
break;
|
|
3088
3089
|
|
|
@@ -3197,6 +3198,8 @@ const PathConvert = {
|
|
|
3197
3198
|
case z:
|
|
3198
3199
|
case Z$5:
|
|
3199
3200
|
data.push(Z$5);
|
|
3201
|
+
x = startX;
|
|
3202
|
+
y = startY;
|
|
3200
3203
|
i++;
|
|
3201
3204
|
break;
|
|
3202
3205
|
|
|
@@ -6075,12 +6078,13 @@ const LeafBounds = {
|
|
|
6075
6078
|
if (this.__hasWorldEvent) BoundsEvent.emitWorld(this);
|
|
6076
6079
|
},
|
|
6077
6080
|
__updateLocalBounds() {
|
|
6078
|
-
const layout = this.__layout;
|
|
6081
|
+
const layout = this.__layout, data = this.__;
|
|
6079
6082
|
if (layout.boxChanged) {
|
|
6080
|
-
if (!
|
|
6083
|
+
if (!data.__pathInputed) this.__updatePath();
|
|
6081
6084
|
this.__updateRenderPath();
|
|
6082
6085
|
this.__updateBoxBounds();
|
|
6083
6086
|
layout.resized = "inner";
|
|
6087
|
+
if (data.__strokeGeometry) data.__strokeGeometry = undefined;
|
|
6084
6088
|
}
|
|
6085
6089
|
if (layout.localBoxChanged) {
|
|
6086
6090
|
if (this.__local) this.__updateLocalBoxBounds();
|
|
@@ -6103,6 +6107,7 @@ const LeafBounds = {
|
|
|
6103
6107
|
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread) layout.renderChanged = true;
|
|
6104
6108
|
if (this.parent) this.parent.__layout.strokeChange();
|
|
6105
6109
|
layout.resized = "inner";
|
|
6110
|
+
if (data.__strokeGeometry) data.__strokeGeometry = undefined;
|
|
6106
6111
|
}
|
|
6107
6112
|
if (layout.renderChanged) {
|
|
6108
6113
|
layout.renderSpread = this.__updateRenderSpread();
|
|
@@ -7079,7 +7084,7 @@ class LeafLevelList {
|
|
|
7079
7084
|
}
|
|
7080
7085
|
}
|
|
7081
7086
|
|
|
7082
|
-
const version = "2.1.
|
|
7087
|
+
const version = "2.1.2";
|
|
7083
7088
|
|
|
7084
7089
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
7085
7090
|
get allowBackgroundColor() {
|
|
@@ -8154,7 +8159,7 @@ class UIData extends LeafData {
|
|
|
8154
8159
|
const isStr = isString(value);
|
|
8155
8160
|
if (isStr || value && isObject(value[0])) {
|
|
8156
8161
|
this.__setInput("path", value);
|
|
8157
|
-
this._path = isStr ? parse(value) : objectToCanvasData(value);
|
|
8162
|
+
this._path = isStr ? parse(value, this.__useArrow) : objectToCanvasData(value);
|
|
8158
8163
|
} else {
|
|
8159
8164
|
if (this.__input) this.__removeInput("path");
|
|
8160
8165
|
this._path = value;
|
|
@@ -8269,7 +8274,11 @@ class EllipseData extends UIData {
|
|
|
8269
8274
|
}
|
|
8270
8275
|
}
|
|
8271
8276
|
|
|
8272
|
-
class PolygonData extends
|
|
8277
|
+
class PolygonData extends UIData {
|
|
8278
|
+
get __usePathBox() {
|
|
8279
|
+
return this.points || this.__pathInputed;
|
|
8280
|
+
}
|
|
8281
|
+
}
|
|
8273
8282
|
|
|
8274
8283
|
class StarData extends UIData {
|
|
8275
8284
|
get __boxStroke() {
|
|
@@ -8380,7 +8389,7 @@ const UIBounds = {
|
|
|
8380
8389
|
if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
|
|
8381
8390
|
boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
|
|
8382
8391
|
if (!data.__boxStroke || data.__useArrow) {
|
|
8383
|
-
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
|
|
8392
|
+
const miterLimitAddWidth = data.__isLinePath ? 0 : (data.strokeJoin === "miter" ? 10 : 1) * spread;
|
|
8384
8393
|
const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
|
|
8385
8394
|
spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
|
|
8386
8395
|
}
|
|
@@ -9684,7 +9693,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9684
9693
|
|
|
9685
9694
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9686
9695
|
|
|
9687
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes,
|
|
9696
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9688
9697
|
|
|
9689
9698
|
let Text = class Text extends UI {
|
|
9690
9699
|
get __tag() {
|
|
@@ -9714,7 +9723,7 @@ let Text = class Text extends UI {
|
|
|
9714
9723
|
const {bounds: contentBounds} = data.__textDrawData;
|
|
9715
9724
|
const b = layout.boxBounds;
|
|
9716
9725
|
layout.contentBounds = contentBounds;
|
|
9717
|
-
if (data.__lineHeight < fontSize)
|
|
9726
|
+
if (data.__lineHeight < fontSize) layout.renderChanged = true;
|
|
9718
9727
|
if (autoWidth || autoHeight) {
|
|
9719
9728
|
b.x = autoWidth ? contentBounds.x : 0;
|
|
9720
9729
|
b.y = autoHeight ? contentBounds.y : 0;
|
|
@@ -9734,6 +9743,8 @@ let Text = class Text extends UI {
|
|
|
9734
9743
|
__updateRenderSpread() {
|
|
9735
9744
|
let spread = super.__updateRenderSpread();
|
|
9736
9745
|
if (!spread) spread = this.isOverflow ? 1 : 0;
|
|
9746
|
+
const {__lineHeight: __lineHeight, fontSize: fontSize} = this.__;
|
|
9747
|
+
if (__lineHeight < fontSize) spread = FourNumberHelper.max(spread, (fontSize - __lineHeight) / 2);
|
|
9737
9748
|
return spread;
|
|
9738
9749
|
}
|
|
9739
9750
|
__updateRenderBounds() {
|
|
@@ -11707,8 +11718,8 @@ function compute(attrName, ui) {
|
|
|
11707
11718
|
}
|
|
11708
11719
|
}
|
|
11709
11720
|
}
|
|
11710
|
-
data["_" + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
11711
11721
|
if (leafPaints.length) {
|
|
11722
|
+
data["_" + attrName] = leafPaints;
|
|
11712
11723
|
if (leafPaints.every(item => item.isTransparent)) {
|
|
11713
11724
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
11714
11725
|
isTransparent = true;
|
|
@@ -11723,6 +11734,7 @@ function compute(attrName, ui) {
|
|
|
11723
11734
|
}
|
|
11724
11735
|
} else {
|
|
11725
11736
|
data.__removePaint(attrName, false);
|
|
11737
|
+
data["_" + attrName] = "";
|
|
11726
11738
|
}
|
|
11727
11739
|
}
|
|
11728
11740
|
|
|
@@ -11872,11 +11884,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
11872
11884
|
needUpdate = false;
|
|
11873
11885
|
}
|
|
11874
11886
|
}
|
|
11887
|
+
if (paint.mode === "brush") PaintImage.brush(leafPaint);
|
|
11875
11888
|
if (!leafPaint.data) {
|
|
11876
11889
|
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
11877
|
-
const {transform: transform} = leafPaint.data, {opacity: opacity
|
|
11878
|
-
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
11879
|
-
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
11890
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity} = paint;
|
|
11891
|
+
const clip = (transform && !transform.onlyScale || data.path || data.cornerRadius) && !leafPaint.brush;
|
|
11892
|
+
if (clip || opacity && opacity < 1 || paint.blendMode) leafPaint.complex = clip ? 2 : true;
|
|
11880
11893
|
}
|
|
11881
11894
|
if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
|
|
11882
11895
|
return needUpdate;
|
|
@@ -11966,6 +11979,7 @@ function getPatternData(paint, box, image) {
|
|
|
11966
11979
|
break;
|
|
11967
11980
|
|
|
11968
11981
|
case "repeat":
|
|
11982
|
+
case "brush":
|
|
11969
11983
|
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
11970
11984
|
if (!repeat) data.repeat = "repeat";
|
|
11971
11985
|
const count = isObject(repeat);
|
|
@@ -12106,7 +12120,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
12106
12120
|
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
12107
12121
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
12108
12122
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
12109
|
-
const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
12123
|
+
const {image: image, brush: brush, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
12110
12124
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
12111
12125
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
12112
12126
|
width *= scaleX;
|
|
@@ -12114,6 +12128,10 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
12114
12128
|
if (gap) {
|
|
12115
12129
|
xGap = gap.x * scaleX / abs$2(data.scaleX || 1);
|
|
12116
12130
|
yGap = gap.y * scaleY / abs$2(data.scaleY || 1);
|
|
12131
|
+
if (brush) {
|
|
12132
|
+
const brushScale = PaintImage.getBrushScale(paint, ui);
|
|
12133
|
+
xGap /= brushScale, yGap /= brushScale;
|
|
12134
|
+
}
|
|
12117
12135
|
}
|
|
12118
12136
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
12119
12137
|
scaleX *= getFloorScale(width + (xGap || 0));
|
|
@@ -12123,7 +12141,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
12123
12141
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
12124
12142
|
}
|
|
12125
12143
|
const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
12126
|
-
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
12144
|
+
const pattern = brush ? imageCanvas : image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
12127
12145
|
paint.style = pattern;
|
|
12128
12146
|
paint.patternId = id;
|
|
12129
12147
|
}
|
|
@@ -12144,9 +12162,9 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
12144
12162
|
|
|
12145
12163
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
12146
12164
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
12147
|
-
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
12165
|
+
const {image: image, brush: brush, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
12148
12166
|
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
12149
|
-
return false;
|
|
12167
|
+
if (!(brush && paint.style)) return false;
|
|
12150
12168
|
} else {
|
|
12151
12169
|
if (drawImage) {
|
|
12152
12170
|
if (data.repeat) {
|
|
@@ -12160,18 +12178,18 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
12160
12178
|
canvas.fillStyle = paint.style || "#000";
|
|
12161
12179
|
canvas.fill();
|
|
12162
12180
|
}
|
|
12163
|
-
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
12164
|
-
return true;
|
|
12165
12181
|
} else {
|
|
12166
12182
|
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
12167
|
-
return false;
|
|
12183
|
+
if (!(brush && paint.style)) return false;
|
|
12168
12184
|
}
|
|
12169
12185
|
}
|
|
12186
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
12187
|
+
return true;
|
|
12170
12188
|
}
|
|
12171
12189
|
|
|
12172
12190
|
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
12173
|
-
const {data: data, image: image, complex: complex} = paint;
|
|
12174
|
-
let {width: width, height: height} = image;
|
|
12191
|
+
const {data: data, image: image, brush: brush, complex: complex} = paint;
|
|
12192
|
+
let {width: width, height: height} = image, view = brush || image;
|
|
12175
12193
|
if (complex) {
|
|
12176
12194
|
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
12177
12195
|
canvas.save();
|
|
@@ -12179,16 +12197,17 @@ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions)
|
|
|
12179
12197
|
blendMode && (canvas.blendMode = blendMode);
|
|
12180
12198
|
opacity && (canvas.opacity *= opacity);
|
|
12181
12199
|
transform && canvas.transform(transform);
|
|
12182
|
-
|
|
12200
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
12183
12201
|
canvas.restore();
|
|
12184
12202
|
} else {
|
|
12185
12203
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
12186
|
-
|
|
12204
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
12187
12205
|
}
|
|
12188
12206
|
}
|
|
12189
12207
|
|
|
12190
12208
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
12191
12209
|
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
12210
|
+
if (paint.brush) PaintImage.addBrushScale(scaleData, paint, ui);
|
|
12192
12211
|
if (canvas) {
|
|
12193
12212
|
const {pixelRatio: pixelRatio} = canvas;
|
|
12194
12213
|
scaleData.scaleX *= pixelRatio;
|
|
@@ -12205,6 +12224,7 @@ function recycleImage(attrName, data) {
|
|
|
12205
12224
|
const paints = data["_" + attrName];
|
|
12206
12225
|
if (isArray(paints)) {
|
|
12207
12226
|
let paint, image, recycleMap, input, url;
|
|
12227
|
+
const ui = data.__leaf;
|
|
12208
12228
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
12209
12229
|
paint = paints[i];
|
|
12210
12230
|
image = paint.image;
|
|
@@ -12213,7 +12233,8 @@ function recycleImage(attrName, data) {
|
|
|
12213
12233
|
if (!recycleMap) recycleMap = {};
|
|
12214
12234
|
recycleMap[url] = true;
|
|
12215
12235
|
ImageManager.recyclePaint(paint);
|
|
12216
|
-
if (
|
|
12236
|
+
if (paint.brush) PaintImage.recycleBrush(paint, ui);
|
|
12237
|
+
if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, ui);
|
|
12217
12238
|
if (image.loading) {
|
|
12218
12239
|
if (!input) {
|
|
12219
12240
|
input = data.__input && data.__input[attrName] || [];
|