@leafer-draw/miniapp 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/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 +51 -28
- 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.
|
|
7084
|
+
const version = "2.1.1";
|
|
7083
7085
|
|
|
7084
7086
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
7085
7087
|
get allowBackgroundColor() {
|
|
@@ -8044,8 +8046,8 @@ class UIData extends LeafData {
|
|
|
8044
8046
|
return this.__getRealStrokeWidth();
|
|
8045
8047
|
}
|
|
8046
8048
|
get __maxStrokeWidth() {
|
|
8047
|
-
const t = this;
|
|
8048
|
-
return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle,
|
|
8049
|
+
const t = this, strokeWidth = t.__hasStrokeSides || t.strokeWidth;
|
|
8050
|
+
return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, strokeWidth) : strokeWidth;
|
|
8049
8051
|
}
|
|
8050
8052
|
get __hasMultiPaint() {
|
|
8051
8053
|
const t = this;
|
|
@@ -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;
|
|
@@ -8146,6 +8148,10 @@ class UIData extends LeafData {
|
|
|
8146
8148
|
}
|
|
8147
8149
|
return strokeWidth;
|
|
8148
8150
|
}
|
|
8151
|
+
__checkComplex() {
|
|
8152
|
+
const t = this;
|
|
8153
|
+
stintSet$3(t, "__complex", t.__isFills || t.__isStrokes || t.cornerRadius || t.__useEffect);
|
|
8154
|
+
}
|
|
8149
8155
|
__setPaint(attrName, value) {
|
|
8150
8156
|
this.__setInput(attrName, value);
|
|
8151
8157
|
const layout = this.__leaf.__layout;
|
|
@@ -8224,7 +8230,11 @@ class EllipseData extends UIData {
|
|
|
8224
8230
|
}
|
|
8225
8231
|
}
|
|
8226
8232
|
|
|
8227
|
-
class PolygonData extends
|
|
8233
|
+
class PolygonData extends UIData {
|
|
8234
|
+
get __usePathBox() {
|
|
8235
|
+
return this.points || this.__pathInputed;
|
|
8236
|
+
}
|
|
8237
|
+
}
|
|
8228
8238
|
|
|
8229
8239
|
class StarData extends UIData {
|
|
8230
8240
|
get __boxStroke() {
|
|
@@ -8335,7 +8345,7 @@ const UIBounds = {
|
|
|
8335
8345
|
if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
|
|
8336
8346
|
boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
|
|
8337
8347
|
if (!data.__boxStroke || data.__useArrow) {
|
|
8338
|
-
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
|
|
8348
|
+
const miterLimitAddWidth = data.__isLinePath ? 0 : (data.strokeJoin === "miter" ? 10 : 1) * spread;
|
|
8339
8349
|
const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
|
|
8340
8350
|
spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
|
|
8341
8351
|
}
|
|
@@ -8380,7 +8390,7 @@ const UIRender = {
|
|
|
8380
8390
|
data.__useEffect = !!(shadow || otherEffect);
|
|
8381
8391
|
}
|
|
8382
8392
|
data.__checkSingle();
|
|
8383
|
-
|
|
8393
|
+
data.__checkComplex();
|
|
8384
8394
|
},
|
|
8385
8395
|
__drawFast(canvas, options) {
|
|
8386
8396
|
drawFast(this, canvas, options);
|
|
@@ -9639,7 +9649,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9639
9649
|
|
|
9640
9650
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9641
9651
|
|
|
9642
|
-
const {copyAndSpread: copyAndSpread$1, includes: includes,
|
|
9652
|
+
const {copyAndSpread: copyAndSpread$1, includes: includes, setList: setList} = BoundsHelper, {stintSet: stintSet$1} = DataHelper;
|
|
9643
9653
|
|
|
9644
9654
|
let Text = class Text extends UI {
|
|
9645
9655
|
get __tag() {
|
|
@@ -9667,9 +9677,10 @@ let Text = class Text extends UI {
|
|
|
9667
9677
|
const {fontSize: fontSize, italic: italic, padding: padding, __autoWidth: autoWidth, __autoHeight: autoHeight} = data;
|
|
9668
9678
|
this.__updateTextDrawData();
|
|
9669
9679
|
const {bounds: contentBounds} = data.__textDrawData;
|
|
9680
|
+
console.log(contentBounds);
|
|
9670
9681
|
const b = layout.boxBounds;
|
|
9671
9682
|
layout.contentBounds = contentBounds;
|
|
9672
|
-
if (data.__lineHeight < fontSize)
|
|
9683
|
+
if (data.__lineHeight < fontSize) layout.renderChanged = true;
|
|
9673
9684
|
if (autoWidth || autoHeight) {
|
|
9674
9685
|
b.x = autoWidth ? contentBounds.x : 0;
|
|
9675
9686
|
b.y = autoHeight ? contentBounds.y : 0;
|
|
@@ -9689,6 +9700,8 @@ let Text = class Text extends UI {
|
|
|
9689
9700
|
__updateRenderSpread() {
|
|
9690
9701
|
let spread = super.__updateRenderSpread();
|
|
9691
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);
|
|
9692
9705
|
return spread;
|
|
9693
9706
|
}
|
|
9694
9707
|
__updateRenderBounds() {
|
|
@@ -10146,8 +10159,8 @@ function compute(attrName, ui) {
|
|
|
10146
10159
|
}
|
|
10147
10160
|
}
|
|
10148
10161
|
}
|
|
10149
|
-
data["_" + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
10150
10162
|
if (leafPaints.length) {
|
|
10163
|
+
data["_" + attrName] = leafPaints;
|
|
10151
10164
|
if (leafPaints.every(item => item.isTransparent)) {
|
|
10152
10165
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
10153
10166
|
isTransparent = true;
|
|
@@ -10162,6 +10175,7 @@ function compute(attrName, ui) {
|
|
|
10162
10175
|
}
|
|
10163
10176
|
} else {
|
|
10164
10177
|
data.__removePaint(attrName, false);
|
|
10178
|
+
data["_" + attrName] = "";
|
|
10165
10179
|
}
|
|
10166
10180
|
}
|
|
10167
10181
|
|
|
@@ -10311,11 +10325,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
10311
10325
|
needUpdate = false;
|
|
10312
10326
|
}
|
|
10313
10327
|
}
|
|
10328
|
+
if (paint.mode === "brush") PaintImage.brush(leafPaint);
|
|
10314
10329
|
if (!leafPaint.data) {
|
|
10315
10330
|
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
10316
|
-
const {transform: transform} = leafPaint.data, {opacity: opacity
|
|
10317
|
-
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
10318
|
-
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;
|
|
10319
10334
|
}
|
|
10320
10335
|
if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
|
|
10321
10336
|
return needUpdate;
|
|
@@ -10405,6 +10420,7 @@ function getPatternData(paint, box, image) {
|
|
|
10405
10420
|
break;
|
|
10406
10421
|
|
|
10407
10422
|
case "repeat":
|
|
10423
|
+
case "brush":
|
|
10408
10424
|
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
10409
10425
|
if (!repeat) data.repeat = "repeat";
|
|
10410
10426
|
const count = isObject(repeat);
|
|
@@ -10545,7 +10561,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
10545
10561
|
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
10546
10562
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
10547
10563
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
10548
|
-
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);
|
|
10549
10565
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
10550
10566
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
10551
10567
|
width *= scaleX;
|
|
@@ -10553,6 +10569,10 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
10553
10569
|
if (gap) {
|
|
10554
10570
|
xGap = gap.x * scaleX / abs$1(data.scaleX || 1);
|
|
10555
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
|
+
}
|
|
10556
10576
|
}
|
|
10557
10577
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
10558
10578
|
scaleX *= getFloorScale(width + (xGap || 0));
|
|
@@ -10562,7 +10582,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
10562
10582
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
10563
10583
|
}
|
|
10564
10584
|
const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
10565
|
-
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);
|
|
10566
10586
|
paint.style = pattern;
|
|
10567
10587
|
paint.patternId = id;
|
|
10568
10588
|
}
|
|
@@ -10583,9 +10603,9 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
10583
10603
|
|
|
10584
10604
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
10585
10605
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
10586
|
-
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;
|
|
10587
10607
|
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
10588
|
-
return false;
|
|
10608
|
+
if (!(brush && paint.style)) return false;
|
|
10589
10609
|
} else {
|
|
10590
10610
|
if (drawImage) {
|
|
10591
10611
|
if (data.repeat) {
|
|
@@ -10599,18 +10619,18 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
10599
10619
|
canvas.fillStyle = paint.style || "#000";
|
|
10600
10620
|
canvas.fill();
|
|
10601
10621
|
}
|
|
10602
|
-
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10603
|
-
return true;
|
|
10604
10622
|
} else {
|
|
10605
10623
|
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
10606
|
-
return false;
|
|
10624
|
+
if (!(brush && paint.style)) return false;
|
|
10607
10625
|
}
|
|
10608
10626
|
}
|
|
10627
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
10628
|
+
return true;
|
|
10609
10629
|
}
|
|
10610
10630
|
|
|
10611
10631
|
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
10612
|
-
const {data: data, image: image, complex: complex} = paint;
|
|
10613
|
-
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;
|
|
10614
10634
|
if (complex) {
|
|
10615
10635
|
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
10616
10636
|
canvas.save();
|
|
@@ -10618,16 +10638,17 @@ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions)
|
|
|
10618
10638
|
blendMode && (canvas.blendMode = blendMode);
|
|
10619
10639
|
opacity && (canvas.opacity *= opacity);
|
|
10620
10640
|
transform && canvas.transform(transform);
|
|
10621
|
-
|
|
10641
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
10622
10642
|
canvas.restore();
|
|
10623
10643
|
} else {
|
|
10624
10644
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
10625
|
-
|
|
10645
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
10626
10646
|
}
|
|
10627
10647
|
}
|
|
10628
10648
|
|
|
10629
10649
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
10630
10650
|
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
10651
|
+
if (paint.brush) PaintImage.addBrushScale(scaleData, paint, ui);
|
|
10631
10652
|
if (canvas) {
|
|
10632
10653
|
const {pixelRatio: pixelRatio} = canvas;
|
|
10633
10654
|
scaleData.scaleX *= pixelRatio;
|
|
@@ -10644,6 +10665,7 @@ function recycleImage(attrName, data) {
|
|
|
10644
10665
|
const paints = data["_" + attrName];
|
|
10645
10666
|
if (isArray(paints)) {
|
|
10646
10667
|
let paint, image, recycleMap, input, url;
|
|
10668
|
+
const ui = data.__leaf;
|
|
10647
10669
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
10648
10670
|
paint = paints[i];
|
|
10649
10671
|
image = paint.image;
|
|
@@ -10652,7 +10674,8 @@ function recycleImage(attrName, data) {
|
|
|
10652
10674
|
if (!recycleMap) recycleMap = {};
|
|
10653
10675
|
recycleMap[url] = true;
|
|
10654
10676
|
ImageManager.recyclePaint(paint);
|
|
10655
|
-
if (
|
|
10677
|
+
if (paint.brush) PaintImage.recycleBrush(paint, ui);
|
|
10678
|
+
if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, ui);
|
|
10656
10679
|
if (image.loading) {
|
|
10657
10680
|
if (!input) {
|
|
10658
10681
|
input = data.__input && data.__input[attrName] || [];
|