@leafer-ui/draw 1.9.4 → 1.9.6
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/lib/draw.cjs +137 -159
- package/lib/draw.esm.js +138 -160
- package/lib/draw.esm.min.js +1 -1
- package/lib/draw.esm.min.js.map +1 -1
- package/lib/draw.min.cjs +1 -1
- package/lib/draw.min.cjs.map +1 -1
- package/package.json +6 -6
package/lib/draw.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineKey, decorateLeafAttr, attr, createDescriptor, Plugin, isObject, PathConvert, DataHelper, Debug, LeafData, isString, isUndefined, isArray, canvasSizeAttrs, UICreator, MathHelper, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, scrollType, autoLayoutType, naturalBoundsType, affectRenderBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, pen, PathCorner, PathDrawer, isNumber, registerUI, Branch, LeafList, Resource, getBoundsData, Creator, CanvasManager, WaitHelper, LeaferEvent,
|
|
1
|
+
import { defineKey, decorateLeafAttr, attr, createDescriptor, Plugin, isObject, PathConvert, DataHelper, Debug, LeafData, isString, isUndefined, isArray, canvasSizeAttrs, UICreator, MathHelper, Bounds, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, scrollType, autoLayoutType, naturalBoundsType, affectRenderBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, pen, PathCorner, PathDrawer, isNumber, registerUI, Branch, LeafList, Resource, getBoundsData, Creator, CanvasManager, WaitHelper, LeaferEvent, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, ImageManager, BoundsHelper, PathCommandDataHelper, Platform, PointHelper, affectStrokeBoundsType, getPointData, LeaferImage, ImageEvent, Matrix, PathCreator } from "@leafer/core";
|
|
2
2
|
|
|
3
3
|
export * from "@leafer/core";
|
|
4
4
|
|
|
@@ -304,7 +304,11 @@ class LeaferData extends GroupData {
|
|
|
304
304
|
|
|
305
305
|
class FrameData extends BoxData {}
|
|
306
306
|
|
|
307
|
-
class LineData extends UIData {
|
|
307
|
+
class LineData extends UIData {
|
|
308
|
+
get __usePathBox() {
|
|
309
|
+
return this.points || this.__pathInputed;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
308
312
|
|
|
309
313
|
class RectData extends UIData {
|
|
310
314
|
get __boxStroke() {
|
|
@@ -318,7 +322,7 @@ class EllipseData extends UIData {
|
|
|
318
322
|
}
|
|
319
323
|
}
|
|
320
324
|
|
|
321
|
-
class PolygonData extends
|
|
325
|
+
class PolygonData extends LineData {}
|
|
322
326
|
|
|
323
327
|
class StarData extends UIData {}
|
|
324
328
|
|
|
@@ -362,8 +366,6 @@ class TextData extends UIData {
|
|
|
362
366
|
if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
|
|
363
367
|
box.set(value);
|
|
364
368
|
if (boxLayout.strokeChanged) layout.strokeChange();
|
|
365
|
-
if (boxLayout.renderChanged) layout.renderChange();
|
|
366
|
-
box.__updateChange();
|
|
367
369
|
} else if (box) {
|
|
368
370
|
t.__box = box.parent = null;
|
|
369
371
|
box.destroy();
|
|
@@ -433,7 +435,7 @@ const UIBounds = {
|
|
|
433
435
|
__updateRenderSpread() {
|
|
434
436
|
let width = 0;
|
|
435
437
|
const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
|
|
436
|
-
if (shadow)
|
|
438
|
+
if (shadow) width = Effect.getShadowSpread(this, shadow);
|
|
437
439
|
if (blur) width = Math.max(width, blur);
|
|
438
440
|
if (filter) width += Filter.getSpread(filter);
|
|
439
441
|
if (renderSpread) width += renderSpread;
|
|
@@ -446,36 +448,69 @@ const UIBounds = {
|
|
|
446
448
|
}
|
|
447
449
|
};
|
|
448
450
|
|
|
451
|
+
const {float: float} = MathHelper;
|
|
452
|
+
|
|
453
|
+
const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
|
|
454
|
+
|
|
449
455
|
const DragBoundsHelper = {
|
|
456
|
+
limitMove(leaf, move) {
|
|
457
|
+
const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
|
|
458
|
+
if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
|
|
459
|
+
D.axisMove(leaf, move);
|
|
460
|
+
},
|
|
461
|
+
limitScaleOf(leaf, origin, scale) {
|
|
462
|
+
const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
|
|
463
|
+
if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
|
|
464
|
+
},
|
|
465
|
+
axisMove(leaf, move) {
|
|
466
|
+
const {draggable: draggable} = leaf;
|
|
467
|
+
if (draggable === "x") move.y = 0;
|
|
468
|
+
if (draggable === "y") move.x = 0;
|
|
469
|
+
},
|
|
470
|
+
getDragBounds(leaf) {
|
|
471
|
+
const {dragBounds: dragBounds} = leaf;
|
|
472
|
+
return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
|
|
473
|
+
},
|
|
474
|
+
isInnerMode(content, dragBounds, dragBoundsType, sideType) {
|
|
475
|
+
return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
|
|
476
|
+
},
|
|
450
477
|
getValidMove(content, dragBounds, dragBoundsType, move, change) {
|
|
451
478
|
const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
|
|
452
479
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
453
480
|
if (!change) move = Object.assign({}, move);
|
|
454
|
-
|
|
455
|
-
const isBiggerHeight = content.height > dragBounds.height;
|
|
456
|
-
if (isBiggerWidth && dragBoundsType !== "outer") {
|
|
481
|
+
if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
|
|
457
482
|
if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
|
|
458
483
|
} else {
|
|
459
484
|
if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
|
|
460
485
|
}
|
|
461
|
-
if (
|
|
486
|
+
if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
|
|
462
487
|
if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
|
|
463
488
|
} else {
|
|
464
489
|
if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
|
|
465
490
|
}
|
|
466
|
-
move.x =
|
|
467
|
-
move.y =
|
|
491
|
+
move.x = float(move.x);
|
|
492
|
+
move.y = float(move.y);
|
|
468
493
|
return move;
|
|
469
494
|
},
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
495
|
+
getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
|
|
496
|
+
if (!change) scale = Object.assign({}, scale);
|
|
497
|
+
let fitScaleX, fitScaleY;
|
|
498
|
+
tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
|
|
499
|
+
tempMerge.set(tempContent).add(dragBounds);
|
|
500
|
+
tempIntersect.set(tempContent).intersect(dragBounds);
|
|
501
|
+
if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
|
|
502
|
+
fitScaleX = tempMerge.width / tempContent.width;
|
|
503
|
+
} else {
|
|
504
|
+
fitScaleX = tempIntersect.width / tempContent.width;
|
|
505
|
+
}
|
|
506
|
+
if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
|
|
507
|
+
fitScaleY = tempMerge.height / tempContent.height;
|
|
508
|
+
} else {
|
|
509
|
+
fitScaleY = tempIntersect.height / tempContent.height;
|
|
510
|
+
}
|
|
511
|
+
scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
|
|
512
|
+
scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
|
|
513
|
+
return scale;
|
|
479
514
|
}
|
|
480
515
|
};
|
|
481
516
|
|
|
@@ -493,7 +528,7 @@ const UIRender = {
|
|
|
493
528
|
}
|
|
494
529
|
if (data.__useEffect) {
|
|
495
530
|
const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
496
|
-
stintSet(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"));
|
|
531
|
+
stintSet(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"));
|
|
497
532
|
data.__useEffect = !!(shadow || otherEffect);
|
|
498
533
|
}
|
|
499
534
|
data.__checkSingle();
|
|
@@ -628,20 +663,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
628
663
|
if (!path) this.__drawPathByBox(pen);
|
|
629
664
|
return pen;
|
|
630
665
|
}
|
|
631
|
-
constructor(data) {
|
|
632
|
-
super(data);
|
|
633
|
-
}
|
|
634
666
|
reset(_data) {}
|
|
635
|
-
set(data,
|
|
636
|
-
if (data)
|
|
637
|
-
if (transition) {
|
|
638
|
-
if (transition === "temp") {
|
|
639
|
-
this.lockNormalStyle = true;
|
|
640
|
-
Object.assign(this, data);
|
|
641
|
-
this.lockNormalStyle = false;
|
|
642
|
-
} else this.animate(data, transition);
|
|
643
|
-
} else Object.assign(this, data);
|
|
644
|
-
}
|
|
667
|
+
set(data, _transition) {
|
|
668
|
+
if (data) Object.assign(this, data);
|
|
645
669
|
}
|
|
646
670
|
get(name) {
|
|
647
671
|
return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
@@ -687,7 +711,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
687
711
|
const data = this.__;
|
|
688
712
|
if (data.path) {
|
|
689
713
|
data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
|
|
690
|
-
if (data.__useArrow) PathArrow.addArrows(this
|
|
714
|
+
if (data.__useArrow) PathArrow.addArrows(this);
|
|
691
715
|
} else data.__pathForRender && (data.__pathForRender = undefined);
|
|
692
716
|
}
|
|
693
717
|
__drawRenderPath(canvas) {
|
|
@@ -711,7 +735,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
711
735
|
drawImagePlaceholder(canvas, _image) {
|
|
712
736
|
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
713
737
|
}
|
|
714
|
-
animate(
|
|
738
|
+
animate(keyframe, _options, _type, _isTemp) {
|
|
739
|
+
this.set(keyframe);
|
|
715
740
|
return Plugin.need("animate");
|
|
716
741
|
}
|
|
717
742
|
killAnimate(_type, _nextStyle) {}
|
|
@@ -900,9 +925,6 @@ let Group = class Group extends UI {
|
|
|
900
925
|
get isBranch() {
|
|
901
926
|
return true;
|
|
902
927
|
}
|
|
903
|
-
constructor(data) {
|
|
904
|
-
super(data);
|
|
905
|
-
}
|
|
906
928
|
reset(data) {
|
|
907
929
|
this.__setBranch();
|
|
908
930
|
super.reset(data);
|
|
@@ -1027,7 +1049,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
1027
1049
|
const canvas = this.canvas = Creator.canvas(config);
|
|
1028
1050
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
1029
1051
|
if (this.isApp) this.__setApp();
|
|
1030
|
-
this.__checkAutoLayout(
|
|
1052
|
+
this.__checkAutoLayout();
|
|
1031
1053
|
this.view = canvas.view;
|
|
1032
1054
|
if (!parentApp) {
|
|
1033
1055
|
this.selector = Creator.selector(this);
|
|
@@ -1126,7 +1148,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
1126
1148
|
this.leafer = leafer;
|
|
1127
1149
|
this.__level = 1;
|
|
1128
1150
|
}
|
|
1129
|
-
__checkAutoLayout(
|
|
1151
|
+
__checkAutoLayout() {
|
|
1152
|
+
const {config: config, parentApp: parentApp} = this;
|
|
1130
1153
|
if (!parentApp) {
|
|
1131
1154
|
if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
|
|
1132
1155
|
this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
|
|
@@ -1143,7 +1166,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
1143
1166
|
} else if (attrName === "zIndex") {
|
|
1144
1167
|
this.canvas.zIndex = newValue;
|
|
1145
1168
|
setTimeout(() => this.parent && this.parent.__updateSortChildren());
|
|
1146
|
-
}
|
|
1169
|
+
} else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
|
|
1170
|
+
mode: newValue
|
|
1171
|
+
});
|
|
1147
1172
|
}
|
|
1148
1173
|
return super.__setAttr(attrName, newValue);
|
|
1149
1174
|
}
|
|
@@ -1152,9 +1177,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
1152
1177
|
return super.__getAttr(attrName);
|
|
1153
1178
|
}
|
|
1154
1179
|
__changeCanvasSize(attrName, newValue) {
|
|
1155
|
-
const
|
|
1156
|
-
data
|
|
1157
|
-
|
|
1180
|
+
const {config: config, canvas: canvas} = this;
|
|
1181
|
+
const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
|
|
1182
|
+
data[attrName] = config[attrName] = newValue;
|
|
1183
|
+
config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
|
|
1158
1184
|
this.__doResize(data);
|
|
1159
1185
|
}
|
|
1160
1186
|
__changeFill(newValue) {
|
|
@@ -1301,9 +1327,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
1301
1327
|
if (!this.parent) {
|
|
1302
1328
|
if (this.selector) this.selector.destroy();
|
|
1303
1329
|
if (this.hitCanvasManager) this.hitCanvasManager.destroy();
|
|
1304
|
-
this.canvasManager.destroy();
|
|
1330
|
+
if (this.canvasManager) this.canvasManager.destroy();
|
|
1305
1331
|
}
|
|
1306
|
-
this.canvas.destroy();
|
|
1332
|
+
if (this.canvas) this.canvas.destroy();
|
|
1307
1333
|
this.config.view = this.view = this.parentApp = null;
|
|
1308
1334
|
if (this.userConfig) this.userConfig.view = null;
|
|
1309
1335
|
super.destroy();
|
|
@@ -1325,15 +1351,14 @@ __decorate([ dataProcessor(LeaferData) ], Leafer.prototype, "__", void 0);
|
|
|
1325
1351
|
|
|
1326
1352
|
__decorate([ boundsType() ], Leafer.prototype, "pixelRatio", void 0);
|
|
1327
1353
|
|
|
1354
|
+
__decorate([ dataType("normal") ], Leafer.prototype, "mode", void 0);
|
|
1355
|
+
|
|
1328
1356
|
Leafer = Leafer_1 = __decorate([ registerUI() ], Leafer);
|
|
1329
1357
|
|
|
1330
1358
|
let Rect = class Rect extends UI {
|
|
1331
1359
|
get __tag() {
|
|
1332
1360
|
return "Rect";
|
|
1333
1361
|
}
|
|
1334
|
-
constructor(data) {
|
|
1335
|
-
super(data);
|
|
1336
|
-
}
|
|
1337
1362
|
};
|
|
1338
1363
|
|
|
1339
1364
|
__decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
|
|
@@ -1465,9 +1490,6 @@ let Frame = class Frame extends Box {
|
|
|
1465
1490
|
get isFrame() {
|
|
1466
1491
|
return true;
|
|
1467
1492
|
}
|
|
1468
|
-
constructor(data) {
|
|
1469
|
-
super(data);
|
|
1470
|
-
}
|
|
1471
1493
|
};
|
|
1472
1494
|
|
|
1473
1495
|
__decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
|
|
@@ -1484,9 +1506,6 @@ let Ellipse = class Ellipse extends UI {
|
|
|
1484
1506
|
get __tag() {
|
|
1485
1507
|
return "Ellipse";
|
|
1486
1508
|
}
|
|
1487
|
-
constructor(data) {
|
|
1488
|
-
super(data);
|
|
1489
|
-
}
|
|
1490
1509
|
__updatePath() {
|
|
1491
1510
|
const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
|
|
1492
1511
|
const rx = width / 2, ry = height / 2;
|
|
@@ -1526,98 +1545,29 @@ __decorate([ pathType(0) ], Ellipse.prototype, "endAngle", void 0);
|
|
|
1526
1545
|
|
|
1527
1546
|
Ellipse = __decorate([ registerUI() ], Ellipse);
|
|
1528
1547
|
|
|
1529
|
-
const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
|
|
1530
|
-
|
|
1531
|
-
const {rotate: rotate, getAngle: getAngle, getDistance: getDistance, defaultPoint: defaultPoint} = PointHelper;
|
|
1532
|
-
|
|
1533
|
-
const {toBounds: toBounds} = PathBounds;
|
|
1534
|
-
|
|
1535
|
-
let Line = class Line extends UI {
|
|
1536
|
-
get __tag() {
|
|
1537
|
-
return "Line";
|
|
1538
|
-
}
|
|
1539
|
-
get toPoint() {
|
|
1540
|
-
const {width: width, rotation: rotation} = this.__;
|
|
1541
|
-
const to = getPointData();
|
|
1542
|
-
if (width) to.x = width;
|
|
1543
|
-
if (rotation) rotate(to, rotation);
|
|
1544
|
-
return to;
|
|
1545
|
-
}
|
|
1546
|
-
set toPoint(value) {
|
|
1547
|
-
this.width = getDistance(defaultPoint, value);
|
|
1548
|
-
this.rotation = getAngle(defaultPoint, value);
|
|
1549
|
-
if (this.height) this.height = 0;
|
|
1550
|
-
}
|
|
1551
|
-
constructor(data) {
|
|
1552
|
-
super(data);
|
|
1553
|
-
}
|
|
1554
|
-
__updatePath() {
|
|
1555
|
-
const data = this.__;
|
|
1556
|
-
const path = data.path = [];
|
|
1557
|
-
if (data.points) {
|
|
1558
|
-
drawPoints$1(path, data.points, false, data.closed);
|
|
1559
|
-
} else {
|
|
1560
|
-
moveTo$2(path, 0, 0);
|
|
1561
|
-
lineTo$2(path, this.width, 0);
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
__updateRenderPath() {
|
|
1565
|
-
const data = this.__;
|
|
1566
|
-
if (!this.pathInputed && data.points && data.curve) {
|
|
1567
|
-
drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
|
|
1568
|
-
if (data.__useArrow) PathArrow.addArrows(this, false);
|
|
1569
|
-
} else super.__updateRenderPath();
|
|
1570
|
-
}
|
|
1571
|
-
__updateBoxBounds() {
|
|
1572
|
-
if (this.points) {
|
|
1573
|
-
toBounds(this.__.__pathForRender, this.__layout.boxBounds);
|
|
1574
|
-
} else super.__updateBoxBounds();
|
|
1575
|
-
}
|
|
1576
|
-
};
|
|
1577
|
-
|
|
1578
|
-
__decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
|
|
1579
|
-
|
|
1580
|
-
__decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
|
|
1581
|
-
|
|
1582
|
-
__decorate([ boundsType(0) ], Line.prototype, "height", void 0);
|
|
1583
|
-
|
|
1584
|
-
__decorate([ pathType() ], Line.prototype, "points", void 0);
|
|
1585
|
-
|
|
1586
|
-
__decorate([ pathType(0) ], Line.prototype, "curve", void 0);
|
|
1587
|
-
|
|
1588
|
-
__decorate([ pathType(false) ], Line.prototype, "closed", void 0);
|
|
1589
|
-
|
|
1590
|
-
Line = __decorate([ registerUI() ], Line);
|
|
1591
|
-
|
|
1592
1548
|
const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
|
|
1593
1549
|
|
|
1594
|
-
const {moveTo: moveTo$
|
|
1595
|
-
|
|
1596
|
-
const line = Line.prototype;
|
|
1550
|
+
const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
|
|
1597
1551
|
|
|
1598
1552
|
let Polygon = class Polygon extends UI {
|
|
1599
1553
|
get __tag() {
|
|
1600
1554
|
return "Polygon";
|
|
1601
1555
|
}
|
|
1602
|
-
constructor(data) {
|
|
1603
|
-
super(data);
|
|
1604
|
-
}
|
|
1605
1556
|
__updatePath() {
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
|
|
1557
|
+
const data = this.__;
|
|
1558
|
+
const path = data.path = [];
|
|
1559
|
+
if (data.points) {
|
|
1560
|
+
drawPoints$1(path, data.points, data.curve, true);
|
|
1609
1561
|
} else {
|
|
1610
|
-
const {width: width, height: height, sides: sides} =
|
|
1562
|
+
const {width: width, height: height, sides: sides} = data;
|
|
1611
1563
|
const rx = width / 2, ry = height / 2;
|
|
1612
|
-
moveTo$
|
|
1564
|
+
moveTo$2(path, rx, 0);
|
|
1613
1565
|
for (let i = 1; i < sides; i++) {
|
|
1614
|
-
lineTo$
|
|
1566
|
+
lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
|
|
1615
1567
|
}
|
|
1616
1568
|
closePath$1(path);
|
|
1617
1569
|
}
|
|
1618
1570
|
}
|
|
1619
|
-
__updateRenderPath() {}
|
|
1620
|
-
__updateBoxBounds() {}
|
|
1621
1571
|
};
|
|
1622
1572
|
|
|
1623
1573
|
__decorate([ dataProcessor(PolygonData) ], Polygon.prototype, "__", void 0);
|
|
@@ -1628,30 +1578,23 @@ __decorate([ pathType() ], Polygon.prototype, "points", void 0);
|
|
|
1628
1578
|
|
|
1629
1579
|
__decorate([ pathType(0) ], Polygon.prototype, "curve", void 0);
|
|
1630
1580
|
|
|
1631
|
-
__decorate([ rewrite(line.__updateRenderPath) ], Polygon.prototype, "__updateRenderPath", null);
|
|
1632
|
-
|
|
1633
|
-
__decorate([ rewrite(line.__updateBoxBounds) ], Polygon.prototype, "__updateBoxBounds", null);
|
|
1634
|
-
|
|
1635
1581
|
Polygon = __decorate([ rewriteAble(), registerUI() ], Polygon);
|
|
1636
1582
|
|
|
1637
1583
|
const {sin: sin, cos: cos, PI: PI} = Math;
|
|
1638
1584
|
|
|
1639
|
-
const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
|
|
1585
|
+
const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
|
|
1640
1586
|
|
|
1641
1587
|
let Star = class Star extends UI {
|
|
1642
1588
|
get __tag() {
|
|
1643
1589
|
return "Star";
|
|
1644
1590
|
}
|
|
1645
|
-
constructor(data) {
|
|
1646
|
-
super(data);
|
|
1647
|
-
}
|
|
1648
1591
|
__updatePath() {
|
|
1649
1592
|
const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
|
|
1650
1593
|
const rx = width / 2, ry = height / 2;
|
|
1651
1594
|
const path = this.__.path = [];
|
|
1652
|
-
moveTo(path, rx, 0);
|
|
1595
|
+
moveTo$1(path, rx, 0);
|
|
1653
1596
|
for (let i = 1; i < corners * 2; i++) {
|
|
1654
|
-
lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
|
|
1597
|
+
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));
|
|
1655
1598
|
}
|
|
1656
1599
|
closePath(path);
|
|
1657
1600
|
}
|
|
@@ -1665,6 +1608,52 @@ __decorate([ pathType(.382) ], Star.prototype, "innerRadius", void 0);
|
|
|
1665
1608
|
|
|
1666
1609
|
Star = __decorate([ registerUI() ], Star);
|
|
1667
1610
|
|
|
1611
|
+
const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
|
|
1612
|
+
|
|
1613
|
+
const {rotate: rotate, getAngle: getAngle, getDistance: getDistance, defaultPoint: defaultPoint} = PointHelper;
|
|
1614
|
+
|
|
1615
|
+
let Line = class Line extends UI {
|
|
1616
|
+
get __tag() {
|
|
1617
|
+
return "Line";
|
|
1618
|
+
}
|
|
1619
|
+
get toPoint() {
|
|
1620
|
+
const {width: width, rotation: rotation} = this.__;
|
|
1621
|
+
const to = getPointData();
|
|
1622
|
+
if (width) to.x = width;
|
|
1623
|
+
if (rotation) rotate(to, rotation);
|
|
1624
|
+
return to;
|
|
1625
|
+
}
|
|
1626
|
+
set toPoint(value) {
|
|
1627
|
+
this.width = getDistance(defaultPoint, value);
|
|
1628
|
+
this.rotation = getAngle(defaultPoint, value);
|
|
1629
|
+
if (this.height) this.height = 0;
|
|
1630
|
+
}
|
|
1631
|
+
__updatePath() {
|
|
1632
|
+
const data = this.__;
|
|
1633
|
+
const path = data.path = [];
|
|
1634
|
+
if (data.points) {
|
|
1635
|
+
drawPoints(path, data.points, data.curve, data.closed);
|
|
1636
|
+
} else {
|
|
1637
|
+
moveTo(path, 0, 0);
|
|
1638
|
+
lineTo(path, this.width, 0);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
|
|
1643
|
+
__decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
|
|
1644
|
+
|
|
1645
|
+
__decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
|
|
1646
|
+
|
|
1647
|
+
__decorate([ boundsType(0) ], Line.prototype, "height", void 0);
|
|
1648
|
+
|
|
1649
|
+
__decorate([ pathType() ], Line.prototype, "points", void 0);
|
|
1650
|
+
|
|
1651
|
+
__decorate([ pathType(0) ], Line.prototype, "curve", void 0);
|
|
1652
|
+
|
|
1653
|
+
__decorate([ pathType(false) ], Line.prototype, "closed", void 0);
|
|
1654
|
+
|
|
1655
|
+
Line = __decorate([ registerUI() ], Line);
|
|
1656
|
+
|
|
1668
1657
|
let Image = class Image extends Rect {
|
|
1669
1658
|
get __tag() {
|
|
1670
1659
|
return "Image";
|
|
@@ -1677,9 +1666,6 @@ let Image = class Image extends Rect {
|
|
|
1677
1666
|
const {fill: fill} = this.__;
|
|
1678
1667
|
return isArray(fill) && fill[0].image;
|
|
1679
1668
|
}
|
|
1680
|
-
constructor(data) {
|
|
1681
|
-
super(data);
|
|
1682
|
-
}
|
|
1683
1669
|
};
|
|
1684
1670
|
|
|
1685
1671
|
__decorate([ dataProcessor(ImageData) ], Image.prototype, "__", void 0);
|
|
@@ -1779,9 +1765,6 @@ let Text = class Text extends UI {
|
|
|
1779
1765
|
this.updateLayout();
|
|
1780
1766
|
return this.__.__textDrawData;
|
|
1781
1767
|
}
|
|
1782
|
-
constructor(data) {
|
|
1783
|
-
super(data);
|
|
1784
|
-
}
|
|
1785
1768
|
__updateTextDrawData() {
|
|
1786
1769
|
const data = this.__;
|
|
1787
1770
|
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
|
|
@@ -1818,10 +1801,6 @@ let Text = class Text extends UI {
|
|
|
1818
1801
|
DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
|
|
1819
1802
|
if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
|
|
1820
1803
|
}
|
|
1821
|
-
__onUpdateSize() {
|
|
1822
|
-
if (this.__box) this.__box.__onUpdateSize();
|
|
1823
|
-
super.__onUpdateSize();
|
|
1824
|
-
}
|
|
1825
1804
|
__updateRenderSpread() {
|
|
1826
1805
|
let width = super.__updateRenderSpread();
|
|
1827
1806
|
if (!width) width = this.isOverflow ? 1 : 0;
|
|
@@ -1832,6 +1811,11 @@ let Text = class Text extends UI {
|
|
|
1832
1811
|
copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
|
|
1833
1812
|
if (this.__box) this.__box.__layout.renderBounds = renderBounds;
|
|
1834
1813
|
}
|
|
1814
|
+
__updateChange() {
|
|
1815
|
+
super.__updateChange();
|
|
1816
|
+
const box = this.__box;
|
|
1817
|
+
if (box) box.__onUpdateSize(), box.__updateChange();
|
|
1818
|
+
}
|
|
1835
1819
|
__drawRenderPath(canvas) {
|
|
1836
1820
|
canvas.font = this.__.__font;
|
|
1837
1821
|
}
|
|
@@ -1914,9 +1898,6 @@ let Path = class Path extends UI {
|
|
|
1914
1898
|
get __tag() {
|
|
1915
1899
|
return "Path";
|
|
1916
1900
|
}
|
|
1917
|
-
constructor(data) {
|
|
1918
|
-
super(data);
|
|
1919
|
-
}
|
|
1920
1901
|
};
|
|
1921
1902
|
|
|
1922
1903
|
__decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
|
|
@@ -1929,9 +1910,6 @@ let Pen = class Pen extends Group {
|
|
|
1929
1910
|
get __tag() {
|
|
1930
1911
|
return "Pen";
|
|
1931
1912
|
}
|
|
1932
|
-
constructor(data) {
|
|
1933
|
-
super(data);
|
|
1934
|
-
}
|
|
1935
1913
|
setStyle(data) {
|
|
1936
1914
|
const path = this.pathElement = new Path(data);
|
|
1937
1915
|
this.pathStyle = data;
|