@meta2d/core 1.0.51 → 1.0.53
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/package.json +1 -1
- package/src/canvas/canvas.d.ts +12 -3
- package/src/canvas/canvas.js +522 -40
- package/src/canvas/canvas.js.map +1 -1
- package/src/canvas/canvasImage.d.ts +5 -1
- package/src/canvas/canvasImage.js +54 -12
- package/src/canvas/canvasImage.js.map +1 -1
- package/src/canvas/magnifierCanvas.js +5 -3
- package/src/canvas/magnifierCanvas.js.map +1 -1
- package/src/core.d.ts +4 -3
- package/src/core.js +309 -93
- package/src/core.js.map +1 -1
- package/src/data.js +2 -1
- package/src/data.js.map +1 -1
- package/src/diagrams/iframe.js +2 -0
- package/src/diagrams/iframe.js.map +1 -1
- package/src/map/map.d.ts +1 -0
- package/src/map/map.js +68 -1
- package/src/map/map.js.map +1 -1
- package/src/options.js +1 -1
- package/src/options.js.map +1 -1
- package/src/pen/model.d.ts +7 -0
- package/src/pen/model.js +1 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.d.ts +2 -0
- package/src/pen/render.js +385 -5
- package/src/pen/render.js.map +1 -1
- package/src/store/store.d.ts +21 -0
- package/src/store/store.js.map +1 -1
package/src/canvas/canvas.js
CHANGED
|
@@ -82,7 +82,7 @@ var __values = (this && this.__values) || function(o) {
|
|
|
82
82
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
83
83
|
};
|
|
84
84
|
import { KeydownType } from '../options';
|
|
85
|
-
import { addLineAnchor, calcIconRect, calcTextRect, calcWorldAnchors, calcWorldRects, LockState, nearestAnchor, PenType, pushPenAnchor, removePenAnchor, renderPen, scalePen, translateLine, deleteTempAnchor, connectLine, disconnectLine, getAnchor, calcAnchorDock, calcMoveDock, calcTextLines, setNodeAnimate, setLineAnimate, calcPenRect, setChildrenActive, getParent, setHover, randomId, getPensLock, getToAnchor, getFromAnchor, calcPadding, getPensDisableRotate, getPensDisableResize, needCalcTextRectProps, calcResizeDock, needPatchFlagsPenRectProps, needCalcIconRectProps, isDomShapes, renderPenRaw, needSetPenProps, getAllChildren, calcInView, isShowChild, getTextColor, getGlobalColor, clearLifeCycle, rotatePen, calcTextAutoWidth, getGradientAnimatePath, CanvasLayer, ctxFlip, ctxRotate, setGlobalAlpha, drawImage, setElemPosition, getAllFollowers, } from '../pen';
|
|
85
|
+
import { addLineAnchor, calcIconRect, calcTextRect, calcWorldAnchors, calcWorldRects, LockState, nearestAnchor, PenType, pushPenAnchor, removePenAnchor, renderPen, scalePen, translateLine, deleteTempAnchor, connectLine, disconnectLine, getAnchor, calcAnchorDock, calcMoveDock, calcTextLines, setNodeAnimate, setLineAnimate, calcPenRect, setChildrenActive, getParent, setHover, randomId, getPensLock, getToAnchor, getFromAnchor, calcPadding, getPensDisableRotate, getPensDisableResize, needCalcTextRectProps, calcResizeDock, needPatchFlagsPenRectProps, needCalcIconRectProps, isDomShapes, renderPenRaw, needSetPenProps, getAllChildren, calcInView, isShowChild, getTextColor, getGlobalColor, clearLifeCycle, rotatePen, calcTextAutoWidth, getGradientAnimatePath, CanvasLayer, ctxFlip, ctxRotate, setGlobalAlpha, drawImage, setElemPosition, getAllFollowers, calcChildrenInitRect, } from '../pen';
|
|
86
86
|
import { calcRotate, distance, getDistance, hitPoint, PointType, PrevNextType, rotatePoint, samePoint, scalePoint, translatePoint, TwoWay, } from '../point';
|
|
87
87
|
import { calcCenter, calcRightBottom, calcRelativePoint, getRect, getRectOfPoints, pointInRect, pointInSimpleRect, rectInRect, rectToPoints, resizeRect, translateRect, pointInPolygon } from '../rect';
|
|
88
88
|
import { EditType, globalStore, } from '../store';
|
|
@@ -120,6 +120,7 @@ var Canvas = /** @class */ (function () {
|
|
|
120
120
|
this.patchFlagsLines = new Set();
|
|
121
121
|
this.lastMouseTime = 0;
|
|
122
122
|
this.hoverTimer = 0;
|
|
123
|
+
this.fitTimer = 0;
|
|
123
124
|
this.patchFlags = false;
|
|
124
125
|
this.lastRender = 0;
|
|
125
126
|
this.touchStart = 0;
|
|
@@ -319,6 +320,33 @@ var Canvas = /** @class */ (function () {
|
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
var x = e.offsetX, y = e.offsetY;
|
|
323
|
+
// if (this.parent.map && e.target === this.parent.map?.box) {
|
|
324
|
+
// //放大镜缩放
|
|
325
|
+
// const width = this.store.data.width || this.store.options.width;
|
|
326
|
+
// const height = this.store.data.height || this.store.options.height;
|
|
327
|
+
// if (width && height) {
|
|
328
|
+
// //大屏
|
|
329
|
+
// x =
|
|
330
|
+
// (x / this.parent.map.boxWidth) * width * this.store.data.scale +
|
|
331
|
+
// this.store.data.origin.x;
|
|
332
|
+
// y =
|
|
333
|
+
// (y / this.parent.map.boxHeight) * height * this.store.data.scale +
|
|
334
|
+
// this.store.data.origin.y;
|
|
335
|
+
// const rect = this.canvas.getBoundingClientRect();
|
|
336
|
+
// x = x + rect.left;
|
|
337
|
+
// y = y + rect.top;
|
|
338
|
+
// } else {
|
|
339
|
+
// const rect = this.parent.getRect();
|
|
340
|
+
// x =
|
|
341
|
+
// (x / this.parent.map.boxWidth) * rect.width +
|
|
342
|
+
// rect.x +
|
|
343
|
+
// this.store.data.x;
|
|
344
|
+
// y =
|
|
345
|
+
// (y / this.parent.map.boxHeight) * rect.height +
|
|
346
|
+
// rect.y +
|
|
347
|
+
// this.store.data.y;
|
|
348
|
+
// }
|
|
349
|
+
// }
|
|
322
350
|
_this.scale(_this.store.data.scale + scaleOff, { x: x, y: y });
|
|
323
351
|
_this.externalElements.focus(); // 聚焦
|
|
324
352
|
};
|
|
@@ -428,6 +456,10 @@ var Canvas = /** @class */ (function () {
|
|
|
428
456
|
break;
|
|
429
457
|
case 'Delete':
|
|
430
458
|
case 'Backspace':
|
|
459
|
+
if (_this.canvasImage.fitFlag && _this.canvasImage.activeFit) {
|
|
460
|
+
_this.deleteFit();
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
431
463
|
!_this.store.data.locked && _this.delete();
|
|
432
464
|
break;
|
|
433
465
|
case 'ArrowLeft':
|
|
@@ -656,7 +688,7 @@ var Canvas = /** @class */ (function () {
|
|
|
656
688
|
}
|
|
657
689
|
else {
|
|
658
690
|
//图元进入编辑模式
|
|
659
|
-
pen.calculative.focus =
|
|
691
|
+
pen.calculative.focus = true;
|
|
660
692
|
}
|
|
661
693
|
});
|
|
662
694
|
_this.render();
|
|
@@ -668,6 +700,16 @@ var Canvas = /** @class */ (function () {
|
|
|
668
700
|
}
|
|
669
701
|
_this.drawingLineName = undefined;
|
|
670
702
|
_this.stopPencil();
|
|
703
|
+
if (_this.store.active) {
|
|
704
|
+
_this.store.active.forEach(function (pen) {
|
|
705
|
+
if (pen.type) {
|
|
706
|
+
}
|
|
707
|
+
else {
|
|
708
|
+
//图元退出编辑模式
|
|
709
|
+
pen.calculative.focus = false;
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}
|
|
671
713
|
if (_this.movingPens) {
|
|
672
714
|
_this.getAllByPens(_this.movingPens).forEach(function (pen) {
|
|
673
715
|
_this.store.pens[pen.id] = undefined;
|
|
@@ -981,6 +1023,13 @@ var Canvas = /** @class */ (function () {
|
|
|
981
1023
|
_this.mousePos.y = e.y;
|
|
982
1024
|
_this.mouseDown = e;
|
|
983
1025
|
_this.lastMouseTime = performance.now();
|
|
1026
|
+
if (_this.canvasImage.fitFlag) {
|
|
1027
|
+
if (!_this.canvasImage.currentFit) {
|
|
1028
|
+
//选中布局容器
|
|
1029
|
+
_this.calcuActiveFit();
|
|
1030
|
+
}
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
984
1033
|
// Set anchor of pen.
|
|
985
1034
|
if (_this.hotkeyType === HotkeyType.AddAnchor) {
|
|
986
1035
|
_this.setAnchor(_this.store.pointAt);
|
|
@@ -1207,6 +1256,9 @@ var Canvas = /** @class */ (function () {
|
|
|
1207
1256
|
});
|
|
1208
1257
|
break;
|
|
1209
1258
|
}
|
|
1259
|
+
if (_this.store.hover) {
|
|
1260
|
+
_this.store.hover.calculative.mouseDown = true;
|
|
1261
|
+
}
|
|
1210
1262
|
_this.store.emitter.emit('mousedown', {
|
|
1211
1263
|
x: e.x,
|
|
1212
1264
|
y: e.y,
|
|
@@ -1216,7 +1268,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1216
1268
|
_this.render();
|
|
1217
1269
|
};
|
|
1218
1270
|
this.onMouseMove = function (e) {
|
|
1219
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1271
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1220
1272
|
if (_this.store.data.locked === LockState.Disable) {
|
|
1221
1273
|
_this.hoverType = HoverType.None;
|
|
1222
1274
|
return;
|
|
@@ -1245,6 +1297,22 @@ var Canvas = /** @class */ (function () {
|
|
|
1245
1297
|
_this.render();
|
|
1246
1298
|
return;
|
|
1247
1299
|
}
|
|
1300
|
+
if (_this.canvasImage.fitFlag) {
|
|
1301
|
+
if (_this.canvasImage.activeFit) {
|
|
1302
|
+
var now_2 = performance.now();
|
|
1303
|
+
if (now_2 - _this.fitTimer > 100) {
|
|
1304
|
+
if (_this.mouseDown) {
|
|
1305
|
+
// 容器大小变化
|
|
1306
|
+
_this.updateFit(e);
|
|
1307
|
+
}
|
|
1308
|
+
else {
|
|
1309
|
+
_this.inFitBorder(_this.mousePos);
|
|
1310
|
+
}
|
|
1311
|
+
_this.fitTimer = now_2;
|
|
1312
|
+
}
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1248
1316
|
if (_this.mouseDown && !_this.store.options.disableTranslate) {
|
|
1249
1317
|
// 画布平移前提
|
|
1250
1318
|
if (_this.mouseRight === MouseRight.Down) {
|
|
@@ -1298,7 +1366,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1298
1366
|
return;
|
|
1299
1367
|
}
|
|
1300
1368
|
// 框选
|
|
1301
|
-
if (e.buttons === 1 && (e.ctrlKey || !_this.hoverType && !_this.hotkeyType)) {
|
|
1369
|
+
if (e.buttons === 1 && (e.ctrlKey || !_this.hoverType && !_this.hotkeyType) && !(e.ctrlKey && (_this.store.activeAnchor || ((_a = _this.store.active) === null || _a === void 0 ? void 0 : _a.length)))) {
|
|
1302
1370
|
_this.dragRect = {
|
|
1303
1371
|
x: Math.min(_this.mouseDown.x, e.x),
|
|
1304
1372
|
y: Math.min(_this.mouseDown.y, e.y),
|
|
@@ -1318,17 +1386,17 @@ var Canvas = /** @class */ (function () {
|
|
|
1318
1386
|
_this.render();
|
|
1319
1387
|
return;
|
|
1320
1388
|
}
|
|
1321
|
-
else if (!((
|
|
1389
|
+
else if (!((_b = _this.store.active[0]) === null || _b === void 0 ? void 0 : _b.locked)) {
|
|
1322
1390
|
var pt = { x: e.x, y: e.y };
|
|
1323
1391
|
// Move line anchor
|
|
1324
1392
|
if (_this.hoverType === HoverType.LineAnchor) {
|
|
1325
|
-
if ((_this.dockInAnchor(e) || ((
|
|
1393
|
+
if ((_this.dockInAnchor(e) || ((_c = _this.store.active[0]) === null || _c === void 0 ? void 0 : _c.lineName) === 'line') &&
|
|
1326
1394
|
!_this.store.options.disableDock &&
|
|
1327
1395
|
!_this.store.options.disableLineDock) {
|
|
1328
1396
|
_this.clearDock();
|
|
1329
1397
|
_this.dock = calcAnchorDock(_this.store, pt, _this.store.activeAnchor);
|
|
1330
|
-
((
|
|
1331
|
-
((
|
|
1398
|
+
((_d = _this.dock) === null || _d === void 0 ? void 0 : _d.xDock) && (pt.x += _this.dock.xDock.step);
|
|
1399
|
+
((_e = _this.dock) === null || _e === void 0 ? void 0 : _e.yDock) && (pt.y += _this.dock.yDock.step);
|
|
1332
1400
|
}
|
|
1333
1401
|
_this.moveLineAnchor(pt, e);
|
|
1334
1402
|
return;
|
|
@@ -1368,7 +1436,7 @@ var Canvas = /** @class */ (function () {
|
|
|
1368
1436
|
if (_this.store.active.length === 1) {
|
|
1369
1437
|
var activePen = _this.store.active[0];
|
|
1370
1438
|
if (activePen.locked === undefined || activePen.locked < LockState.DisableMove) {
|
|
1371
|
-
(
|
|
1439
|
+
(_f = activePen === null || activePen === void 0 ? void 0 : activePen.onMouseMove) === null || _f === void 0 ? void 0 : _f.call(activePen, activePen, _this.mousePos);
|
|
1372
1440
|
}
|
|
1373
1441
|
if (activePen.calculative.focus) {
|
|
1374
1442
|
//执行图元的操作
|
|
@@ -1399,8 +1467,8 @@ var Canvas = /** @class */ (function () {
|
|
|
1399
1467
|
!_this.store.options.disableLineDock) {
|
|
1400
1468
|
_this.clearDock();
|
|
1401
1469
|
_this.dock = calcAnchorDock(_this.store, pt);
|
|
1402
|
-
((
|
|
1403
|
-
((
|
|
1470
|
+
((_g = _this.dock) === null || _g === void 0 ? void 0 : _g.xDock) && (pt.x += _this.dock.xDock.step);
|
|
1471
|
+
((_h = _this.dock) === null || _h === void 0 ? void 0 : _h.yDock) && (pt.y += _this.dock.yDock.step);
|
|
1404
1472
|
}
|
|
1405
1473
|
if (_this.mouseDown &&
|
|
1406
1474
|
_this.drawingLineName === 'curve' &&
|
|
@@ -1629,22 +1697,27 @@ var Canvas = /** @class */ (function () {
|
|
|
1629
1697
|
});
|
|
1630
1698
|
_this.patchFlagsLines.clear();
|
|
1631
1699
|
if (_this.dragRect) {
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1700
|
+
if (_this.canvasImage.fitFlag) {
|
|
1701
|
+
_this.makeFit();
|
|
1702
|
+
}
|
|
1703
|
+
else {
|
|
1704
|
+
var pens = _this.store.data.pens.filter(function (pen) {
|
|
1705
|
+
if (pen.visible === false ||
|
|
1706
|
+
pen.locked >= LockState.DisableMove ||
|
|
1707
|
+
pen.parentId || pen.isRuleLine) {
|
|
1708
|
+
return false;
|
|
1709
|
+
}
|
|
1710
|
+
if (rectInRect(pen.calculative.worldRect, _this.dragRect, e.ctrlKey || _this.store.options.dragAllIn)) {
|
|
1711
|
+
// 先判断在区域内,若不在区域内,则锚点肯定不在框选区域内,避免每条连线过度计算
|
|
1712
|
+
if (pen.type === PenType.Line && !_this.store.options.dragAllIn) {
|
|
1713
|
+
return lineInRect(pen, _this.dragRect);
|
|
1714
|
+
}
|
|
1715
|
+
return true;
|
|
1642
1716
|
}
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
_this.active(pens);
|
|
1717
|
+
});
|
|
1718
|
+
//框选
|
|
1719
|
+
_this.active(pens);
|
|
1720
|
+
}
|
|
1648
1721
|
}
|
|
1649
1722
|
if (e.button !== 2) {
|
|
1650
1723
|
if (distance(_this.mouseDown, e) < 2) {
|
|
@@ -1657,6 +1730,9 @@ var Canvas = /** @class */ (function () {
|
|
|
1657
1730
|
pen: _this.store.hover,
|
|
1658
1731
|
});
|
|
1659
1732
|
}
|
|
1733
|
+
if (_this.store.hover) {
|
|
1734
|
+
_this.store.hover.calculative.mouseDown = false;
|
|
1735
|
+
}
|
|
1660
1736
|
_this.store.emitter.emit('mouseup', {
|
|
1661
1737
|
x: e.x,
|
|
1662
1738
|
y: e.y,
|
|
@@ -1671,7 +1747,10 @@ var Canvas = /** @class */ (function () {
|
|
|
1671
1747
|
if (_this.willInactivePen) {
|
|
1672
1748
|
_this.willInactivePen.calculative.active = undefined;
|
|
1673
1749
|
setChildrenActive(_this.willInactivePen, false); // 子节点取消激活
|
|
1674
|
-
_this.store.active.
|
|
1750
|
+
var index = _this.store.active.findIndex(function (p) { return p === _this.willInactivePen; });
|
|
1751
|
+
if (index >= 0) {
|
|
1752
|
+
_this.store.active.splice(index, 1);
|
|
1753
|
+
}
|
|
1675
1754
|
_this.calcActiveRect();
|
|
1676
1755
|
_this.willInactivePen = undefined;
|
|
1677
1756
|
_this.store.emitter.emit('inactive', [_this.willInactivePen]);
|
|
@@ -1788,6 +1867,9 @@ var Canvas = /** @class */ (function () {
|
|
|
1788
1867
|
if (_this.dragRect) {
|
|
1789
1868
|
return;
|
|
1790
1869
|
}
|
|
1870
|
+
if (_this.canvasImage.fitFlag) {
|
|
1871
|
+
return;
|
|
1872
|
+
}
|
|
1791
1873
|
var hoverType = HoverType.None;
|
|
1792
1874
|
_this.store.hover = undefined;
|
|
1793
1875
|
_this.store.hoverAnchor = undefined;
|
|
@@ -2839,7 +2921,7 @@ var Canvas = /** @class */ (function () {
|
|
|
2839
2921
|
var e_6, _a;
|
|
2840
2922
|
_this.clearDropdownList();
|
|
2841
2923
|
var pen = _this.store.pens[_this.inputDiv.dataset.penId];
|
|
2842
|
-
if (!_this.store.data.locked && !['
|
|
2924
|
+
if (!_this.store.data.locked && !['tablePlus'].includes(pen.name)) {
|
|
2843
2925
|
return;
|
|
2844
2926
|
}
|
|
2845
2927
|
_this.dropdown.style.display = 'block';
|
|
@@ -2930,6 +3012,36 @@ var Canvas = /** @class */ (function () {
|
|
|
2930
3012
|
_this.render();
|
|
2931
3013
|
_this.store.emitter.emit('valueUpdate', pen);
|
|
2932
3014
|
};
|
|
3015
|
+
this.inFitBorder = function (pt) {
|
|
3016
|
+
var current = undefined;
|
|
3017
|
+
var width = (_this.store.data.width || _this.store.options.width);
|
|
3018
|
+
var height = (_this.store.data.height || _this.store.options.height);
|
|
3019
|
+
var point = {
|
|
3020
|
+
x: (pt.x - _this.store.data.origin.x) / _this.store.data.scale,
|
|
3021
|
+
y: (pt.y - _this.store.data.origin.y) / _this.store.data.scale,
|
|
3022
|
+
};
|
|
3023
|
+
var fit = _this.canvasImage.activeFit;
|
|
3024
|
+
// if (pointInRect(point, { x:fit.x-0.01, y:0, width, height })) {
|
|
3025
|
+
_this.externalElements.style.cursor = 'default';
|
|
3026
|
+
if (point.y > height * fit.y - 10 && point.y < height * fit.y + 10) {
|
|
3027
|
+
current = 'top';
|
|
3028
|
+
_this.externalElements.style.cursor = 'row-resize';
|
|
3029
|
+
}
|
|
3030
|
+
if (point.y > height * (fit.y + fit.height) - 10 && point.y < height * (fit.y + fit.height) + 10) {
|
|
3031
|
+
current = 'bottom';
|
|
3032
|
+
_this.externalElements.style.cursor = 'row-resize';
|
|
3033
|
+
}
|
|
3034
|
+
if (point.x > width * fit.x - 10 && point.x < width * fit.x) {
|
|
3035
|
+
current = 'left';
|
|
3036
|
+
_this.externalElements.style.cursor = 'col-resize';
|
|
3037
|
+
}
|
|
3038
|
+
if (point.x > width * (fit.x + fit.width) - 10 && point.x < width * (fit.x + fit.width) + 10) {
|
|
3039
|
+
current = 'right';
|
|
3040
|
+
_this.externalElements.style.cursor = 'col-resize';
|
|
3041
|
+
}
|
|
3042
|
+
// }
|
|
3043
|
+
_this.canvasImage.currentFit = current;
|
|
3044
|
+
};
|
|
2933
3045
|
this.canvasTemplate = new CanvasTemplate(parentElement, store);
|
|
2934
3046
|
this.canvasTemplate.canvas.style.zIndex = '1';
|
|
2935
3047
|
this.canvasImageBottom = new CanvasImage(parentElement, store, true);
|
|
@@ -3270,14 +3382,14 @@ var Canvas = /** @class */ (function () {
|
|
|
3270
3382
|
}
|
|
3271
3383
|
if (pen.dataset) {
|
|
3272
3384
|
if (num % 2 === 0) {
|
|
3273
|
-
lastW = pen.width
|
|
3385
|
+
lastW = pen.width - 40 * this.store.data.scale;
|
|
3274
3386
|
}
|
|
3275
3387
|
else {
|
|
3276
3388
|
lastW = 0;
|
|
3277
3389
|
}
|
|
3278
3390
|
num++;
|
|
3279
3391
|
if (num % 2 === 0) {
|
|
3280
|
-
lastH += pen.height + 10;
|
|
3392
|
+
lastH += pen.height + 10 * this.store.data.scale;
|
|
3281
3393
|
}
|
|
3282
3394
|
}
|
|
3283
3395
|
}
|
|
@@ -3671,6 +3783,7 @@ var Canvas = /** @class */ (function () {
|
|
|
3671
3783
|
pen.calculative.initRect.ey =
|
|
3672
3784
|
pen.calculative.y + pen.calculative.height;
|
|
3673
3785
|
}
|
|
3786
|
+
calcChildrenInitRect(pen);
|
|
3674
3787
|
});
|
|
3675
3788
|
// active 消息表示拖拽结束
|
|
3676
3789
|
// this.store.emitter.emit('active', this.store.active);
|
|
@@ -4468,6 +4581,11 @@ var Canvas = /** @class */ (function () {
|
|
|
4468
4581
|
}
|
|
4469
4582
|
globalStore.anchors[pen.name](pen);
|
|
4470
4583
|
}
|
|
4584
|
+
if (!pen.anchors) {
|
|
4585
|
+
var anchors = deepClone(this.store.options.defaultAnchors);
|
|
4586
|
+
anchors.forEach(function (item, index) { item.id = "" + index; item.penId = pen.id; });
|
|
4587
|
+
pen.anchors = anchors;
|
|
4588
|
+
}
|
|
4471
4589
|
this.updatePenRect(pen);
|
|
4472
4590
|
if (!pen.anchors && pen.calculative.worldAnchors) {
|
|
4473
4591
|
pen.anchors = pen.calculative.worldAnchors.map(function (pt) {
|
|
@@ -5465,7 +5583,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5465
5583
|
};
|
|
5466
5584
|
Canvas.prototype.moveLineAnchor = function (pt, keyOptions) {
|
|
5467
5585
|
var _this = this;
|
|
5468
|
-
var _a, _b, _c, _d;
|
|
5586
|
+
var _a, _b, _c, _d, _e;
|
|
5469
5587
|
if (!this.activeRect || this.store.data.locked) {
|
|
5470
5588
|
return;
|
|
5471
5589
|
}
|
|
@@ -5476,8 +5594,8 @@ var Canvas = /** @class */ (function () {
|
|
|
5476
5594
|
var pen = this.store.pens[this.store.activeAnchor.connectTo];
|
|
5477
5595
|
disconnectLine(pen, getAnchor(pen, this.store.activeAnchor.anchorId), this.store.pens[this.store.activeAnchor.penId], this.store.activeAnchor);
|
|
5478
5596
|
}
|
|
5479
|
-
var anchorId = this.store.activeAnchor.id;
|
|
5480
|
-
var connectedLine = (
|
|
5597
|
+
var anchorId = (_b = this.store.activeAnchor) === null || _b === void 0 ? void 0 : _b.id;
|
|
5598
|
+
var connectedLine = (_d = (_c = this.store.pens[this.store.activeAnchor.penId]) === null || _c === void 0 ? void 0 : _c.connectedLines) === null || _d === void 0 ? void 0 : _d.filter(function (item) { return item.anchor === anchorId; });
|
|
5481
5599
|
if (connectedLine && connectedLine.length > 0) {
|
|
5482
5600
|
connectedLine.forEach(function (connected) {
|
|
5483
5601
|
var pen = _this.store.pens[connected.lineId];
|
|
@@ -5557,7 +5675,7 @@ var Canvas = /** @class */ (function () {
|
|
|
5557
5675
|
to.prev = undefined;
|
|
5558
5676
|
// 重新自动计算连线
|
|
5559
5677
|
if (line.lineName !== 'polyline') {
|
|
5560
|
-
(
|
|
5678
|
+
(_e = this[line.lineName]) === null || _e === void 0 ? void 0 : _e.call(this, this.store, line);
|
|
5561
5679
|
}
|
|
5562
5680
|
}
|
|
5563
5681
|
}
|
|
@@ -6934,7 +7052,7 @@ var Canvas = /** @class */ (function () {
|
|
|
6934
7052
|
};
|
|
6935
7053
|
this.inputDiv.oninput = function (e) {
|
|
6936
7054
|
var pen = _this.store.pens[_this.inputDiv.dataset.penId];
|
|
6937
|
-
if (pen.inputType === 'number') {
|
|
7055
|
+
if (pen && pen.inputType === 'number') {
|
|
6938
7056
|
var value = e.target.innerText;
|
|
6939
7057
|
var numericValue = value.replace(/[^0-9]/g, ''); // 移除非数字字符
|
|
6940
7058
|
// 如果输入的值不是纯数字,则替换为纯数字
|
|
@@ -7040,7 +7158,7 @@ var Canvas = /** @class */ (function () {
|
|
|
7040
7158
|
};
|
|
7041
7159
|
Canvas.prototype.changePenId = function (oldId, newId) {
|
|
7042
7160
|
var _this = this;
|
|
7043
|
-
var _a, _b, _c, _d, _e;
|
|
7161
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7044
7162
|
if (oldId === newId) {
|
|
7045
7163
|
return;
|
|
7046
7164
|
}
|
|
@@ -7080,6 +7198,9 @@ var Canvas = /** @class */ (function () {
|
|
|
7080
7198
|
calcWorldAnchors(line);
|
|
7081
7199
|
});
|
|
7082
7200
|
}
|
|
7201
|
+
//锚点
|
|
7202
|
+
(_f = pen.anchors) === null || _f === void 0 ? void 0 : _f.forEach(function (anchor) { return anchor.penId = newId; });
|
|
7203
|
+
(_g = pen.calculative.worldAnchors) === null || _g === void 0 ? void 0 : _g.forEach(function (anchor) { return anchor.penId = newId; });
|
|
7083
7204
|
};
|
|
7084
7205
|
Canvas.prototype.updateValue = function (pen, data) {
|
|
7085
7206
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -7127,6 +7248,9 @@ var Canvas = /** @class */ (function () {
|
|
|
7127
7248
|
if (needCalcIconRectProps.includes(k)) {
|
|
7128
7249
|
willCalcIconRect = true;
|
|
7129
7250
|
}
|
|
7251
|
+
if (pen.image && pen.name !== 'gif' && ['globalAlpha', 'flipY', 'flipX', 'x', 'y', 'width', 'height'].includes(k)) {
|
|
7252
|
+
willRenderImage = true;
|
|
7253
|
+
}
|
|
7130
7254
|
}
|
|
7131
7255
|
else {
|
|
7132
7256
|
// 复合属性,如abc.def.ghi
|
|
@@ -7435,11 +7559,11 @@ var Canvas = /** @class */ (function () {
|
|
|
7435
7559
|
}
|
|
7436
7560
|
return canvas.toDataURL();
|
|
7437
7561
|
};
|
|
7438
|
-
Canvas.prototype.activeToPng = function (padding) {
|
|
7562
|
+
Canvas.prototype.activeToPng = function (padding, maxWidth) {
|
|
7439
7563
|
if (padding === void 0) { padding = 2; }
|
|
7440
|
-
return this.pensToPng(this.store.active, padding);
|
|
7564
|
+
return this.pensToPng(this.store.active, padding, maxWidth);
|
|
7441
7565
|
};
|
|
7442
|
-
Canvas.prototype.pensToPng = function (pens, padding) {
|
|
7566
|
+
Canvas.prototype.pensToPng = function (pens, padding, maxWidth) {
|
|
7443
7567
|
var e_26, _a;
|
|
7444
7568
|
if (pens === void 0) { pens = this.store.active; }
|
|
7445
7569
|
if (padding === void 0) { padding = 2; }
|
|
@@ -7459,6 +7583,9 @@ var Canvas = /** @class */ (function () {
|
|
|
7459
7583
|
rect.width += p[3] + p[1];
|
|
7460
7584
|
rect.height += p[0] + p[2];
|
|
7461
7585
|
calcRightBottom(rect);
|
|
7586
|
+
var scale = (maxWidth || rect.width) / rect.width;
|
|
7587
|
+
rect.width *= scale;
|
|
7588
|
+
rect.height *= scale;
|
|
7462
7589
|
var canvas = document.createElement('canvas');
|
|
7463
7590
|
canvas.width = rect.width;
|
|
7464
7591
|
canvas.height = rect.height;
|
|
@@ -7472,8 +7599,17 @@ var Canvas = /** @class */ (function () {
|
|
|
7472
7599
|
}
|
|
7473
7600
|
var ctx = canvas.getContext('2d');
|
|
7474
7601
|
ctx.textBaseline = 'middle'; // 默认垂直居中
|
|
7602
|
+
ctx.scale(scale, scale);
|
|
7603
|
+
var background = this.store.data.background || this.store.options.background;
|
|
7604
|
+
if (background) {
|
|
7605
|
+
// 绘制背景颜色
|
|
7606
|
+
ctx.save();
|
|
7607
|
+
ctx.fillStyle = background;
|
|
7608
|
+
ctx.fillRect(0, 0, oldRect.width + (p[3] + p[1]), oldRect.height + (p[0] + p[2]));
|
|
7609
|
+
ctx.restore();
|
|
7610
|
+
}
|
|
7475
7611
|
// // 平移画布,画笔的 worldRect 不变化
|
|
7476
|
-
ctx.translate(-oldRect.x, -oldRect.y);
|
|
7612
|
+
ctx.translate(-oldRect.x + p[3], -oldRect.y + p[0]);
|
|
7477
7613
|
try {
|
|
7478
7614
|
for (var _b = __values(this.store.data.pens), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7479
7615
|
var pen = _c.value;
|
|
@@ -7602,6 +7738,17 @@ var Canvas = /** @class */ (function () {
|
|
|
7602
7738
|
if (!isFinite(rect.width)) {
|
|
7603
7739
|
throw new Error('can not move view, because width is not finite');
|
|
7604
7740
|
}
|
|
7741
|
+
var width = this.store.data.width || this.store.options.width;
|
|
7742
|
+
var height = this.store.data.height || this.store.options.height;
|
|
7743
|
+
if (width && height) {
|
|
7744
|
+
//大屏
|
|
7745
|
+
rect = {
|
|
7746
|
+
x: this.store.data.origin.x,
|
|
7747
|
+
y: this.store.data.origin.y,
|
|
7748
|
+
width: width * this.store.data.scale,
|
|
7749
|
+
height: height * this.store.data.scale,
|
|
7750
|
+
};
|
|
7751
|
+
}
|
|
7605
7752
|
this.store.data.x = this.canvas.clientWidth / 2 - x * rect.width - rect.x;
|
|
7606
7753
|
this.store.data.y = this.canvas.clientHeight / 2 - y * rect.height - rect.y;
|
|
7607
7754
|
this.onMovePens();
|
|
@@ -7620,6 +7767,341 @@ var Canvas = /** @class */ (function () {
|
|
|
7620
7767
|
this.externalElements.style.cursor = 'default';
|
|
7621
7768
|
this.render();
|
|
7622
7769
|
};
|
|
7770
|
+
Canvas.prototype.showFit = function () {
|
|
7771
|
+
this.store.data.locked = 0;
|
|
7772
|
+
this.canvasImage.fitFlag = true;
|
|
7773
|
+
this.canvasImage.activeFit = undefined;
|
|
7774
|
+
this.canvasImage.currentFit = undefined;
|
|
7775
|
+
if (!this.store.data.fits) {
|
|
7776
|
+
this.store.data.fits = [];
|
|
7777
|
+
}
|
|
7778
|
+
this.store.data.fits.forEach(function (fit) { return fit.active = false; });
|
|
7779
|
+
this.canvasImage.init();
|
|
7780
|
+
this.canvasImage.render();
|
|
7781
|
+
};
|
|
7782
|
+
Canvas.prototype.hideFit = function () {
|
|
7783
|
+
this.canvasImage.fitFlag = false;
|
|
7784
|
+
this.canvasImage.activeFit = undefined;
|
|
7785
|
+
this.canvasImage.currentFit = undefined;
|
|
7786
|
+
this.canvasImage.init();
|
|
7787
|
+
this.canvasImage.render();
|
|
7788
|
+
};
|
|
7789
|
+
Canvas.prototype.makeFit = function () {
|
|
7790
|
+
var _this = this;
|
|
7791
|
+
if (this.dragRect.width < 100 && this.dragRect.height < 100) {
|
|
7792
|
+
return;
|
|
7793
|
+
}
|
|
7794
|
+
//将所有当前框选的图元设置到该容器中
|
|
7795
|
+
var pens = this.store.data.pens.filter(function (pen) {
|
|
7796
|
+
if (
|
|
7797
|
+
// pen.locked >= LockState.DisableMove ||
|
|
7798
|
+
pen.parentId || pen.isRuleLine) {
|
|
7799
|
+
return false;
|
|
7800
|
+
}
|
|
7801
|
+
if (rectInRect(pen.calculative.worldRect, _this.dragRect, true)) {
|
|
7802
|
+
// 先判断在区域内,若不在区域内,则锚点肯定不在框选区域内,避免每条连线过度计算
|
|
7803
|
+
if (pen.type === PenType.Line && !_this.store.options.dragAllIn) {
|
|
7804
|
+
return lineInRect(pen, _this.dragRect);
|
|
7805
|
+
}
|
|
7806
|
+
return true;
|
|
7807
|
+
}
|
|
7808
|
+
});
|
|
7809
|
+
if (!pens.length) {
|
|
7810
|
+
return;
|
|
7811
|
+
}
|
|
7812
|
+
var _rect = this.parent.getRect(pens);
|
|
7813
|
+
var scale = this.store.data.scale;
|
|
7814
|
+
var width = this.store.data.width || this.store.options.width;
|
|
7815
|
+
var height = this.store.data.height || this.store.options.height;
|
|
7816
|
+
var x = (Math.floor(_rect.x) - this.store.data.origin.x) / scale / width;
|
|
7817
|
+
var y = (Math.floor(_rect.y) - this.store.data.origin.y) / scale / height;
|
|
7818
|
+
var rect = {
|
|
7819
|
+
x: x,
|
|
7820
|
+
y: y,
|
|
7821
|
+
width: (Math.ceil(_rect.width) + 1) / scale / width,
|
|
7822
|
+
height: (Math.ceil(_rect.height) + 1) / scale / height,
|
|
7823
|
+
children: pens.map(function (pen) { return pen.id; }),
|
|
7824
|
+
id: s8(),
|
|
7825
|
+
active: true
|
|
7826
|
+
};
|
|
7827
|
+
if (rect.x < -0.1) {
|
|
7828
|
+
rect.x = -0.1;
|
|
7829
|
+
}
|
|
7830
|
+
if (rect.y < -0.1) {
|
|
7831
|
+
rect.y = -0.1;
|
|
7832
|
+
}
|
|
7833
|
+
if (rect.width > 0.5) {
|
|
7834
|
+
rect.left = true;
|
|
7835
|
+
rect.right = true;
|
|
7836
|
+
rect.leftValue = (rect.x - 0) * scale * width;
|
|
7837
|
+
rect.rightValue = (1 - (rect.x + rect.width)) * scale * width;
|
|
7838
|
+
}
|
|
7839
|
+
else {
|
|
7840
|
+
if (rect.x < 0.5) {
|
|
7841
|
+
rect.left = true;
|
|
7842
|
+
rect.leftValue = (rect.x - 0) * scale * width;
|
|
7843
|
+
}
|
|
7844
|
+
else {
|
|
7845
|
+
rect.right = true;
|
|
7846
|
+
rect.rightValue = (1 - (rect.x + rect.width)) * scale * width;
|
|
7847
|
+
}
|
|
7848
|
+
}
|
|
7849
|
+
if (rect.leftValue < 1) {
|
|
7850
|
+
rect.leftValue = 0;
|
|
7851
|
+
}
|
|
7852
|
+
if (rect.rightValue < 1) {
|
|
7853
|
+
rect.rightValue = 0;
|
|
7854
|
+
}
|
|
7855
|
+
if (rect.height > 0.5) {
|
|
7856
|
+
rect.top = true;
|
|
7857
|
+
rect.bottom = true;
|
|
7858
|
+
rect.topValue = (rect.y - 0) * scale * height;
|
|
7859
|
+
rect.bottomValue = (1 - (rect.y + rect.height)) * scale * height;
|
|
7860
|
+
}
|
|
7861
|
+
else {
|
|
7862
|
+
if (rect.y < 0.5) {
|
|
7863
|
+
rect.top = true;
|
|
7864
|
+
rect.topValue = (rect.y - 0) * scale * height;
|
|
7865
|
+
}
|
|
7866
|
+
else {
|
|
7867
|
+
rect.bottom = true;
|
|
7868
|
+
rect.bottomValue = (1 - (rect.y + rect.height)) * scale * height;
|
|
7869
|
+
}
|
|
7870
|
+
}
|
|
7871
|
+
if (rect.topValue < 1) {
|
|
7872
|
+
rect.topValue = 0;
|
|
7873
|
+
}
|
|
7874
|
+
if (rect.bottomValue < 1) {
|
|
7875
|
+
rect.bottomValue = 0;
|
|
7876
|
+
}
|
|
7877
|
+
if (!this.store.data.fits) {
|
|
7878
|
+
this.store.data.fits = [];
|
|
7879
|
+
}
|
|
7880
|
+
this.store.data.fits.forEach(function (fit) { fit.active = false; });
|
|
7881
|
+
this.store.data.fits.push(rect);
|
|
7882
|
+
this.canvasImage.activeFit = rect;
|
|
7883
|
+
this.store.emitter.emit('fit', rect);
|
|
7884
|
+
this.canvasImage.init();
|
|
7885
|
+
this.canvasImage.render();
|
|
7886
|
+
};
|
|
7887
|
+
Canvas.prototype.updateFit = function (e) {
|
|
7888
|
+
var _this = this;
|
|
7889
|
+
var scale = this.store.data.scale;
|
|
7890
|
+
var width = this.store.data.width || this.store.options.width;
|
|
7891
|
+
var height = this.store.data.height || this.store.options.height;
|
|
7892
|
+
var x = (e.x - this.store.data.origin.x) / scale / width;
|
|
7893
|
+
var y = (e.y - this.store.data.origin.y) / scale / height;
|
|
7894
|
+
if (this.canvasImage.currentFit) {
|
|
7895
|
+
var fit = this.canvasImage.activeFit;
|
|
7896
|
+
if (this.canvasImage.currentFit === 'top') {
|
|
7897
|
+
if (y < -0.1) {
|
|
7898
|
+
y = -0.1;
|
|
7899
|
+
}
|
|
7900
|
+
var gap = y - fit.y;
|
|
7901
|
+
fit.height -= gap;
|
|
7902
|
+
if (fit.height < 0.01) {
|
|
7903
|
+
fit.height = 0.01;
|
|
7904
|
+
return;
|
|
7905
|
+
}
|
|
7906
|
+
fit.y = y;
|
|
7907
|
+
}
|
|
7908
|
+
if (this.canvasImage.currentFit === 'bottom') {
|
|
7909
|
+
if (y > 1.1) {
|
|
7910
|
+
y = 1.1;
|
|
7911
|
+
}
|
|
7912
|
+
fit.height = y - fit.y;
|
|
7913
|
+
if (fit.height <= 0.01) {
|
|
7914
|
+
fit.height = 0.01;
|
|
7915
|
+
}
|
|
7916
|
+
}
|
|
7917
|
+
if (this.canvasImage.currentFit === 'left') {
|
|
7918
|
+
if (x < -0.1) {
|
|
7919
|
+
x = -0.1;
|
|
7920
|
+
}
|
|
7921
|
+
var gap = x - fit.x;
|
|
7922
|
+
fit.width -= gap;
|
|
7923
|
+
if (fit.width < 0.01) {
|
|
7924
|
+
fit.width = 0.01;
|
|
7925
|
+
return;
|
|
7926
|
+
}
|
|
7927
|
+
fit.x = x;
|
|
7928
|
+
}
|
|
7929
|
+
if (this.canvasImage.currentFit === 'right') {
|
|
7930
|
+
if (x > 1.1) {
|
|
7931
|
+
x = 1.1;
|
|
7932
|
+
}
|
|
7933
|
+
fit.width = x - fit.x;
|
|
7934
|
+
if (fit.width <= 0.01) {
|
|
7935
|
+
fit.width = 0.01;
|
|
7936
|
+
}
|
|
7937
|
+
}
|
|
7938
|
+
var rect_2 = {
|
|
7939
|
+
x: fit.x * width * scale + this.store.data.origin.x,
|
|
7940
|
+
y: fit.y * height * scale + this.store.data.origin.y,
|
|
7941
|
+
width: fit.width * width * scale,
|
|
7942
|
+
height: fit.height * height * scale,
|
|
7943
|
+
};
|
|
7944
|
+
calcRightBottom(rect_2);
|
|
7945
|
+
var pens = this.store.data.pens.filter(function (pen) {
|
|
7946
|
+
if (
|
|
7947
|
+
// pen.locked >= LockState.DisableMove ||
|
|
7948
|
+
pen.parentId || pen.isRuleLine) {
|
|
7949
|
+
return false;
|
|
7950
|
+
}
|
|
7951
|
+
if (rectInRect(pen.calculative.worldRect, rect_2, true)) {
|
|
7952
|
+
if (pen.type === PenType.Line && !_this.store.options.dragAllIn) {
|
|
7953
|
+
return lineInRect(pen, rect_2);
|
|
7954
|
+
}
|
|
7955
|
+
return true;
|
|
7956
|
+
}
|
|
7957
|
+
});
|
|
7958
|
+
fit.left = undefined;
|
|
7959
|
+
fit.leftValue = undefined;
|
|
7960
|
+
fit.right = undefined;
|
|
7961
|
+
fit.rightValue = undefined;
|
|
7962
|
+
fit.top = undefined;
|
|
7963
|
+
fit.topValue = undefined;
|
|
7964
|
+
fit.bottom = undefined;
|
|
7965
|
+
fit.bottomValue = undefined;
|
|
7966
|
+
if (fit.width > 0.5) {
|
|
7967
|
+
fit.left = true;
|
|
7968
|
+
fit.right = true;
|
|
7969
|
+
fit.leftValue = (fit.x - 0) * scale * width;
|
|
7970
|
+
fit.rightValue = ((1 - (fit.x + fit.width)) * scale * width);
|
|
7971
|
+
}
|
|
7972
|
+
else {
|
|
7973
|
+
if (fit.x < 0.5) {
|
|
7974
|
+
fit.left = true;
|
|
7975
|
+
fit.leftValue = (fit.x - 0) * scale * width;
|
|
7976
|
+
}
|
|
7977
|
+
else {
|
|
7978
|
+
fit.right = true;
|
|
7979
|
+
fit.rightValue = ((1 - (fit.x + fit.width)) * scale * width);
|
|
7980
|
+
}
|
|
7981
|
+
}
|
|
7982
|
+
if (Math.abs(fit.leftValue) < 1) {
|
|
7983
|
+
fit.leftValue = 0;
|
|
7984
|
+
}
|
|
7985
|
+
if (Math.abs(fit.rightValue) < 1) {
|
|
7986
|
+
fit.rightValue = 0;
|
|
7987
|
+
}
|
|
7988
|
+
if (fit.height > 0.5) {
|
|
7989
|
+
fit.top = true;
|
|
7990
|
+
fit.bottom = true;
|
|
7991
|
+
fit.topValue = (fit.y - 0) * scale * height;
|
|
7992
|
+
fit.bottomValue = (1 - (fit.y + fit.height)) * scale * height;
|
|
7993
|
+
}
|
|
7994
|
+
else {
|
|
7995
|
+
if (fit.y < 0.5) {
|
|
7996
|
+
fit.top = true;
|
|
7997
|
+
fit.topValue = (fit.y - 0) * scale * height;
|
|
7998
|
+
}
|
|
7999
|
+
else {
|
|
8000
|
+
fit.bottom = true;
|
|
8001
|
+
fit.bottomValue = (1 - (fit.y + fit.height)) * scale * height;
|
|
8002
|
+
}
|
|
8003
|
+
}
|
|
8004
|
+
if (Math.abs(fit.topValue) < 1) {
|
|
8005
|
+
fit.topValue = 0;
|
|
8006
|
+
}
|
|
8007
|
+
if (Math.abs(fit.bottomValue) < 1) {
|
|
8008
|
+
fit.bottomValue = 0;
|
|
8009
|
+
}
|
|
8010
|
+
fit.children = pens.map(function (pen) { return pen.id; });
|
|
8011
|
+
this.store.emitter.emit('fit', fit);
|
|
8012
|
+
this.mouseDown.x = e.x;
|
|
8013
|
+
this.mouseDown.y = e.y;
|
|
8014
|
+
this.canvasImage.init();
|
|
8015
|
+
this.canvasImage.render();
|
|
8016
|
+
}
|
|
8017
|
+
};
|
|
8018
|
+
Canvas.prototype.updateFitRect = function (fit) {
|
|
8019
|
+
if (fit === void 0) { fit = this.canvasImage.activeFit; }
|
|
8020
|
+
var width = this.store.data.width || this.store.options.width;
|
|
8021
|
+
var height = this.store.data.height || this.store.options.height;
|
|
8022
|
+
if (fit.left) {
|
|
8023
|
+
if (fit.leftValue) {
|
|
8024
|
+
fit.x = Math.abs(fit.leftValue) < 1 ? fit.leftValue : fit.leftValue / width;
|
|
8025
|
+
}
|
|
8026
|
+
else {
|
|
8027
|
+
fit.x = 0;
|
|
8028
|
+
}
|
|
8029
|
+
}
|
|
8030
|
+
if (fit.right) {
|
|
8031
|
+
if (fit.rightValue) {
|
|
8032
|
+
fit.width = 1 - (Math.abs(fit.rightValue) < 1 ? fit.rightValue : fit.rightValue / width) - fit.x;
|
|
8033
|
+
}
|
|
8034
|
+
else {
|
|
8035
|
+
fit.width = 1 - fit.x;
|
|
8036
|
+
}
|
|
8037
|
+
}
|
|
8038
|
+
if (fit.top) {
|
|
8039
|
+
if (fit.topValue) {
|
|
8040
|
+
fit.y = Math.abs(fit.topValue) < 1 ? fit.topValue : fit.topValue / height;
|
|
8041
|
+
}
|
|
8042
|
+
else {
|
|
8043
|
+
fit.y = 0;
|
|
8044
|
+
}
|
|
8045
|
+
}
|
|
8046
|
+
if (fit.bottom) {
|
|
8047
|
+
if (fit.bottomValue) {
|
|
8048
|
+
fit.height = 1 - (Math.abs(fit.bottomValue) < 1 ? fit.bottomValue : fit.bottomValue / height) - fit.y;
|
|
8049
|
+
}
|
|
8050
|
+
else {
|
|
8051
|
+
fit.height = 1 - fit.y;
|
|
8052
|
+
}
|
|
8053
|
+
}
|
|
8054
|
+
this.canvasImage.init();
|
|
8055
|
+
this.canvasImage.render();
|
|
8056
|
+
};
|
|
8057
|
+
Canvas.prototype.deleteFit = function (fit) {
|
|
8058
|
+
if (fit === void 0) { fit = this.canvasImage.activeFit; }
|
|
8059
|
+
if (!fit) {
|
|
8060
|
+
return;
|
|
8061
|
+
}
|
|
8062
|
+
var index = this.store.data.fits.findIndex(function (item) { return item.id === fit.id; });
|
|
8063
|
+
this.store.data.fits.splice(index, 1);
|
|
8064
|
+
this.canvasImage.activeFit = undefined;
|
|
8065
|
+
this.canvasImage.init();
|
|
8066
|
+
this.canvasImage.render();
|
|
8067
|
+
this.store.emitter.emit('fit', undefined);
|
|
8068
|
+
};
|
|
8069
|
+
Canvas.prototype.calcuActiveFit = function () {
|
|
8070
|
+
var _a;
|
|
8071
|
+
var width = this.store.data.width || this.store.options.width;
|
|
8072
|
+
var height = this.store.data.height || this.store.options.height;
|
|
8073
|
+
var downX = (this.mouseDown.x - this.store.data.origin.x) / this.store.data.scale / width;
|
|
8074
|
+
var downY = (this.mouseDown.y - this.store.data.origin.y) / this.store.data.scale / height;
|
|
8075
|
+
var idx = -1;
|
|
8076
|
+
var lastActiveIdx = -1;
|
|
8077
|
+
(_a = this.store.data.fits) === null || _a === void 0 ? void 0 : _a.forEach(function (fit, index) {
|
|
8078
|
+
fit.ex = null;
|
|
8079
|
+
fit.ey = null;
|
|
8080
|
+
if (pointInRect({ x: downX, y: downY }, fit)) {
|
|
8081
|
+
idx = index;
|
|
8082
|
+
}
|
|
8083
|
+
;
|
|
8084
|
+
if (fit.active) {
|
|
8085
|
+
lastActiveIdx = index;
|
|
8086
|
+
}
|
|
8087
|
+
});
|
|
8088
|
+
if (idx !== -1 && idx !== lastActiveIdx) {
|
|
8089
|
+
this.canvasImage.activeFit = this.store.data.fits[idx];
|
|
8090
|
+
this.store.data.fits[idx].active = true;
|
|
8091
|
+
if (lastActiveIdx !== -1) {
|
|
8092
|
+
this.store.data.fits[lastActiveIdx].active = false;
|
|
8093
|
+
}
|
|
8094
|
+
this.store.emitter.emit('fit', this.store.data.fits[idx]);
|
|
8095
|
+
}
|
|
8096
|
+
else if (idx === -1 && lastActiveIdx !== -1) {
|
|
8097
|
+
this.store.data.fits[lastActiveIdx].active = false;
|
|
8098
|
+
this.store.emitter.emit('fit', undefined);
|
|
8099
|
+
this.canvasImage.activeFit = null;
|
|
8100
|
+
}
|
|
8101
|
+
this.inactive();
|
|
8102
|
+
this.canvasImage.init();
|
|
8103
|
+
this.canvasImage.render();
|
|
8104
|
+
};
|
|
7623
8105
|
Canvas.prototype.toggleMagnifier = function () {
|
|
7624
8106
|
this.magnifierCanvas.magnifier = !this.magnifierCanvas.magnifier;
|
|
7625
8107
|
if (this.magnifierCanvas.magnifier) {
|