@inweb/markup 25.8.1 → 25.8.3
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/markup.js +132 -198
- package/dist/markup.js.map +1 -1
- package/dist/markup.min.js +1 -1
- package/dist/markup.module.js +139 -193
- package/dist/markup.module.js.map +1 -1
- package/lib/markup/Konva/KonvaMarkup.d.ts +0 -2
- package/lib/markup/WorldTransform.d.ts +2 -1
- package/package.json +3 -3
- package/src/markup/Konva/KonvaMarkup.ts +173 -227
- package/src/markup/WorldTransform.ts +3 -1
package/dist/markup.module.js
CHANGED
|
@@ -1017,45 +1017,76 @@ class KonvaMarkup {
|
|
|
1017
1017
|
}
|
|
1018
1018
|
colorizeAllMarkup(r, g, b) {
|
|
1019
1019
|
const hexColor = new MarkupColor(r, g, b).HexColor;
|
|
1020
|
-
this.getObjects().
|
|
1021
|
-
|
|
1022
|
-
|
|
1020
|
+
this.getObjects().filter((obj => {
|
|
1021
|
+
var _a;
|
|
1022
|
+
return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
|
|
1023
1023
|
}));
|
|
1024
|
-
this._konvaLayer.draw();
|
|
1025
1024
|
}
|
|
1026
1025
|
colorizeSelectedMarkups(r, g, b) {
|
|
1027
1026
|
const hexColor = new MarkupColor(r, g, b).HexColor;
|
|
1028
|
-
this.getSelectedObjects().
|
|
1029
|
-
|
|
1030
|
-
|
|
1027
|
+
this.getSelectedObjects().filter((obj => {
|
|
1028
|
+
var _a;
|
|
1029
|
+
return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
|
|
1031
1030
|
}));
|
|
1032
1031
|
}
|
|
1033
1032
|
setViewpoint(viewpoint) {
|
|
1034
|
-
|
|
1033
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1034
|
+
const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || {
|
|
1035
1035
|
r: 255,
|
|
1036
1036
|
g: 0,
|
|
1037
1037
|
b: 0
|
|
1038
1038
|
};
|
|
1039
1039
|
this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
|
|
1040
|
-
|
|
1040
|
+
(_b = viewpoint.lines) === null || _b === void 0 ? void 0 : _b.forEach((line => {
|
|
1041
|
+
const linePoints = [];
|
|
1042
|
+
line.points.forEach((point => {
|
|
1043
|
+
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
1044
|
+
linePoints.push(screenPoint.x);
|
|
1045
|
+
linePoints.push(screenPoint.y);
|
|
1046
|
+
}));
|
|
1047
|
+
this.addLine(linePoints, line.color, line.type, line.width, line.id);
|
|
1048
|
+
}));
|
|
1049
|
+
(_c = viewpoint.texts) === null || _c === void 0 ? void 0 : _c.forEach((text => {
|
|
1050
|
+
const screenPoint = this._worldTransformer.worldToScreen(text.position);
|
|
1051
|
+
this.addText(text.text, screenPoint, text.angle, text.color, text.text_size, text.font_size, text.id);
|
|
1052
|
+
}));
|
|
1053
|
+
(_d = viewpoint.rectangles) === null || _d === void 0 ? void 0 : _d.forEach((rect => {
|
|
1054
|
+
const screenPoint = this._worldTransformer.worldToScreen(rect.position);
|
|
1055
|
+
this.addRectangle(screenPoint, rect.width, rect.height, rect.line_width, rect.color, rect.id);
|
|
1056
|
+
}));
|
|
1057
|
+
(_e = viewpoint.ellipses) === null || _e === void 0 ? void 0 : _e.forEach((ellipse => {
|
|
1058
|
+
const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
|
|
1059
|
+
this.addEllipse(screenPoint, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
|
|
1060
|
+
}));
|
|
1061
|
+
(_f = viewpoint.arrows) === null || _f === void 0 ? void 0 : _f.forEach((arrow => {
|
|
1062
|
+
const startPoint = this._worldTransformer.worldToScreen(arrow.start);
|
|
1063
|
+
const endPoint = this._worldTransformer.worldToScreen(arrow.end);
|
|
1064
|
+
this.addArrow(startPoint, endPoint, arrow.color, arrow.id);
|
|
1065
|
+
}));
|
|
1066
|
+
(_g = viewpoint.clouds) === null || _g === void 0 ? void 0 : _g.forEach((cloud => {
|
|
1067
|
+
const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
|
|
1068
|
+
this.addCloud(screenPoint, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
|
|
1069
|
+
}));
|
|
1070
|
+
(_h = viewpoint.images) === null || _h === void 0 ? void 0 : _h.forEach((image => {
|
|
1071
|
+
const screenPoint = this._worldTransformer.worldToScreen(image.position);
|
|
1072
|
+
this.addImage(screenPoint, image.src, image.width, image.height, image.id);
|
|
1073
|
+
}));
|
|
1041
1074
|
}
|
|
1042
1075
|
getViewpoint() {
|
|
1043
|
-
const viewpoint = {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1076
|
+
const viewpoint = {};
|
|
1077
|
+
viewpoint.lines = this.getMarkupLines();
|
|
1078
|
+
viewpoint.texts = this.getMarkupTexts();
|
|
1079
|
+
viewpoint.arrows = this.getMarkupArrows();
|
|
1080
|
+
viewpoint.clouds = this.getMarkupClouds();
|
|
1081
|
+
viewpoint.ellipses = this.getMarkupEllipses();
|
|
1082
|
+
viewpoint.images = this.getMarkupImages();
|
|
1083
|
+
viewpoint.rectangles = this.getMarkupRectangles();
|
|
1084
|
+
viewpoint.custom_fields = {
|
|
1085
|
+
markup_color: this.getMarkupColor()
|
|
1051
1086
|
};
|
|
1052
1087
|
viewpoint.snapshot = {
|
|
1053
1088
|
data: this.combineMarkupWithDrawing()
|
|
1054
1089
|
};
|
|
1055
|
-
viewpoint.custom_fields = {
|
|
1056
|
-
markup_color: this.getMarkupColor()
|
|
1057
|
-
};
|
|
1058
|
-
this.fillViewpointShapes(viewpoint);
|
|
1059
1090
|
viewpoint.description = (new Date).toDateString();
|
|
1060
1091
|
return viewpoint;
|
|
1061
1092
|
}
|
|
@@ -1101,50 +1132,6 @@ class KonvaMarkup {
|
|
|
1101
1132
|
clearSelected() {
|
|
1102
1133
|
this._konvaTransformer.nodes([]);
|
|
1103
1134
|
}
|
|
1104
|
-
fillViewpointShapes(viewpoint) {
|
|
1105
|
-
const markupLines = this.getMarkupLines();
|
|
1106
|
-
if (markupLines && markupLines.length > 0) {
|
|
1107
|
-
markupLines === null || markupLines === void 0 ? void 0 : markupLines.forEach((line => {
|
|
1108
|
-
viewpoint.lines.push(line);
|
|
1109
|
-
}));
|
|
1110
|
-
}
|
|
1111
|
-
const markupTexts = this.getMarkupTexts();
|
|
1112
|
-
if (markupTexts && markupTexts.length > 0) {
|
|
1113
|
-
markupTexts === null || markupTexts === void 0 ? void 0 : markupTexts.forEach((text => {
|
|
1114
|
-
viewpoint.texts.push(text);
|
|
1115
|
-
}));
|
|
1116
|
-
}
|
|
1117
|
-
const markupRectangles = this.getMarkupRectangles();
|
|
1118
|
-
if (markupRectangles && markupRectangles.length > 0) {
|
|
1119
|
-
markupRectangles === null || markupRectangles === void 0 ? void 0 : markupRectangles.forEach((rectangle => {
|
|
1120
|
-
viewpoint.rectangles.push(rectangle);
|
|
1121
|
-
}));
|
|
1122
|
-
}
|
|
1123
|
-
const markupEllipses = this.getMarkupEllipses();
|
|
1124
|
-
if (markupEllipses && markupEllipses.length > 0) {
|
|
1125
|
-
markupEllipses === null || markupEllipses === void 0 ? void 0 : markupEllipses.forEach((ellipse => {
|
|
1126
|
-
viewpoint.ellipses.push(ellipse);
|
|
1127
|
-
}));
|
|
1128
|
-
}
|
|
1129
|
-
const markupArrows = this.getMarkupArrows();
|
|
1130
|
-
if (markupArrows && markupArrows.length > 0) {
|
|
1131
|
-
markupArrows === null || markupArrows === void 0 ? void 0 : markupArrows.forEach((arrow => {
|
|
1132
|
-
viewpoint.arrows.push(arrow);
|
|
1133
|
-
}));
|
|
1134
|
-
}
|
|
1135
|
-
const markupImages = this.getMarkupImages();
|
|
1136
|
-
if (markupImages && markupImages.length > 0) {
|
|
1137
|
-
markupImages === null || markupImages === void 0 ? void 0 : markupImages.forEach((image => {
|
|
1138
|
-
viewpoint.images.push(image);
|
|
1139
|
-
}));
|
|
1140
|
-
}
|
|
1141
|
-
const markupClouds = this.getMarkupClouds();
|
|
1142
|
-
if (markupClouds && markupClouds.length > 0) {
|
|
1143
|
-
markupClouds === null || markupClouds === void 0 ? void 0 : markupClouds.forEach((cloud => {
|
|
1144
|
-
viewpoint.clouds.push(cloud);
|
|
1145
|
-
}));
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
1135
|
addObject(object) {
|
|
1149
1136
|
this._konvaLayer.add(object.ref());
|
|
1150
1137
|
}
|
|
@@ -1375,11 +1362,11 @@ class KonvaMarkup {
|
|
|
1375
1362
|
}
|
|
1376
1363
|
getMarkupLines() {
|
|
1377
1364
|
const lines = [];
|
|
1378
|
-
this.konvaLayerFind("Line").forEach((
|
|
1379
|
-
const linePoints =
|
|
1365
|
+
this.konvaLayerFind("Line").forEach((ref => {
|
|
1366
|
+
const linePoints = ref.points();
|
|
1380
1367
|
if (!linePoints) return;
|
|
1381
1368
|
const worldPoints = [];
|
|
1382
|
-
const absoluteTransform =
|
|
1369
|
+
const absoluteTransform = ref.getAbsoluteTransform();
|
|
1383
1370
|
for (let i = 0; i < linePoints.length; i += 2) {
|
|
1384
1371
|
const atPoint = absoluteTransform.point({
|
|
1385
1372
|
x: linePoints[i],
|
|
@@ -1388,14 +1375,15 @@ class KonvaMarkup {
|
|
|
1388
1375
|
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
1389
1376
|
worldPoints.push(worldPoint);
|
|
1390
1377
|
}
|
|
1391
|
-
const konvaLine = new KonvaLine(null,
|
|
1392
|
-
|
|
1378
|
+
const konvaLine = new KonvaLine(null, ref);
|
|
1379
|
+
const line = {
|
|
1393
1380
|
id: konvaLine.id(),
|
|
1394
1381
|
points: worldPoints,
|
|
1395
1382
|
color: konvaLine.getColor() || "#ff0000",
|
|
1396
1383
|
type: konvaLine.getLineType() || this.lineType,
|
|
1397
1384
|
width: konvaLine.getLineWidth() || this.lineWidth
|
|
1398
|
-
}
|
|
1385
|
+
};
|
|
1386
|
+
lines.push(line);
|
|
1399
1387
|
}));
|
|
1400
1388
|
return lines;
|
|
1401
1389
|
}
|
|
@@ -1403,15 +1391,14 @@ class KonvaMarkup {
|
|
|
1403
1391
|
const texts = [];
|
|
1404
1392
|
const textSize = .02;
|
|
1405
1393
|
const textScale = this._worldTransformer.getScale();
|
|
1406
|
-
this.konvaLayerFind("Text").forEach((
|
|
1407
|
-
if (!text) return;
|
|
1394
|
+
this.konvaLayerFind("Text").forEach((ref => {
|
|
1408
1395
|
const position = {
|
|
1409
|
-
x:
|
|
1410
|
-
y:
|
|
1396
|
+
x: ref.x(),
|
|
1397
|
+
y: ref.y()
|
|
1411
1398
|
};
|
|
1412
1399
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
1413
|
-
const shape = new KonvaText(null,
|
|
1414
|
-
|
|
1400
|
+
const shape = new KonvaText(null, ref);
|
|
1401
|
+
const text = {
|
|
1415
1402
|
id: shape.id(),
|
|
1416
1403
|
position: worldPoint,
|
|
1417
1404
|
text: shape.getText(),
|
|
@@ -1419,140 +1406,109 @@ class KonvaMarkup {
|
|
|
1419
1406
|
angle: shape.getRotation(),
|
|
1420
1407
|
color: shape.getColor(),
|
|
1421
1408
|
font_size: shape.getFontSize()
|
|
1422
|
-
}
|
|
1409
|
+
};
|
|
1410
|
+
texts.push(text);
|
|
1423
1411
|
}));
|
|
1424
1412
|
return texts;
|
|
1425
1413
|
}
|
|
1426
1414
|
getMarkupRectangles() {
|
|
1427
1415
|
const rectangles = [];
|
|
1428
|
-
this.konvaLayerFind("Rectangle").forEach((
|
|
1429
|
-
const position =
|
|
1416
|
+
this.konvaLayerFind("Rectangle").forEach((ref => {
|
|
1417
|
+
const position = ref.position();
|
|
1430
1418
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
1431
|
-
const shape = new KonvaRectangle(null,
|
|
1432
|
-
|
|
1419
|
+
const shape = new KonvaRectangle(null, ref);
|
|
1420
|
+
const rectangle = {
|
|
1433
1421
|
id: shape.id(),
|
|
1434
1422
|
position: worldPoint,
|
|
1435
1423
|
width: shape.getWidth(),
|
|
1436
1424
|
height: shape.getHeigth(),
|
|
1437
1425
|
line_width: shape.getLineWidth(),
|
|
1438
1426
|
color: shape.getColor()
|
|
1439
|
-
}
|
|
1427
|
+
};
|
|
1428
|
+
rectangles.push(rectangle);
|
|
1440
1429
|
}));
|
|
1441
1430
|
return rectangles;
|
|
1442
1431
|
}
|
|
1443
1432
|
getMarkupEllipses() {
|
|
1444
1433
|
const ellipses = [];
|
|
1445
|
-
this.konvaLayerFind("Ellipse").forEach((
|
|
1446
|
-
const position =
|
|
1434
|
+
this.konvaLayerFind("Ellipse").forEach((ref => {
|
|
1435
|
+
const position = ref.position();
|
|
1447
1436
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
1448
|
-
const shape = new KonvaEllipse(null,
|
|
1449
|
-
|
|
1437
|
+
const shape = new KonvaEllipse(null, ref);
|
|
1438
|
+
const ellipse = {
|
|
1450
1439
|
id: shape.id(),
|
|
1451
1440
|
position: worldPoint,
|
|
1452
1441
|
radius: {
|
|
1453
|
-
x:
|
|
1454
|
-
y:
|
|
1442
|
+
x: ref.getRadiusX(),
|
|
1443
|
+
y: ref.getRadiusY()
|
|
1455
1444
|
},
|
|
1456
1445
|
line_width: shape.getLineWidth(),
|
|
1457
1446
|
color: shape.getColor()
|
|
1458
|
-
}
|
|
1447
|
+
};
|
|
1448
|
+
ellipses.push(ellipse);
|
|
1459
1449
|
}));
|
|
1460
1450
|
return ellipses;
|
|
1461
1451
|
}
|
|
1462
1452
|
getMarkupArrows() {
|
|
1463
1453
|
const arrows = [];
|
|
1464
|
-
this.konvaLayerFind("Arrow").forEach((
|
|
1465
|
-
const absoluteTransform =
|
|
1454
|
+
this.konvaLayerFind("Arrow").forEach((ref => {
|
|
1455
|
+
const absoluteTransform = ref.getAbsoluteTransform();
|
|
1466
1456
|
const atStartPoint = absoluteTransform.point({
|
|
1467
|
-
x:
|
|
1468
|
-
y:
|
|
1457
|
+
x: ref.points()[0],
|
|
1458
|
+
y: ref.points()[1]
|
|
1469
1459
|
});
|
|
1470
1460
|
const worldStartPoint = this._worldTransformer.screenToWorld(atStartPoint);
|
|
1471
1461
|
const atEndPoint = absoluteTransform.point({
|
|
1472
|
-
x:
|
|
1473
|
-
y:
|
|
1462
|
+
x: ref.points()[2],
|
|
1463
|
+
y: ref.points()[3]
|
|
1474
1464
|
});
|
|
1475
1465
|
const worldEndPoint = this._worldTransformer.screenToWorld(atEndPoint);
|
|
1476
|
-
const shape = new KonvaArrow(null,
|
|
1477
|
-
|
|
1466
|
+
const shape = new KonvaArrow(null, ref);
|
|
1467
|
+
const arrow = {
|
|
1478
1468
|
id: shape.id(),
|
|
1479
1469
|
start: worldStartPoint,
|
|
1480
1470
|
end: worldEndPoint,
|
|
1481
1471
|
color: shape.getColor()
|
|
1482
|
-
}
|
|
1472
|
+
};
|
|
1473
|
+
arrows.push(arrow);
|
|
1483
1474
|
}));
|
|
1484
1475
|
return arrows;
|
|
1485
1476
|
}
|
|
1486
1477
|
getMarkupImages() {
|
|
1487
1478
|
const images = [];
|
|
1488
|
-
this.konvaLayerFind("Image").forEach((
|
|
1489
|
-
const position =
|
|
1479
|
+
this.konvaLayerFind("Image").forEach((ref => {
|
|
1480
|
+
const position = ref.position();
|
|
1490
1481
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
1491
|
-
const shape = new KonvaImage(null,
|
|
1492
|
-
|
|
1482
|
+
const shape = new KonvaImage(null, ref);
|
|
1483
|
+
const image = {
|
|
1493
1484
|
id: shape.id(),
|
|
1494
1485
|
position: worldPoint,
|
|
1495
1486
|
src: shape.getSrc(),
|
|
1496
1487
|
width: shape.getWidth(),
|
|
1497
1488
|
height: shape.getHeight()
|
|
1498
|
-
}
|
|
1489
|
+
};
|
|
1490
|
+
images.push(image);
|
|
1499
1491
|
}));
|
|
1500
1492
|
return images;
|
|
1501
1493
|
}
|
|
1502
1494
|
getMarkupClouds() {
|
|
1503
1495
|
const clouds = [];
|
|
1504
|
-
this.konvaLayerFind("Cloud").forEach((
|
|
1505
|
-
const position =
|
|
1496
|
+
this.konvaLayerFind("Cloud").forEach((ref => {
|
|
1497
|
+
const position = ref.position();
|
|
1506
1498
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
1507
|
-
const shape = new KonvaCloud(null,
|
|
1508
|
-
|
|
1499
|
+
const shape = new KonvaCloud(null, ref);
|
|
1500
|
+
const cloud = {
|
|
1509
1501
|
id: shape.id(),
|
|
1510
1502
|
position: worldPoint,
|
|
1511
1503
|
width: shape.getWidth(),
|
|
1512
1504
|
height: shape.getHeigth(),
|
|
1513
1505
|
line_width: shape.getLineWidth(),
|
|
1514
1506
|
color: shape.getColor()
|
|
1515
|
-
}
|
|
1507
|
+
};
|
|
1508
|
+
clouds.push(cloud);
|
|
1516
1509
|
}));
|
|
1517
1510
|
return clouds;
|
|
1518
1511
|
}
|
|
1519
|
-
loadMarkup(viewpoint) {
|
|
1520
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1521
|
-
(_a = viewpoint.lines) === null || _a === void 0 ? void 0 : _a.forEach((vpLine => {
|
|
1522
|
-
const linePoints = [];
|
|
1523
|
-
vpLine.points.forEach((point => {
|
|
1524
|
-
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
1525
|
-
linePoints.push(screenPoint.x);
|
|
1526
|
-
linePoints.push(screenPoint.y);
|
|
1527
|
-
}));
|
|
1528
|
-
this.addLine(linePoints, vpLine.color, vpLine.type, vpLine.width, vpLine.id);
|
|
1529
|
-
}));
|
|
1530
|
-
(_b = viewpoint.texts) === null || _b === void 0 ? void 0 : _b.forEach((vpText => {
|
|
1531
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpText.position);
|
|
1532
|
-
this.addText(vpText.text, screenPoint, vpText.angle, vpText.color, vpText.text_size, vpText.font_size, vpText.id);
|
|
1533
|
-
}));
|
|
1534
|
-
(_c = viewpoint.rectangles) === null || _c === void 0 ? void 0 : _c.forEach((vpRect => {
|
|
1535
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpRect.position);
|
|
1536
|
-
this.addRectangle(screenPoint, vpRect.width, vpRect.height, vpRect.line_width, vpRect.color, vpRect.id);
|
|
1537
|
-
}));
|
|
1538
|
-
(_d = viewpoint.ellipses) === null || _d === void 0 ? void 0 : _d.forEach((vpEllipse => {
|
|
1539
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpEllipse.position);
|
|
1540
|
-
this.addEllipse(screenPoint, vpEllipse.radius, vpEllipse.line_width, vpEllipse.color, vpEllipse.id);
|
|
1541
|
-
}));
|
|
1542
|
-
(_e = viewpoint.arrows) === null || _e === void 0 ? void 0 : _e.forEach((vpArrow => {
|
|
1543
|
-
const startPoint = this._worldTransformer.worldToScreen(vpArrow.start);
|
|
1544
|
-
const endPoint = this._worldTransformer.worldToScreen(vpArrow.end);
|
|
1545
|
-
this.addArrow(startPoint, endPoint, vpArrow.color, vpArrow.id);
|
|
1546
|
-
}));
|
|
1547
|
-
(_f = viewpoint.clouds) === null || _f === void 0 ? void 0 : _f.forEach((vpCloud => {
|
|
1548
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpCloud.position);
|
|
1549
|
-
this.addCloud(screenPoint, vpCloud.width, vpCloud.height, vpCloud.line_width, vpCloud.color, vpCloud.id);
|
|
1550
|
-
}));
|
|
1551
|
-
(_g = viewpoint.images) === null || _g === void 0 ? void 0 : _g.forEach((vpImage => {
|
|
1552
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpImage.position);
|
|
1553
|
-
this.addImage(screenPoint, vpImage.src, vpImage.width, vpImage.height, vpImage.id);
|
|
1554
|
-
}));
|
|
1555
|
-
}
|
|
1556
1512
|
combineMarkupWithDrawing() {
|
|
1557
1513
|
this.clearSelected();
|
|
1558
1514
|
const tempCanvas = document.createElement("canvas");
|
|
@@ -1581,8 +1537,7 @@ class KonvaMarkup {
|
|
|
1581
1537
|
color: color || this._markupColor.HexColor,
|
|
1582
1538
|
id: id
|
|
1583
1539
|
});
|
|
1584
|
-
|
|
1585
|
-
this._konvaLayer.add(obj);
|
|
1540
|
+
this._konvaLayer.add(konvaLine.ref());
|
|
1586
1541
|
return konvaLine;
|
|
1587
1542
|
}
|
|
1588
1543
|
createTextInput(pos, inputX, inputY, angle, text) {
|
|
@@ -1664,33 +1619,32 @@ class KonvaMarkup {
|
|
|
1664
1619
|
this._imageInputPos = null;
|
|
1665
1620
|
}
|
|
1666
1621
|
addText(specifiedText, position, angle, color, textSize, fontSize, id) {
|
|
1622
|
+
if (!specifiedText) return;
|
|
1667
1623
|
const trNodes = this._konvaTransformer.nodes();
|
|
1668
1624
|
if (trNodes.length > 0) {
|
|
1669
1625
|
trNodes[0].destroy();
|
|
1670
1626
|
this._konvaTransformer.nodes([]);
|
|
1671
1627
|
}
|
|
1672
1628
|
this.removeTextInput();
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
fontSize = textSize / (scale.y / size) / 34;
|
|
1679
|
-
}
|
|
1680
|
-
const konvaText = new KonvaText({
|
|
1681
|
-
position: {
|
|
1682
|
-
x: position.x,
|
|
1683
|
-
y: position.y
|
|
1684
|
-
},
|
|
1685
|
-
text: specifiedText,
|
|
1686
|
-
rotation: angle,
|
|
1687
|
-
fontSize: fontSize || this.fontSize,
|
|
1688
|
-
color: color || this._markupColor.HexColor,
|
|
1689
|
-
id: id
|
|
1690
|
-
});
|
|
1691
|
-
this._konvaLayer.add(konvaText.ref());
|
|
1692
|
-
return konvaText;
|
|
1629
|
+
const tolerance = 1e-6;
|
|
1630
|
+
if (textSize && textSize > tolerance && (!fontSize || fontSize < tolerance)) {
|
|
1631
|
+
const size = .02;
|
|
1632
|
+
const scale = this._worldTransformer.getScale();
|
|
1633
|
+
fontSize = textSize / (scale.y / size) / 34;
|
|
1693
1634
|
}
|
|
1635
|
+
const konvaText = new KonvaText({
|
|
1636
|
+
position: {
|
|
1637
|
+
x: position.x,
|
|
1638
|
+
y: position.y
|
|
1639
|
+
},
|
|
1640
|
+
text: specifiedText,
|
|
1641
|
+
rotation: angle,
|
|
1642
|
+
fontSize: fontSize || this.fontSize,
|
|
1643
|
+
color: color || this._markupColor.HexColor,
|
|
1644
|
+
id: id
|
|
1645
|
+
});
|
|
1646
|
+
this._konvaLayer.add(konvaText.ref());
|
|
1647
|
+
return konvaText;
|
|
1694
1648
|
}
|
|
1695
1649
|
addRectangle(position, width, height, lineWidth, color, id) {
|
|
1696
1650
|
if (!position) return;
|
|
@@ -1702,8 +1656,7 @@ class KonvaMarkup {
|
|
|
1702
1656
|
color: color || this._markupColor.HexColor,
|
|
1703
1657
|
id: id
|
|
1704
1658
|
});
|
|
1705
|
-
|
|
1706
|
-
this._konvaLayer.add(obj);
|
|
1659
|
+
this._konvaLayer.add(konvaRectangle.ref());
|
|
1707
1660
|
return konvaRectangle;
|
|
1708
1661
|
}
|
|
1709
1662
|
addEllipse(position, radius, lineWidth, color, id) {
|
|
@@ -1715,8 +1668,7 @@ class KonvaMarkup {
|
|
|
1715
1668
|
color: color || this._markupColor.HexColor,
|
|
1716
1669
|
id: id
|
|
1717
1670
|
});
|
|
1718
|
-
|
|
1719
|
-
this._konvaLayer.add(obj);
|
|
1671
|
+
this._konvaLayer.add(konvaEllipse.ref());
|
|
1720
1672
|
return konvaEllipse;
|
|
1721
1673
|
}
|
|
1722
1674
|
addArrow(start, end, color, id) {
|
|
@@ -1727,8 +1679,7 @@ class KonvaMarkup {
|
|
|
1727
1679
|
color: color || this._markupColor.HexColor,
|
|
1728
1680
|
id: id
|
|
1729
1681
|
});
|
|
1730
|
-
|
|
1731
|
-
this._konvaLayer.add(obj);
|
|
1682
|
+
this._konvaLayer.add(konvaArrow.ref());
|
|
1732
1683
|
return konvaArrow;
|
|
1733
1684
|
}
|
|
1734
1685
|
addCloud(position, width, height, lineWidth, color, id) {
|
|
@@ -1741,30 +1692,25 @@ class KonvaMarkup {
|
|
|
1741
1692
|
lineWidth: lineWidth || this.lineWidth,
|
|
1742
1693
|
id: id
|
|
1743
1694
|
});
|
|
1744
|
-
|
|
1745
|
-
this._konvaLayer.add(obj);
|
|
1695
|
+
this._konvaLayer.add(konvaCloud.ref());
|
|
1746
1696
|
return konvaCloud;
|
|
1747
1697
|
}
|
|
1748
1698
|
addImage(position, src, width, height, id) {
|
|
1749
|
-
if (!position) return;
|
|
1750
|
-
|
|
1751
|
-
if (
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
src: src,
|
|
1755
|
-
width: width,
|
|
1756
|
-
height: height,
|
|
1757
|
-
id: id
|
|
1758
|
-
});
|
|
1759
|
-
const obj = konvaImage.ref();
|
|
1760
|
-
this._konvaLayer.add(obj);
|
|
1761
|
-
const trNodes = this._konvaTransformer.nodes();
|
|
1762
|
-
if (trNodes.length > 0) {
|
|
1763
|
-
trNodes[0].destroy();
|
|
1764
|
-
this._konvaTransformer.nodes([]);
|
|
1765
|
-
}
|
|
1699
|
+
if (!position || !src) return;
|
|
1700
|
+
const trNodes = this._konvaTransformer.nodes();
|
|
1701
|
+
if (trNodes.length > 0) {
|
|
1702
|
+
trNodes[0].destroy();
|
|
1703
|
+
this._konvaTransformer.nodes([]);
|
|
1766
1704
|
}
|
|
1767
1705
|
this.removeImageInput();
|
|
1706
|
+
const konvaImage = new KonvaImage({
|
|
1707
|
+
position: position,
|
|
1708
|
+
src: src,
|
|
1709
|
+
width: width,
|
|
1710
|
+
height: height,
|
|
1711
|
+
id: id
|
|
1712
|
+
});
|
|
1713
|
+
this._konvaLayer.add(konvaImage.ref());
|
|
1768
1714
|
return konvaImage;
|
|
1769
1715
|
}
|
|
1770
1716
|
}
|