Spaces:
Running
Running
edge added
Browse files
comic_panel_extractor/static/annotator.html
CHANGED
|
@@ -857,7 +857,7 @@
|
|
| 857 |
}
|
| 858 |
|
| 859 |
if (annotation.type === 'segmentation') {
|
| 860 |
-
this.drawPolygon(annotation.points, strokeColor, fillColor);
|
| 861 |
} else {
|
| 862 |
this.drawBox(annotation.left, annotation.top, annotation.width, annotation.height, strokeColor, fillColor);
|
| 863 |
}
|
|
@@ -870,8 +870,7 @@
|
|
| 870 |
|
| 871 |
// Draw current box being drawn
|
| 872 |
if (this.currentBox) {
|
| 873 |
-
this.drawBox(this.currentBox.left, this.currentBox.top,
|
| 874 |
-
this.currentBox.width, this.currentBox.height, '#ff0000', 'rgba(255, 0, 0, 0.3)');
|
| 875 |
}
|
| 876 |
|
| 877 |
// Draw current polygon being drawn
|
|
@@ -899,26 +898,38 @@
|
|
| 899 |
}
|
| 900 |
this.ctx.stroke();
|
| 901 |
|
| 902 |
-
// Draw corner points (
|
| 903 |
-
const
|
| 904 |
points.forEach((point, index) => {
|
| 905 |
this.ctx.fillStyle = isSelected ? '#0066ff' : strokeColor;
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
this.ctx.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 909 |
|
| 910 |
if (isSelected) {
|
| 911 |
this.ctx.strokeStyle = '#ffffff';
|
| 912 |
this.ctx.lineWidth = 2;
|
| 913 |
-
this.ctx.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 914 |
}
|
| 915 |
});
|
| 916 |
|
| 917 |
-
// Draw edge handles for selected polygon
|
| 918 |
if (isSelected && points.length > 2 && this.showEdgeHandles) {
|
| 919 |
this.drawEdgeHandles(points);
|
| 920 |
}
|
| 921 |
}
|
|
|
|
|
|
|
| 922 |
drawEdgeHandles(points) {
|
| 923 |
this.ctx.fillStyle = 'rgba(0, 102, 255, 0.8)';
|
| 924 |
this.ctx.strokeStyle = '#ffffff';
|
|
@@ -930,7 +941,7 @@
|
|
| 930 |
const midY = (points[i].y + points[nextIndex].y) / 2;
|
| 931 |
|
| 932 |
// Draw square handle
|
| 933 |
-
const handleSize =
|
| 934 |
this.ctx.fillRect(midX - handleSize / 2, midY - handleSize / 2, handleSize, handleSize);
|
| 935 |
this.ctx.strokeRect(midX - handleSize / 2, midY - handleSize / 2, handleSize, handleSize);
|
| 936 |
}
|
|
@@ -1437,7 +1448,7 @@
|
|
| 1437 |
}
|
| 1438 |
|
| 1439 |
getResizeHandle(x, y) {
|
| 1440 |
-
if (this.selectedBoxIndex < 0) return {cursor: 'move'};
|
| 1441 |
|
| 1442 |
const box = this.annotations[this.selectedBoxIndex];
|
| 1443 |
const handleSize = 8;
|
|
@@ -1459,7 +1470,7 @@
|
|
| 1459 |
return handle;
|
| 1460 |
}
|
| 1461 |
}
|
| 1462 |
-
return {cursor: 'move'};
|
| 1463 |
}
|
| 1464 |
|
| 1465 |
getBoxAtPosition(x, y) {
|
|
|
|
| 857 |
}
|
| 858 |
|
| 859 |
if (annotation.type === 'segmentation') {
|
| 860 |
+
this.drawPolygon(annotation.points, strokeColor, fillColor, index === this.selectedBoxIndex);
|
| 861 |
} else {
|
| 862 |
this.drawBox(annotation.left, annotation.top, annotation.width, annotation.height, strokeColor, fillColor);
|
| 863 |
}
|
|
|
|
| 870 |
|
| 871 |
// Draw current box being drawn
|
| 872 |
if (this.currentBox) {
|
| 873 |
+
this.drawBox(this.currentBox.left, this.currentBox.top, this.currentBox.width, this.currentBox.height, '#ff0000', 'rgba(255, 0, 0, 0.3)');
|
|
|
|
| 874 |
}
|
| 875 |
|
| 876 |
// Draw current polygon being drawn
|
|
|
|
| 898 |
}
|
| 899 |
this.ctx.stroke();
|
| 900 |
|
| 901 |
+
// Draw corner points as squares (like bbox handles) - ONLY at intersecting points
|
| 902 |
+
const handleSize = isSelected ? 10 : 6;
|
| 903 |
points.forEach((point, index) => {
|
| 904 |
this.ctx.fillStyle = isSelected ? '#0066ff' : strokeColor;
|
| 905 |
+
|
| 906 |
+
// Draw square handle centered on the point
|
| 907 |
+
this.ctx.fillRect(
|
| 908 |
+
point.x - handleSize / 2,
|
| 909 |
+
point.y - handleSize / 2,
|
| 910 |
+
handleSize,
|
| 911 |
+
handleSize
|
| 912 |
+
);
|
| 913 |
|
| 914 |
if (isSelected) {
|
| 915 |
this.ctx.strokeStyle = '#ffffff';
|
| 916 |
this.ctx.lineWidth = 2;
|
| 917 |
+
this.ctx.strokeRect(
|
| 918 |
+
point.x - handleSize / 2,
|
| 919 |
+
point.y - handleSize / 2,
|
| 920 |
+
handleSize,
|
| 921 |
+
handleSize
|
| 922 |
+
);
|
| 923 |
}
|
| 924 |
});
|
| 925 |
|
| 926 |
+
// Draw edge handles for selected polygon (these are the midpoint handles)
|
| 927 |
if (isSelected && points.length > 2 && this.showEdgeHandles) {
|
| 928 |
this.drawEdgeHandles(points);
|
| 929 |
}
|
| 930 |
}
|
| 931 |
+
|
| 932 |
+
|
| 933 |
drawEdgeHandles(points) {
|
| 934 |
this.ctx.fillStyle = 'rgba(0, 102, 255, 0.8)';
|
| 935 |
this.ctx.strokeStyle = '#ffffff';
|
|
|
|
| 941 |
const midY = (points[i].y + points[nextIndex].y) / 2;
|
| 942 |
|
| 943 |
// Draw square handle
|
| 944 |
+
const handleSize = 10;
|
| 945 |
this.ctx.fillRect(midX - handleSize / 2, midY - handleSize / 2, handleSize, handleSize);
|
| 946 |
this.ctx.strokeRect(midX - handleSize / 2, midY - handleSize / 2, handleSize, handleSize);
|
| 947 |
}
|
|
|
|
| 1448 |
}
|
| 1449 |
|
| 1450 |
getResizeHandle(x, y) {
|
| 1451 |
+
if (this.selectedBoxIndex < 0) return { cursor: 'move' };
|
| 1452 |
|
| 1453 |
const box = this.annotations[this.selectedBoxIndex];
|
| 1454 |
const handleSize = 8;
|
|
|
|
| 1470 |
return handle;
|
| 1471 |
}
|
| 1472 |
}
|
| 1473 |
+
return { cursor: 'move' };
|
| 1474 |
}
|
| 1475 |
|
| 1476 |
getBoxAtPosition(x, y) {
|