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