@leafer-draw/miniapp 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/miniapp.cjs +26 -16
- package/dist/miniapp.esm.js +26 -16
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +47 -26
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +7 -7
package/dist/miniapp.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$4:
|
|
3083
3083
|
x = old[i + 1];
|
|
3084
3084
|
y = old[i + 2];
|
|
3085
|
-
data.push(M$4, x, y)
|
|
3085
|
+
if (lastCommand === command) data.push(L$5, x, y); else data.push(M$4, 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$4:
|
|
3199
3200
|
data.push(Z$4);
|
|
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() {
|
|
@@ -8113,7 +8118,7 @@ class UIData extends LeafData {
|
|
|
8113
8118
|
const isStr = isString(value);
|
|
8114
8119
|
if (isStr || value && isObject(value[0])) {
|
|
8115
8120
|
this.__setInput("path", value);
|
|
8116
|
-
this._path = isStr ? parse(value) : objectToCanvasData(value);
|
|
8121
|
+
this._path = isStr ? parse(value, this.__useArrow) : objectToCanvasData(value);
|
|
8117
8122
|
} else {
|
|
8118
8123
|
if (this.__input) this.__removeInput("path");
|
|
8119
8124
|
this._path = value;
|
|
@@ -8228,7 +8233,11 @@ class EllipseData extends UIData {
|
|
|
8228
8233
|
}
|
|
8229
8234
|
}
|
|
8230
8235
|
|
|
8231
|
-
class PolygonData extends
|
|
8236
|
+
class PolygonData extends UIData {
|
|
8237
|
+
get __usePathBox() {
|
|
8238
|
+
return this.points || this.__pathInputed;
|
|
8239
|
+
}
|
|
8240
|
+
}
|
|
8232
8241
|
|
|
8233
8242
|
class StarData extends UIData {
|
|
8234
8243
|
get __boxStroke() {
|
|
@@ -8339,7 +8348,7 @@ const UIBounds = {
|
|
|
8339
8348
|
if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
|
|
8340
8349
|
boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
|
|
8341
8350
|
if (!data.__boxStroke || data.__useArrow) {
|
|
8342
|
-
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
|
|
8351
|
+
const miterLimitAddWidth = data.__isLinePath ? 0 : (data.strokeJoin === "miter" ? 10 : 1) * spread;
|
|
8343
8352
|
const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
|
|
8344
8353
|
spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
|
|
8345
8354
|
}
|
|
@@ -9643,7 +9652,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9643
9652
|
|
|
9644
9653
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9645
9654
|
|
|
9646
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes,
|
|
9655
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9647
9656
|
|
|
9648
9657
|
let Text = class Text extends UI {
|
|
9649
9658
|
get __tag() {
|
|
@@ -9673,7 +9682,7 @@ let Text = class Text extends UI {
|
|
|
9673
9682
|
const {bounds: contentBounds} = data.__textDrawData;
|
|
9674
9683
|
const b = layout.boxBounds;
|
|
9675
9684
|
layout.contentBounds = contentBounds;
|
|
9676
|
-
if (data.__lineHeight < fontSize)
|
|
9685
|
+
if (data.__lineHeight < fontSize) layout.renderChanged = true;
|
|
9677
9686
|
if (autoWidth || autoHeight) {
|
|
9678
9687
|
b.x = autoWidth ? contentBounds.x : 0;
|
|
9679
9688
|
b.y = autoHeight ? contentBounds.y : 0;
|
|
@@ -9693,6 +9702,8 @@ let Text = class Text extends UI {
|
|
|
9693
9702
|
__updateRenderSpread() {
|
|
9694
9703
|
let spread = super.__updateRenderSpread();
|
|
9695
9704
|
if (!spread) spread = this.isOverflow ? 1 : 0;
|
|
9705
|
+
const {__lineHeight: __lineHeight, fontSize: fontSize} = this.__;
|
|
9706
|
+
if (__lineHeight < fontSize) spread = FourNumberHelper.max(spread, (fontSize - __lineHeight) / 2);
|
|
9696
9707
|
return spread;
|
|
9697
9708
|
}
|
|
9698
9709
|
__updateRenderBounds() {
|
|
@@ -10150,8 +10161,8 @@ function compute(attrName, ui) {
|
|
|
10150
10161
|
}
|
|
10151
10162
|
}
|
|
10152
10163
|
}
|
|
10153
|
-
data["_" + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
10154
10164
|
if (leafPaints.length) {
|
|
10165
|
+
data["_" + attrName] = leafPaints;
|
|
10155
10166
|
if (leafPaints.every(item => item.isTransparent)) {
|
|
10156
10167
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
10157
10168
|
isTransparent = true;
|
|
@@ -10166,6 +10177,7 @@ function compute(attrName, ui) {
|
|
|
10166
10177
|
}
|
|
10167
10178
|
} else {
|
|
10168
10179
|
data.__removePaint(attrName, false);
|
|
10180
|
+
data["_" + attrName] = "";
|
|
10169
10181
|
}
|
|
10170
10182
|
}
|
|
10171
10183
|
|
|
@@ -10315,11 +10327,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
10315
10327
|
needUpdate = false;
|
|
10316
10328
|
}
|
|
10317
10329
|
}
|
|
10330
|
+
if (paint.mode === "brush") PaintImage.brush(leafPaint);
|
|
10318
10331
|
if (!leafPaint.data) {
|
|
10319
10332
|
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
10320
|
-
const {transform: transform} = leafPaint.data, {opacity: opacity
|
|
10321
|
-
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
10322
|
-
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
10333
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity} = paint;
|
|
10334
|
+
const clip = (transform && !transform.onlyScale || data.path || data.cornerRadius) && !leafPaint.brush;
|
|
10335
|
+
if (clip || opacity && opacity < 1 || paint.blendMode) leafPaint.complex = clip ? 2 : true;
|
|
10323
10336
|
}
|
|
10324
10337
|
if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
|
|
10325
10338
|
return needUpdate;
|
|
@@ -10409,6 +10422,7 @@ function getPatternData(paint, box, image) {
|
|
|
10409
10422
|
break;
|
|
10410
10423
|
|
|
10411
10424
|
case "repeat":
|
|
10425
|
+
case "brush":
|
|
10412
10426
|
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
10413
10427
|
if (!repeat) data.repeat = "repeat";
|
|
10414
10428
|
const count = isObject(repeat);
|
|
@@ -10549,7 +10563,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
10549
10563
|
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
10550
10564
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
10551
10565
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
10552
|
-
const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10566
|
+
const {image: image, brush: brush, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
10553
10567
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
10554
10568
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
10555
10569
|
width *= scaleX;
|
|
@@ -10557,6 +10571,10 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
10557
10571
|
if (gap) {
|
|
10558
10572
|
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
10559
10573
|
yGap = gap.y * scaleY / abs$1(data.scaleY || 1);
|
|
10574
|
+
if (brush) {
|
|
10575
|
+
const brushScale = PaintImage.getBrushScale(paint, ui);
|
|
10576
|
+
xGap /= brushScale, yGap /= brushScale;
|
|
10577
|
+
}
|
|
10560
10578
|
}
|
|
10561
10579
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10562
10580
|
scaleX *= getFloorScale(width + (xGap || 0));
|
|
@@ -10566,7 +10584,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
10566
10584
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10567
10585
|
}
|
|
10568
10586
|
const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
10569
|
-
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10587
|
+
const pattern = brush ? imageCanvas : image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
10570
10588
|
paint.style = pattern;
|
|
10571
10589
|
paint.patternId = id;
|
|
10572
10590
|
}
|
|
@@ -10587,9 +10605,9 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
10587
10605
|
|
|
10588
10606
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
10589
10607
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
10590
|
-
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
10608
|
+
const {image: image, brush: brush, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
10591
10609
|
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
10592
|
-
return false;
|
|
10610
|
+
if (!(brush && paint.style)) return false;
|
|
10593
10611
|
} else {
|
|
10594
10612
|
if (drawImage) {
|
|
10595
10613
|
if (data.repeat) {
|
|
@@ -10603,18 +10621,18 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
10603
10621
|
canvas.fillStyle = paint.style || "#000";
|
|
10604
10622
|
canvas.fill();
|
|
10605
10623
|
}
|
|
10606
|
-
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10607
|
-
return true;
|
|
10608
10624
|
} else {
|
|
10609
10625
|
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
10610
|
-
return false;
|
|
10626
|
+
if (!(brush && paint.style)) return false;
|
|
10611
10627
|
}
|
|
10612
10628
|
}
|
|
10629
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10630
|
+
return true;
|
|
10613
10631
|
}
|
|
10614
10632
|
|
|
10615
10633
|
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
10616
|
-
const {data: data, image: image, complex: complex} = paint;
|
|
10617
|
-
let {width: width, height: height} = image;
|
|
10634
|
+
const {data: data, image: image, brush: brush, complex: complex} = paint;
|
|
10635
|
+
let {width: width, height: height} = image, view = brush || image;
|
|
10618
10636
|
if (complex) {
|
|
10619
10637
|
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
10620
10638
|
canvas.save();
|
|
@@ -10622,16 +10640,17 @@ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions)
|
|
|
10622
10640
|
blendMode && (canvas.blendMode = blendMode);
|
|
10623
10641
|
opacity && (canvas.opacity *= opacity);
|
|
10624
10642
|
transform && canvas.transform(transform);
|
|
10625
|
-
|
|
10643
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
10626
10644
|
canvas.restore();
|
|
10627
10645
|
} else {
|
|
10628
10646
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
10629
|
-
|
|
10647
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
10630
10648
|
}
|
|
10631
10649
|
}
|
|
10632
10650
|
|
|
10633
10651
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
10634
10652
|
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
10653
|
+
if (paint.brush) PaintImage.addBrushScale(scaleData, paint, ui);
|
|
10635
10654
|
if (canvas) {
|
|
10636
10655
|
const {pixelRatio: pixelRatio} = canvas;
|
|
10637
10656
|
scaleData.scaleX *= pixelRatio;
|
|
@@ -10648,6 +10667,7 @@ function recycleImage(attrName, data) {
|
|
|
10648
10667
|
const paints = data["_" + attrName];
|
|
10649
10668
|
if (isArray(paints)) {
|
|
10650
10669
|
let paint, image, recycleMap, input, url;
|
|
10670
|
+
const ui = data.__leaf;
|
|
10651
10671
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
10652
10672
|
paint = paints[i];
|
|
10653
10673
|
image = paint.image;
|
|
@@ -10656,7 +10676,8 @@ function recycleImage(attrName, data) {
|
|
|
10656
10676
|
if (!recycleMap) recycleMap = {};
|
|
10657
10677
|
recycleMap[url] = true;
|
|
10658
10678
|
ImageManager.recyclePaint(paint);
|
|
10659
|
-
if (
|
|
10679
|
+
if (paint.brush) PaintImage.recycleBrush(paint, ui);
|
|
10680
|
+
if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, ui);
|
|
10660
10681
|
if (image.loading) {
|
|
10661
10682
|
if (!input) {
|
|
10662
10683
|
input = data.__input && data.__input[attrName] || [];
|