roundabout,
created on Wednesday, 4 September 2024, 10:07:03 (1725444423),
received on Wednesday, 4 September 2024, 11:10:54 (1725448254)
Author identity: vlad <vlad.muntoiu@gmail.com>
59a0e79b4f14f2f6486e96ca8212d3267424418e
static/picture-annotation.py
@@ -404,10 +404,16 @@ def open_shape(event):
vertical_ruler.style.display = "block"
horizontal_ruler.style.display = "block"
zone.style.cursor = "crosshair"
elif shape_type == "shape-polygon":
helper_message.innerText = ("Click on the image to define the points of the polygon, "
"press escape to cancel, enter to close, or backspace to "
"remove the last point")
elif shape_type == "shape-polygon" or shape_type == "shape-polyline":
match shape_type:
case "shape-polygon":
helper_message.innerText = ("Click on the image to define the points of the polygon, "
"press escape to cancel, enter to close, or backspace to "
"remove the last point")
case "shape-polyline":
helper_message.innerText = ("Click on the image to define the points of the polyline, "
"press escape to cancel, enter to finish, or backspace to "
"remove the last point")
if not polygon_points and not new_shape:
new_shape = document.createElementNS("http://www.w3.org/2000/svg", "svg")
@@ -418,7 +424,6 @@ def open_shape(event):
new_shape.classList.add("shape-container")
if not polygon_points and int(len(new_shape.children)) == 0:
print(len(new_shape.children), "children found")
zone.addEventListener("click", make_polygon_proxy)
document.addEventListener("keydown", close_polygon_proxy)
document.addEventListener("keydown", cancel_polygon_proxy)
@@ -429,10 +434,15 @@ def open_shape(event):
confirm_button.style.display = "block"
backspace_button.addEventListener("click", backspace_polygon_proxy)
backspace_button.style.display = "block"
polygon = document.createElementNS("http://www.w3.org/2000/svg", "polygon")
match shape_type:
case "shape-polygon":
polygon = document.createElementNS("http://www.w3.org/2000/svg", "polygon")
polygon.classList.add("shape-polygon")
case "shape-polyline":
polygon = document.createElementNS("http://www.w3.org/2000/svg", "polyline")
polygon.classList.add("shape-polyline")
polygon.setAttribute("fill", "none")
polygon.setAttribute("data-object-type", "")
polygon.classList.add("shape-polygon")
polygon.classList.add("shape")
new_shape.appendChild(polygon)
zone.appendChild(new_shape)
static/style.css
@@ -63,8 +63,13 @@ iconify-icon {
pointer-events: auto;
}
.shape-polyline {
fill: none;
}
.shape.selected {
fill-opacity: 0.2;
stroke-width: 4px;
}
.shape-container {
templates/picture-annotation.html
@@ -24,7 +24,7 @@
<button class="button-flat" title="polygon" id="shape-polygon">
<iconify-icon icon="mdi:pentagon"></iconify-icon>
</button>
<button class="button-flat" title="line" id="shape-line">
<button class="button-flat" title="polyline" id="shape-polyline">
<iconify-icon icon="mdi:graph-line-variant"></iconify-icon>
</button>
<button class="button-flat" title="point" id="shape-point">