leafer-draw 1.9.5 → 1.9.7
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/web.cjs +26 -6
- package/dist/web.esm.js +27 -7
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +172 -102
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +189 -116
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +3 -3
package/dist/web.js
CHANGED
|
@@ -344,7 +344,7 @@ var LeaferUI = function(exports) {
|
|
|
344
344
|
};
|
|
345
345
|
}
|
|
346
346
|
const {sin: sin$5, cos: cos$5, acos: acos, sqrt: sqrt$3} = Math;
|
|
347
|
-
const {float: float$
|
|
347
|
+
const {float: float$2} = MathHelper;
|
|
348
348
|
const tempPoint$3 = {};
|
|
349
349
|
function getWorld() {
|
|
350
350
|
return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), {
|
|
@@ -392,6 +392,15 @@ var LeaferUI = function(exports) {
|
|
|
392
392
|
t.c *= scaleY;
|
|
393
393
|
t.d *= scaleY;
|
|
394
394
|
},
|
|
395
|
+
pixelScale(t, pixelRatio, to) {
|
|
396
|
+
to || (to = t);
|
|
397
|
+
to.a = t.a * pixelRatio;
|
|
398
|
+
to.b = t.b * pixelRatio;
|
|
399
|
+
to.c = t.c * pixelRatio;
|
|
400
|
+
to.d = t.d * pixelRatio;
|
|
401
|
+
to.e = t.e * pixelRatio;
|
|
402
|
+
to.f = t.f * pixelRatio;
|
|
403
|
+
},
|
|
395
404
|
scaleOfOuter(t, origin, scaleX, scaleY) {
|
|
396
405
|
M$6.toInnerPoint(t, origin, tempPoint$3);
|
|
397
406
|
M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
|
|
@@ -583,12 +592,12 @@ var LeaferUI = function(exports) {
|
|
|
583
592
|
const cosR = c / scaleY;
|
|
584
593
|
rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
|
|
585
594
|
}
|
|
586
|
-
const cosR = float$
|
|
595
|
+
const cosR = float$2(cos$5(rotation));
|
|
587
596
|
const sinR = sin$5(rotation);
|
|
588
|
-
scaleX = float$
|
|
589
|
-
skewX = cosR ? float$
|
|
590
|
-
skewY = cosR ? float$
|
|
591
|
-
rotation = float$
|
|
597
|
+
scaleX = float$2(scaleX), scaleY = float$2(scaleY);
|
|
598
|
+
skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
|
|
599
|
+
skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
|
|
600
|
+
rotation = float$2(rotation / OneRadian);
|
|
592
601
|
} else {
|
|
593
602
|
scaleX = a;
|
|
594
603
|
scaleY = d;
|
|
@@ -882,6 +891,10 @@ var LeaferUI = function(exports) {
|
|
|
882
891
|
this.scaleY *= y || x;
|
|
883
892
|
return this;
|
|
884
893
|
}
|
|
894
|
+
pixelScale(pixelRatio) {
|
|
895
|
+
MatrixHelper.pixelScale(this, pixelRatio);
|
|
896
|
+
return this;
|
|
897
|
+
}
|
|
885
898
|
scaleOfOuter(origin, x, y) {
|
|
886
899
|
MatrixHelper.scaleOfOuter(this, origin, x, y);
|
|
887
900
|
return this;
|
|
@@ -1085,7 +1098,7 @@ var LeaferUI = function(exports) {
|
|
|
1085
1098
|
};
|
|
1086
1099
|
const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
|
|
1087
1100
|
const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
1088
|
-
const {float: float, fourNumber: fourNumber} = MathHelper;
|
|
1101
|
+
const {float: float$1, fourNumber: fourNumber} = MathHelper;
|
|
1089
1102
|
const {floor: floor$2, ceil: ceil$2} = Math;
|
|
1090
1103
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
1091
1104
|
const point = {};
|
|
@@ -1262,10 +1275,10 @@ var LeaferUI = function(exports) {
|
|
|
1262
1275
|
}
|
|
1263
1276
|
},
|
|
1264
1277
|
float(t, maxLength) {
|
|
1265
|
-
t.x = float(t.x, maxLength);
|
|
1266
|
-
t.y = float(t.y, maxLength);
|
|
1267
|
-
t.width = float(t.width, maxLength);
|
|
1268
|
-
t.height = float(t.height, maxLength);
|
|
1278
|
+
t.x = float$1(t.x, maxLength);
|
|
1279
|
+
t.y = float$1(t.y, maxLength);
|
|
1280
|
+
t.width = float$1(t.width, maxLength);
|
|
1281
|
+
t.height = float$1(t.height, maxLength);
|
|
1269
1282
|
},
|
|
1270
1283
|
add(t, bounds, isPoint) {
|
|
1271
1284
|
right$1 = t.x + t.width;
|
|
@@ -1991,7 +2004,7 @@ var LeaferUI = function(exports) {
|
|
|
1991
2004
|
__decorate([ contextMethod() ], Canvas.prototype, "fillText", null);
|
|
1992
2005
|
__decorate([ contextMethod() ], Canvas.prototype, "measureText", null);
|
|
1993
2006
|
__decorate([ contextMethod() ], Canvas.prototype, "strokeText", null);
|
|
1994
|
-
const {copy: copy$7, multiplyParent: multiplyParent$4} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
|
|
2007
|
+
const {copy: copy$7, multiplyParent: multiplyParent$4, pixelScale: pixelScale} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
|
|
1995
2008
|
const minSize = {
|
|
1996
2009
|
width: 1,
|
|
1997
2010
|
height: 1,
|
|
@@ -2089,12 +2102,7 @@ var LeaferUI = function(exports) {
|
|
|
2089
2102
|
setWorld(matrix, parentMatrix) {
|
|
2090
2103
|
const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
|
|
2091
2104
|
if (parentMatrix) multiplyParent$4(matrix, parentMatrix, w);
|
|
2092
|
-
|
|
2093
|
-
w.b = matrix.b * pixelRatio;
|
|
2094
|
-
w.c = matrix.c * pixelRatio;
|
|
2095
|
-
w.d = matrix.d * pixelRatio;
|
|
2096
|
-
w.e = matrix.e * pixelRatio;
|
|
2097
|
-
w.f = matrix.f * pixelRatio;
|
|
2105
|
+
pixelScale(matrix, pixelRatio, w);
|
|
2098
2106
|
if (pixelSnap) {
|
|
2099
2107
|
if (matrix.half && matrix.half * pixelRatio % 2) w.e = round$1(w.e - .5) + .5, w.f = round$1(w.f - .5) + .5; else w.e = round$1(w.e),
|
|
2100
2108
|
w.f = round$1(w.f);
|
|
@@ -4008,6 +4016,17 @@ var LeaferUI = function(exports) {
|
|
|
4008
4016
|
}
|
|
4009
4017
|
}));
|
|
4010
4018
|
}
|
|
4019
|
+
function dimType(defaultValue) {
|
|
4020
|
+
return decorateLeafAttr(defaultValue, key => attr({
|
|
4021
|
+
set(value) {
|
|
4022
|
+
if (this.__setAttr(key, value)) {
|
|
4023
|
+
const data = this.__;
|
|
4024
|
+
DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
|
|
4025
|
+
this.__layout.surfaceChange();
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
}));
|
|
4029
|
+
}
|
|
4011
4030
|
function opacityType(defaultValue) {
|
|
4012
4031
|
return decorateLeafAttr(defaultValue, key => attr({
|
|
4013
4032
|
set(value) {
|
|
@@ -4048,7 +4067,7 @@ var LeaferUI = function(exports) {
|
|
|
4048
4067
|
return decorateLeafAttr(defaultValue, key => attr({
|
|
4049
4068
|
set(value) {
|
|
4050
4069
|
if (this.__setAttr(key, value)) {
|
|
4051
|
-
this.__layout.
|
|
4070
|
+
this.__layout.surfaceChange();
|
|
4052
4071
|
this.waitParent(() => {
|
|
4053
4072
|
this.parent.__layout.childrenSortChange();
|
|
4054
4073
|
});
|
|
@@ -4082,7 +4101,7 @@ var LeaferUI = function(exports) {
|
|
|
4082
4101
|
set(value) {
|
|
4083
4102
|
if (this.__setAttr(key, value)) {
|
|
4084
4103
|
this.__layout.hitCanvasChanged = true;
|
|
4085
|
-
if (Debug.showBounds === "hit") this.__layout.
|
|
4104
|
+
if (Debug.showBounds === "hit") this.__layout.surfaceChange();
|
|
4086
4105
|
if (this.leafer) this.leafer.updateCursor();
|
|
4087
4106
|
}
|
|
4088
4107
|
}
|
|
@@ -5105,6 +5124,7 @@ var LeaferUI = function(exports) {
|
|
|
5105
5124
|
LeaferEvent.STOP = "leafer.stop";
|
|
5106
5125
|
LeaferEvent.RESTART = "leafer.restart";
|
|
5107
5126
|
LeaferEvent.END = "leafer.end";
|
|
5127
|
+
LeaferEvent.UPDATE_MODE = "leafer.update_mode";
|
|
5108
5128
|
LeaferEvent.TRANSFORM = "leafer.transform";
|
|
5109
5129
|
LeaferEvent.MOVE = "leafer.move";
|
|
5110
5130
|
LeaferEvent.SCALE = "leafer.scale";
|
|
@@ -5479,6 +5499,7 @@ var LeaferUI = function(exports) {
|
|
|
5479
5499
|
if (options.shape) return this.__renderShape(canvas, options);
|
|
5480
5500
|
if (this.__worldOpacity) {
|
|
5481
5501
|
const data = this.__;
|
|
5502
|
+
if (data.bright && !options.topRendering) return options.topList.add(this);
|
|
5482
5503
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5483
5504
|
canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
|
|
5484
5505
|
if (this.__.__single) {
|
|
@@ -5525,7 +5546,9 @@ var LeaferUI = function(exports) {
|
|
|
5525
5546
|
this.__nowWorld = this.__getNowWorld(options);
|
|
5526
5547
|
if (this.__worldOpacity) {
|
|
5527
5548
|
const data = this.__;
|
|
5528
|
-
if (data.
|
|
5549
|
+
if (data.__useDim) {
|
|
5550
|
+
if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
|
|
5551
|
+
}
|
|
5529
5552
|
if (data.__single && !this.isBranchLeaf) {
|
|
5530
5553
|
if (data.eraser === "path") return this.__renderEraser(canvas, options);
|
|
5531
5554
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
@@ -6350,7 +6373,7 @@ var LeaferUI = function(exports) {
|
|
|
6350
6373
|
this.levelMap = null;
|
|
6351
6374
|
}
|
|
6352
6375
|
}
|
|
6353
|
-
const version = "1.9.
|
|
6376
|
+
const version = "1.9.7";
|
|
6354
6377
|
const debug$4 = Debug.get("LeaferCanvas");
|
|
6355
6378
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6356
6379
|
set zIndex(zIndex) {
|
|
@@ -7083,7 +7106,7 @@ var LeaferUI = function(exports) {
|
|
|
7083
7106
|
};
|
|
7084
7107
|
if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
|
|
7085
7108
|
if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
|
|
7086
|
-
this.target
|
|
7109
|
+
Platform.render(this.target, canvas, options);
|
|
7087
7110
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
7088
7111
|
this.renderOptions = options;
|
|
7089
7112
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
@@ -7172,6 +7195,14 @@ var LeaferUI = function(exports) {
|
|
|
7172
7195
|
interaction: (_target, _canvas, _selector, _options) => undefined
|
|
7173
7196
|
});
|
|
7174
7197
|
Platform.layout = Layouter.fullLayout;
|
|
7198
|
+
Platform.render = function(target, canvas, options) {
|
|
7199
|
+
const topOptions = Object.assign(Object.assign({}, options), {
|
|
7200
|
+
topRendering: true
|
|
7201
|
+
});
|
|
7202
|
+
options.topList = new LeafList;
|
|
7203
|
+
target.__render(canvas, options);
|
|
7204
|
+
if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
|
|
7205
|
+
};
|
|
7175
7206
|
function effectType(defaultValue) {
|
|
7176
7207
|
return decorateLeafAttr(defaultValue, key => attr({
|
|
7177
7208
|
set(value) {
|
|
@@ -7490,8 +7521,6 @@ var LeaferUI = function(exports) {
|
|
|
7490
7521
|
if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
|
|
7491
7522
|
box.set(value);
|
|
7492
7523
|
if (boxLayout.strokeChanged) layout.strokeChange();
|
|
7493
|
-
if (boxLayout.renderChanged) layout.renderChange();
|
|
7494
|
-
box.__updateChange();
|
|
7495
7524
|
} else if (box) {
|
|
7496
7525
|
t.__box = box.parent = null;
|
|
7497
7526
|
box.destroy();
|
|
@@ -7558,7 +7587,7 @@ var LeaferUI = function(exports) {
|
|
|
7558
7587
|
__updateRenderSpread() {
|
|
7559
7588
|
let width = 0;
|
|
7560
7589
|
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
|
|
7561
|
-
if (shadow)
|
|
7590
|
+
if (shadow) width = Effect.getShadowSpread(this, shadow);
|
|
7562
7591
|
if (blur) width = Math.max(width, blur);
|
|
7563
7592
|
if (filter) width += Filter.getSpread(filter);
|
|
7564
7593
|
if (renderSpread) width += renderSpread;
|
|
@@ -7570,36 +7599,67 @@ var LeaferUI = function(exports) {
|
|
|
7570
7599
|
return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
|
|
7571
7600
|
}
|
|
7572
7601
|
};
|
|
7602
|
+
const {float: float} = MathHelper;
|
|
7603
|
+
const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
|
|
7573
7604
|
const DragBoundsHelper = {
|
|
7605
|
+
limitMove(leaf, move) {
|
|
7606
|
+
const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
|
|
7607
|
+
if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
|
|
7608
|
+
D.axisMove(leaf, move);
|
|
7609
|
+
},
|
|
7610
|
+
limitScaleOf(leaf, origin, scale) {
|
|
7611
|
+
const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
|
|
7612
|
+
if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
|
|
7613
|
+
},
|
|
7614
|
+
axisMove(leaf, move) {
|
|
7615
|
+
const {draggable: draggable} = leaf;
|
|
7616
|
+
if (draggable === "x") move.y = 0;
|
|
7617
|
+
if (draggable === "y") move.x = 0;
|
|
7618
|
+
},
|
|
7619
|
+
getDragBounds(leaf) {
|
|
7620
|
+
const {dragBounds: dragBounds} = leaf;
|
|
7621
|
+
return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
|
|
7622
|
+
},
|
|
7623
|
+
isInnerMode(content, dragBounds, dragBoundsType, sideType) {
|
|
7624
|
+
return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
|
|
7625
|
+
},
|
|
7574
7626
|
getValidMove(content, dragBounds, dragBoundsType, move, change) {
|
|
7575
7627
|
const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
|
|
7576
7628
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
7577
7629
|
if (!change) move = Object.assign({}, move);
|
|
7578
|
-
|
|
7579
|
-
const isBiggerHeight = content.height > dragBounds.height;
|
|
7580
|
-
if (isBiggerWidth && dragBoundsType !== "outer") {
|
|
7630
|
+
if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
|
|
7581
7631
|
if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
|
|
7582
7632
|
} else {
|
|
7583
7633
|
if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
|
|
7584
7634
|
}
|
|
7585
|
-
if (
|
|
7635
|
+
if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
|
|
7586
7636
|
if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
|
|
7587
7637
|
} else {
|
|
7588
7638
|
if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
|
|
7589
7639
|
}
|
|
7590
|
-
move.x =
|
|
7591
|
-
move.y =
|
|
7640
|
+
move.x = float(move.x);
|
|
7641
|
+
move.y = float(move.y);
|
|
7592
7642
|
return move;
|
|
7593
7643
|
},
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7644
|
+
getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
|
|
7645
|
+
if (!change) scale = Object.assign({}, scale);
|
|
7646
|
+
let fitScaleX, fitScaleY;
|
|
7647
|
+
tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
|
|
7648
|
+
tempMerge.set(tempContent).add(dragBounds);
|
|
7649
|
+
tempIntersect.set(tempContent).intersect(dragBounds);
|
|
7650
|
+
if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
|
|
7651
|
+
fitScaleX = tempMerge.width / tempContent.width;
|
|
7652
|
+
} else {
|
|
7653
|
+
fitScaleX = tempIntersect.width / tempContent.width;
|
|
7654
|
+
}
|
|
7655
|
+
if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
|
|
7656
|
+
fitScaleY = tempMerge.height / tempContent.height;
|
|
7657
|
+
} else {
|
|
7658
|
+
fitScaleY = tempIntersect.height / tempContent.height;
|
|
7659
|
+
}
|
|
7660
|
+
scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
|
|
7661
|
+
scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
|
|
7662
|
+
return scale;
|
|
7603
7663
|
}
|
|
7604
7664
|
};
|
|
7605
7665
|
const D = DragBoundsHelper;
|
|
@@ -7614,7 +7674,7 @@ var LeaferUI = function(exports) {
|
|
|
7614
7674
|
}
|
|
7615
7675
|
if (data.__useEffect) {
|
|
7616
7676
|
const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7617
|
-
stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
|
|
7677
|
+
stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !Effect.isTransformShadow(shadow[0]) && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
|
|
7618
7678
|
data.__useEffect = !!(shadow || otherEffect);
|
|
7619
7679
|
}
|
|
7620
7680
|
data.__checkSingle();
|
|
@@ -7860,8 +7920,8 @@ var LeaferUI = function(exports) {
|
|
|
7860
7920
|
__decorate([ opacityType(1) ], exports.UI.prototype, "opacity", void 0);
|
|
7861
7921
|
__decorate([ visibleType(true) ], exports.UI.prototype, "visible", void 0);
|
|
7862
7922
|
__decorate([ surfaceType(false) ], exports.UI.prototype, "locked", void 0);
|
|
7863
|
-
__decorate([
|
|
7864
|
-
__decorate([
|
|
7923
|
+
__decorate([ dimType(false) ], exports.UI.prototype, "dim", void 0);
|
|
7924
|
+
__decorate([ dimType(false) ], exports.UI.prototype, "dimskip", void 0);
|
|
7865
7925
|
__decorate([ sortType(0) ], exports.UI.prototype, "zIndex", void 0);
|
|
7866
7926
|
__decorate([ maskType(false) ], exports.UI.prototype, "mask", void 0);
|
|
7867
7927
|
__decorate([ eraserType(false) ], exports.UI.prototype, "eraser", void 0);
|
|
@@ -8166,7 +8226,9 @@ var LeaferUI = function(exports) {
|
|
|
8166
8226
|
} else if (attrName === "zIndex") {
|
|
8167
8227
|
this.canvas.zIndex = newValue;
|
|
8168
8228
|
setTimeout(() => this.parent && this.parent.__updateSortChildren());
|
|
8169
|
-
}
|
|
8229
|
+
} else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
|
|
8230
|
+
mode: newValue
|
|
8231
|
+
});
|
|
8170
8232
|
}
|
|
8171
8233
|
return super.__setAttr(attrName, newValue);
|
|
8172
8234
|
}
|
|
@@ -8345,6 +8407,7 @@ var LeaferUI = function(exports) {
|
|
|
8345
8407
|
exports.Leafer.list = new LeafList;
|
|
8346
8408
|
__decorate([ dataProcessor(LeaferData) ], exports.Leafer.prototype, "__", void 0);
|
|
8347
8409
|
__decorate([ boundsType() ], exports.Leafer.prototype, "pixelRatio", void 0);
|
|
8410
|
+
__decorate([ dataType("normal") ], exports.Leafer.prototype, "mode", void 0);
|
|
8348
8411
|
exports.Leafer = Leafer_1 = __decorate([ registerUI() ], exports.Leafer);
|
|
8349
8412
|
exports.Rect = class Rect extends exports.UI {
|
|
8350
8413
|
get __tag() {
|
|
@@ -8504,45 +8567,8 @@ var LeaferUI = function(exports) {
|
|
|
8504
8567
|
__decorate([ pathType(0) ], exports.Ellipse.prototype, "startAngle", void 0);
|
|
8505
8568
|
__decorate([ pathType(0) ], exports.Ellipse.prototype, "endAngle", void 0);
|
|
8506
8569
|
exports.Ellipse = __decorate([ registerUI() ], exports.Ellipse);
|
|
8507
|
-
const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
|
|
8508
|
-
const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
|
|
8509
|
-
exports.Line = class Line extends exports.UI {
|
|
8510
|
-
get __tag() {
|
|
8511
|
-
return "Line";
|
|
8512
|
-
}
|
|
8513
|
-
get toPoint() {
|
|
8514
|
-
const {width: width, rotation: rotation} = this.__;
|
|
8515
|
-
const to = getPointData();
|
|
8516
|
-
if (width) to.x = width;
|
|
8517
|
-
if (rotation) rotate$1(to, rotation);
|
|
8518
|
-
return to;
|
|
8519
|
-
}
|
|
8520
|
-
set toPoint(value) {
|
|
8521
|
-
this.width = getDistance$2(defaultPoint, value);
|
|
8522
|
-
this.rotation = getAngle$1(defaultPoint, value);
|
|
8523
|
-
if (this.height) this.height = 0;
|
|
8524
|
-
}
|
|
8525
|
-
__updatePath() {
|
|
8526
|
-
const data = this.__;
|
|
8527
|
-
const path = data.path = [];
|
|
8528
|
-
if (data.points) {
|
|
8529
|
-
drawPoints$1(path, data.points, data.curve, data.closed);
|
|
8530
|
-
} else {
|
|
8531
|
-
moveTo$2(path, 0, 0);
|
|
8532
|
-
lineTo$2(path, this.width, 0);
|
|
8533
|
-
}
|
|
8534
|
-
}
|
|
8535
|
-
};
|
|
8536
|
-
__decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
|
|
8537
|
-
__decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
|
|
8538
|
-
__decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
|
|
8539
|
-
__decorate([ pathType() ], exports.Line.prototype, "points", void 0);
|
|
8540
|
-
__decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
|
|
8541
|
-
__decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
|
|
8542
|
-
exports.Line = __decorate([ registerUI() ], exports.Line);
|
|
8543
8570
|
const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
|
|
8544
|
-
const {moveTo: moveTo$
|
|
8545
|
-
const line = exports.Line.prototype;
|
|
8571
|
+
const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
|
|
8546
8572
|
exports.Polygon = class Polygon extends exports.UI {
|
|
8547
8573
|
get __tag() {
|
|
8548
8574
|
return "Polygon";
|
|
@@ -8551,29 +8577,25 @@ var LeaferUI = function(exports) {
|
|
|
8551
8577
|
const data = this.__;
|
|
8552
8578
|
const path = data.path = [];
|
|
8553
8579
|
if (data.points) {
|
|
8554
|
-
drawPoints(path, data.points, data.curve, true);
|
|
8580
|
+
drawPoints$1(path, data.points, data.curve, true);
|
|
8555
8581
|
} else {
|
|
8556
8582
|
const {width: width, height: height, sides: sides} = data;
|
|
8557
8583
|
const rx = width / 2, ry = height / 2;
|
|
8558
|
-
moveTo$
|
|
8584
|
+
moveTo$2(path, rx, 0);
|
|
8559
8585
|
for (let i = 1; i < sides; i++) {
|
|
8560
|
-
lineTo$
|
|
8586
|
+
lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
|
|
8561
8587
|
}
|
|
8562
8588
|
closePath$1(path);
|
|
8563
8589
|
}
|
|
8564
8590
|
}
|
|
8565
|
-
__updateRenderPath() {}
|
|
8566
|
-
__updateBoxBounds() {}
|
|
8567
8591
|
};
|
|
8568
8592
|
__decorate([ dataProcessor(PolygonData) ], exports.Polygon.prototype, "__", void 0);
|
|
8569
8593
|
__decorate([ pathType(3) ], exports.Polygon.prototype, "sides", void 0);
|
|
8570
8594
|
__decorate([ pathType() ], exports.Polygon.prototype, "points", void 0);
|
|
8571
8595
|
__decorate([ pathType(0) ], exports.Polygon.prototype, "curve", void 0);
|
|
8572
|
-
__decorate([ rewrite(line.__updateRenderPath) ], exports.Polygon.prototype, "__updateRenderPath", null);
|
|
8573
|
-
__decorate([ rewrite(line.__updateBoxBounds) ], exports.Polygon.prototype, "__updateBoxBounds", null);
|
|
8574
8596
|
exports.Polygon = __decorate([ rewriteAble(), registerUI() ], exports.Polygon);
|
|
8575
8597
|
const {sin: sin, cos: cos, PI: PI} = Math;
|
|
8576
|
-
const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
|
|
8598
|
+
const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
|
|
8577
8599
|
exports.Star = class Star extends exports.UI {
|
|
8578
8600
|
get __tag() {
|
|
8579
8601
|
return "Star";
|
|
@@ -8582,9 +8604,9 @@ var LeaferUI = function(exports) {
|
|
|
8582
8604
|
const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
|
|
8583
8605
|
const rx = width / 2, ry = height / 2;
|
|
8584
8606
|
const path = this.__.path = [];
|
|
8585
|
-
moveTo(path, rx, 0);
|
|
8607
|
+
moveTo$1(path, rx, 0);
|
|
8586
8608
|
for (let i = 1; i < corners * 2; i++) {
|
|
8587
|
-
lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
|
|
8609
|
+
lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
|
|
8588
8610
|
}
|
|
8589
8611
|
closePath(path);
|
|
8590
8612
|
}
|
|
@@ -8593,6 +8615,42 @@ var LeaferUI = function(exports) {
|
|
|
8593
8615
|
__decorate([ pathType(5) ], exports.Star.prototype, "corners", void 0);
|
|
8594
8616
|
__decorate([ pathType(.382) ], exports.Star.prototype, "innerRadius", void 0);
|
|
8595
8617
|
exports.Star = __decorate([ registerUI() ], exports.Star);
|
|
8618
|
+
const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
|
|
8619
|
+
const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
|
|
8620
|
+
exports.Line = class Line extends exports.UI {
|
|
8621
|
+
get __tag() {
|
|
8622
|
+
return "Line";
|
|
8623
|
+
}
|
|
8624
|
+
get toPoint() {
|
|
8625
|
+
const {width: width, rotation: rotation} = this.__;
|
|
8626
|
+
const to = getPointData();
|
|
8627
|
+
if (width) to.x = width;
|
|
8628
|
+
if (rotation) rotate$1(to, rotation);
|
|
8629
|
+
return to;
|
|
8630
|
+
}
|
|
8631
|
+
set toPoint(value) {
|
|
8632
|
+
this.width = getDistance$2(defaultPoint, value);
|
|
8633
|
+
this.rotation = getAngle$1(defaultPoint, value);
|
|
8634
|
+
if (this.height) this.height = 0;
|
|
8635
|
+
}
|
|
8636
|
+
__updatePath() {
|
|
8637
|
+
const data = this.__;
|
|
8638
|
+
const path = data.path = [];
|
|
8639
|
+
if (data.points) {
|
|
8640
|
+
drawPoints(path, data.points, data.curve, data.closed);
|
|
8641
|
+
} else {
|
|
8642
|
+
moveTo(path, 0, 0);
|
|
8643
|
+
lineTo(path, this.width, 0);
|
|
8644
|
+
}
|
|
8645
|
+
}
|
|
8646
|
+
};
|
|
8647
|
+
__decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
|
|
8648
|
+
__decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
|
|
8649
|
+
__decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
|
|
8650
|
+
__decorate([ pathType() ], exports.Line.prototype, "points", void 0);
|
|
8651
|
+
__decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
|
|
8652
|
+
__decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
|
|
8653
|
+
exports.Line = __decorate([ registerUI() ], exports.Line);
|
|
8596
8654
|
exports.Image = class Image extends exports.Rect {
|
|
8597
8655
|
get __tag() {
|
|
8598
8656
|
return "Image";
|
|
@@ -8725,10 +8783,6 @@ var LeaferUI = function(exports) {
|
|
|
8725
8783
|
DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
|
|
8726
8784
|
if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
|
|
8727
8785
|
}
|
|
8728
|
-
__onUpdateSize() {
|
|
8729
|
-
if (this.__box) this.__box.__onUpdateSize();
|
|
8730
|
-
super.__onUpdateSize();
|
|
8731
|
-
}
|
|
8732
8786
|
__updateRenderSpread() {
|
|
8733
8787
|
let width = super.__updateRenderSpread();
|
|
8734
8788
|
if (!width) width = this.isOverflow ? 1 : 0;
|
|
@@ -8739,6 +8793,11 @@ var LeaferUI = function(exports) {
|
|
|
8739
8793
|
copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
|
|
8740
8794
|
if (this.__box) this.__box.__layout.renderBounds = renderBounds;
|
|
8741
8795
|
}
|
|
8796
|
+
__updateChange() {
|
|
8797
|
+
super.__updateChange();
|
|
8798
|
+
const box = this.__box;
|
|
8799
|
+
if (box) box.__onUpdateSize(), box.__updateChange();
|
|
8800
|
+
}
|
|
8742
8801
|
__drawRenderPath(canvas) {
|
|
8743
8802
|
canvas.font = this.__.__font;
|
|
8744
8803
|
}
|
|
@@ -9717,11 +9776,16 @@ var LeaferUI = function(exports) {
|
|
|
9717
9776
|
}
|
|
9718
9777
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
|
|
9719
9778
|
}
|
|
9720
|
-
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
9779
|
+
if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
9721
9780
|
if (end && index < end) other.clearWorld(copyBounds);
|
|
9722
9781
|
});
|
|
9723
9782
|
other.recycle(copyBounds);
|
|
9724
9783
|
}
|
|
9784
|
+
function getShadowSpread(_ui, shadow) {
|
|
9785
|
+
let width = 0;
|
|
9786
|
+
shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
|
|
9787
|
+
return width;
|
|
9788
|
+
}
|
|
9725
9789
|
function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
|
|
9726
9790
|
const {bounds: bounds, shapeBounds: shapeBounds} = shape;
|
|
9727
9791
|
if (Platform.fullImageShadow) {
|
|
@@ -9793,7 +9857,11 @@ var LeaferUI = function(exports) {
|
|
|
9793
9857
|
shadow: shadow,
|
|
9794
9858
|
innerShadow: innerShadow,
|
|
9795
9859
|
blur: blur,
|
|
9796
|
-
backgroundBlur: backgroundBlur
|
|
9860
|
+
backgroundBlur: backgroundBlur,
|
|
9861
|
+
getShadowSpread: getShadowSpread,
|
|
9862
|
+
isTransformShadow(_shadow) {
|
|
9863
|
+
return undefined;
|
|
9864
|
+
}
|
|
9797
9865
|
};
|
|
9798
9866
|
const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
|
|
9799
9867
|
let usedGrayscaleAlpha;
|
|
@@ -10249,16 +10317,17 @@ var LeaferUI = function(exports) {
|
|
|
10249
10317
|
row.data = null;
|
|
10250
10318
|
}
|
|
10251
10319
|
function decorationText(drawData, style) {
|
|
10252
|
-
let type;
|
|
10320
|
+
let type, offset = 0;
|
|
10253
10321
|
const {fontSize: fontSize, textDecoration: textDecoration} = style;
|
|
10254
10322
|
drawData.decorationHeight = fontSize / 11;
|
|
10255
10323
|
if (isObject(textDecoration)) {
|
|
10256
10324
|
type = textDecoration.type;
|
|
10257
10325
|
if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
|
|
10326
|
+
if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
|
|
10258
10327
|
} else type = textDecoration;
|
|
10259
10328
|
switch (type) {
|
|
10260
10329
|
case "under":
|
|
10261
|
-
drawData.decorationY = [ fontSize * .15 ];
|
|
10330
|
+
drawData.decorationY = [ fontSize * .15 + offset ];
|
|
10262
10331
|
break;
|
|
10263
10332
|
|
|
10264
10333
|
case "delete":
|
|
@@ -10266,7 +10335,7 @@ var LeaferUI = function(exports) {
|
|
|
10266
10335
|
break;
|
|
10267
10336
|
|
|
10268
10337
|
case "under-delete":
|
|
10269
|
-
drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
|
|
10338
|
+
drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
|
|
10270
10339
|
}
|
|
10271
10340
|
}
|
|
10272
10341
|
const {top: top, right: right, bottom: bottom, left: left} = exports.Direction4;
|
|
@@ -10472,6 +10541,7 @@ var LeaferUI = function(exports) {
|
|
|
10472
10541
|
exports.defineDataProcessor = defineDataProcessor;
|
|
10473
10542
|
exports.defineKey = defineKey;
|
|
10474
10543
|
exports.defineLeafAttr = defineLeafAttr;
|
|
10544
|
+
exports.dimType = dimType;
|
|
10475
10545
|
exports.doBoundsType = doBoundsType;
|
|
10476
10546
|
exports.doStrokeType = doStrokeType;
|
|
10477
10547
|
exports.effectType = effectType;
|