@leafer-draw/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.cjs +26 -16
- package/dist/worker.esm.js +26 -16
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +51 -28
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- 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 +7 -7
package/dist/worker.module.js
CHANGED
|
@@ -3082,7 +3082,7 @@ const PathConvert = {
|
|
|
3082
3082
|
case M$4:
|
|
3083
3083
|
x = old[i + 1];
|
|
3084
3084
|
y = old[i + 2];
|
|
3085
|
-
data.push(M$4, x, y);
|
|
3085
|
+
data.push(lastCommand === command ? L$5 : M$4, 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() {
|
|
@@ -7885,8 +7887,8 @@ class UIData extends LeafData {
|
|
|
7885
7887
|
return this.__getRealStrokeWidth();
|
|
7886
7888
|
}
|
|
7887
7889
|
get __maxStrokeWidth() {
|
|
7888
|
-
const t = this;
|
|
7889
|
-
return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle,
|
|
7890
|
+
const t = this, strokeWidth = t.__hasStrokeSides || t.strokeWidth;
|
|
7891
|
+
return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, strokeWidth) : strokeWidth;
|
|
7890
7892
|
}
|
|
7891
7893
|
get __hasMultiPaint() {
|
|
7892
7894
|
const t = this;
|
|
@@ -7954,7 +7956,7 @@ class UIData extends LeafData {
|
|
|
7954
7956
|
const isStr = isString(value);
|
|
7955
7957
|
if (isStr || value && isObject(value[0])) {
|
|
7956
7958
|
this.__setInput("path", value);
|
|
7957
|
-
this._path = isStr ? parse(value) : objectToCanvasData(value);
|
|
7959
|
+
this._path = isStr ? parse(value, this.__useArrow) : objectToCanvasData(value);
|
|
7958
7960
|
} else {
|
|
7959
7961
|
if (this.__input) this.__removeInput("path");
|
|
7960
7962
|
this._path = value;
|
|
@@ -7987,6 +7989,10 @@ class UIData extends LeafData {
|
|
|
7987
7989
|
}
|
|
7988
7990
|
return strokeWidth;
|
|
7989
7991
|
}
|
|
7992
|
+
__checkComplex() {
|
|
7993
|
+
const t = this;
|
|
7994
|
+
stintSet$3(t, "__complex", t.__isFills || t.__isStrokes || t.cornerRadius || t.__useEffect);
|
|
7995
|
+
}
|
|
7990
7996
|
__setPaint(attrName, value) {
|
|
7991
7997
|
this.__setInput(attrName, value);
|
|
7992
7998
|
const layout = this.__leaf.__layout;
|
|
@@ -8065,7 +8071,11 @@ class EllipseData extends UIData {
|
|
|
8065
8071
|
}
|
|
8066
8072
|
}
|
|
8067
8073
|
|
|
8068
|
-
class PolygonData extends
|
|
8074
|
+
class PolygonData extends UIData {
|
|
8075
|
+
get __usePathBox() {
|
|
8076
|
+
return this.points || this.__pathInputed;
|
|
8077
|
+
}
|
|
8078
|
+
}
|
|
8069
8079
|
|
|
8070
8080
|
class StarData extends UIData {
|
|
8071
8081
|
get __boxStroke() {
|
|
@@ -8176,7 +8186,7 @@ const UIBounds = {
|
|
|
8176
8186
|
if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
|
|
8177
8187
|
boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
|
|
8178
8188
|
if (!data.__boxStroke || data.__useArrow) {
|
|
8179
|
-
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
|
|
8189
|
+
const miterLimitAddWidth = data.__isLinePath ? 0 : (data.strokeJoin === "miter" ? 10 : 1) * spread;
|
|
8180
8190
|
const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
|
|
8181
8191
|
spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
|
|
8182
8192
|
}
|
|
@@ -8221,7 +8231,7 @@ const UIRender = {
|
|
|
8221
8231
|
data.__useEffect = !!(shadow || otherEffect);
|
|
8222
8232
|
}
|
|
8223
8233
|
data.__checkSingle();
|
|
8224
|
-
|
|
8234
|
+
data.__checkComplex();
|
|
8225
8235
|
},
|
|
8226
8236
|
__drawFast(canvas, options) {
|
|
8227
8237
|
drawFast(this, canvas, options);
|
|
@@ -9480,7 +9490,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9480
9490
|
|
|
9481
9491
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9482
9492
|
|
|
9483
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes,
|
|
9493
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9484
9494
|
|
|
9485
9495
|
let Text = class Text extends UI {
|
|
9486
9496
|
get __tag() {
|
|
@@ -9508,9 +9518,10 @@ let Text = class Text extends UI {
|
|
|
9508
9518
|
const {fontSize: fontSize, italic: italic, padding: padding, __autoWidth: autoWidth, __autoHeight: autoHeight} = data;
|
|
9509
9519
|
this.__updateTextDrawData();
|
|
9510
9520
|
const {bounds: contentBounds} = data.__textDrawData;
|
|
9521
|
+
console.log(contentBounds);
|
|
9511
9522
|
const b = layout.boxBounds;
|
|
9512
9523
|
layout.contentBounds = contentBounds;
|
|
9513
|
-
if (data.__lineHeight < fontSize)
|
|
9524
|
+
if (data.__lineHeight < fontSize) layout.renderChanged = true;
|
|
9514
9525
|
if (autoWidth || autoHeight) {
|
|
9515
9526
|
b.x = autoWidth ? contentBounds.x : 0;
|
|
9516
9527
|
b.y = autoHeight ? contentBounds.y : 0;
|
|
@@ -9530,6 +9541,8 @@ let Text = class Text extends UI {
|
|
|
9530
9541
|
__updateRenderSpread() {
|
|
9531
9542
|
let spread = super.__updateRenderSpread();
|
|
9532
9543
|
if (!spread) spread = this.isOverflow ? 1 : 0;
|
|
9544
|
+
const {__lineHeight: __lineHeight, fontSize: fontSize} = this.__;
|
|
9545
|
+
if (__lineHeight < fontSize) spread = FourNumberHelper.max(spread, (fontSize - __lineHeight) / 2);
|
|
9533
9546
|
return spread;
|
|
9534
9547
|
}
|
|
9535
9548
|
__updateRenderBounds() {
|
|
@@ -9987,8 +10000,8 @@ function compute(attrName, ui) {
|
|
|
9987
10000
|
}
|
|
9988
10001
|
}
|
|
9989
10002
|
}
|
|
9990
|
-
data["_" + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
9991
10003
|
if (leafPaints.length) {
|
|
10004
|
+
data["_" + attrName] = leafPaints;
|
|
9992
10005
|
if (leafPaints.every(item => item.isTransparent)) {
|
|
9993
10006
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
9994
10007
|
isTransparent = true;
|
|
@@ -10003,6 +10016,7 @@ function compute(attrName, ui) {
|
|
|
10003
10016
|
}
|
|
10004
10017
|
} else {
|
|
10005
10018
|
data.__removePaint(attrName, false);
|
|
10019
|
+
data["_" + attrName] = "";
|
|
10006
10020
|
}
|
|
10007
10021
|
}
|
|
10008
10022
|
|
|
@@ -10152,11 +10166,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
10152
10166
|
needUpdate = false;
|
|
10153
10167
|
}
|
|
10154
10168
|
}
|
|
10169
|
+
if (paint.mode === "brush") PaintImage.brush(leafPaint);
|
|
10155
10170
|
if (!leafPaint.data) {
|
|
10156
10171
|
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
10157
|
-
const {transform: transform} = leafPaint.data, {opacity: opacity
|
|
10158
|
-
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
10159
|
-
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
10172
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity} = paint;
|
|
10173
|
+
const clip = (transform && !transform.onlyScale || data.path || data.cornerRadius) && !leafPaint.brush;
|
|
10174
|
+
if (clip || opacity && opacity < 1 || paint.blendMode) leafPaint.complex = clip ? 2 : true;
|
|
10160
10175
|
}
|
|
10161
10176
|
if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
|
|
10162
10177
|
return needUpdate;
|
|
@@ -10246,6 +10261,7 @@ function getPatternData(paint, box, image) {
|
|
|
10246
10261
|
break;
|
|
10247
10262
|
|
|
10248
10263
|
case "repeat":
|
|
10264
|
+
case "brush":
|
|
10249
10265
|
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
10250
10266
|
if (!repeat) data.repeat = "repeat";
|
|
10251
10267
|
const count = isObject(repeat);
|
|
@@ -10386,7 +10402,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
10386
10402
|
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
10387
10403
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
10388
10404
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
10389
|
-
const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10405
|
+
const {image: image, brush: brush, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10390
10406
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
10391
10407
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
10392
10408
|
width *= scaleX;
|
|
@@ -10394,6 +10410,10 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
10394
10410
|
if (gap) {
|
|
10395
10411
|
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
10396
10412
|
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
10413
|
+
if (brush) {
|
|
10414
|
+
const brushScale = PaintImage.getBrushScale(paint, ui);
|
|
10415
|
+
xGap /= brushScale, yGap /= brushScale;
|
|
10416
|
+
}
|
|
10397
10417
|
}
|
|
10398
10418
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10399
10419
|
scaleX *= getFloorScale(width + (xGap || 0));
|
|
@@ -10403,7 +10423,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
10403
10423
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10404
10424
|
}
|
|
10405
10425
|
const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
10406
|
-
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10426
|
+
const pattern = brush ? imageCanvas : image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10407
10427
|
paint.style = pattern;
|
|
10408
10428
|
paint.patternId = id;
|
|
10409
10429
|
}
|
|
@@ -10424,9 +10444,9 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
10424
10444
|
|
|
10425
10445
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
10426
10446
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
10427
|
-
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
10447
|
+
const {image: image, brush: brush, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
10428
10448
|
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
10429
|
-
return false;
|
|
10449
|
+
if (!(brush && paint.style)) return false;
|
|
10430
10450
|
} else {
|
|
10431
10451
|
if (drawImage) {
|
|
10432
10452
|
if (data.repeat) {
|
|
@@ -10440,18 +10460,18 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
10440
10460
|
canvas.fillStyle = paint.style || "#000";
|
|
10441
10461
|
canvas.fill();
|
|
10442
10462
|
}
|
|
10443
|
-
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10444
|
-
return true;
|
|
10445
10463
|
} else {
|
|
10446
10464
|
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
10447
|
-
return false;
|
|
10465
|
+
if (!(brush && paint.style)) return false;
|
|
10448
10466
|
}
|
|
10449
10467
|
}
|
|
10468
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10469
|
+
return true;
|
|
10450
10470
|
}
|
|
10451
10471
|
|
|
10452
10472
|
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
10453
|
-
const {data: data, image: image, complex: complex} = paint;
|
|
10454
|
-
let {width: width, height: height} = image;
|
|
10473
|
+
const {data: data, image: image, brush: brush, complex: complex} = paint;
|
|
10474
|
+
let {width: width, height: height} = image, view = brush || image;
|
|
10455
10475
|
if (complex) {
|
|
10456
10476
|
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
10457
10477
|
canvas.save();
|
|
@@ -10459,16 +10479,17 @@ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions)
|
|
|
10459
10479
|
blendMode && (canvas.blendMode = blendMode);
|
|
10460
10480
|
opacity && (canvas.opacity *= opacity);
|
|
10461
10481
|
transform && canvas.transform(transform);
|
|
10462
|
-
|
|
10482
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
10463
10483
|
canvas.restore();
|
|
10464
10484
|
} else {
|
|
10465
10485
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
10466
|
-
|
|
10486
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
10467
10487
|
}
|
|
10468
10488
|
}
|
|
10469
10489
|
|
|
10470
10490
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
10471
10491
|
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
10492
|
+
if (paint.brush) PaintImage.addBrushScale(scaleData, paint, ui);
|
|
10472
10493
|
if (canvas) {
|
|
10473
10494
|
const {pixelRatio: pixelRatio} = canvas;
|
|
10474
10495
|
scaleData.scaleX *= pixelRatio;
|
|
@@ -10485,6 +10506,7 @@ function recycleImage(attrName, data) {
|
|
|
10485
10506
|
const paints = data["_" + attrName];
|
|
10486
10507
|
if (isArray(paints)) {
|
|
10487
10508
|
let paint, image, recycleMap, input, url;
|
|
10509
|
+
const ui = data.__leaf;
|
|
10488
10510
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
10489
10511
|
paint = paints[i];
|
|
10490
10512
|
image = paint.image;
|
|
@@ -10493,7 +10515,8 @@ function recycleImage(attrName, data) {
|
|
|
10493
10515
|
if (!recycleMap) recycleMap = {};
|
|
10494
10516
|
recycleMap[url] = true;
|
|
10495
10517
|
ImageManager.recyclePaint(paint);
|
|
10496
|
-
if (
|
|
10518
|
+
if (paint.brush) PaintImage.recycleBrush(paint, ui);
|
|
10519
|
+
if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, ui);
|
|
10497
10520
|
if (image.loading) {
|
|
10498
10521
|
if (!input) {
|
|
10499
10522
|
input = data.__input && data.__input[attrName] || [];
|