roundabout,
created on Tuesday, 3 September 2024, 09:22:34 (1725355354),
received on Wednesday, 4 September 2024, 09:03:53 (1725440633)
Author identity: vlad <vlad.muntoiu@gmail.com>
a2d1043573b871b32901280e03d0ac01a47624c1
static/picture-annotation.py
@@ -165,7 +165,7 @@ def cancel_bbox(event):
horizontal_ruler.style.display = "none" vertical_ruler_2.style.display = "none" horizontal_ruler_2.style.display = "none" document.body.style.cursor = "auto"zone.style.cursor = "auto"cancel_button.style.display = "none" helper_message.innerText = "Select a shape type then click on the image to begin defining it"
@@ -230,13 +230,11 @@ def make_polygon(event):
polygon.setAttribute("points", " ".join([f"{point[0] * image.naturalWidth},{point[1] * image.naturalHeight}" for point in polygon_points])) def close_polygon(event):if event is not None and hasattr(event, "key") and event.key != "Enter":return# Polygon is already there, but we need to remove the eventsdef reset_polygon():zone.removeEventListener("click", make_polygon_proxy) document.removeEventListener("keydown", close_polygon_proxy) document.removeEventListener("keydown", cancel_polygon_proxy) document.removeEventListener("keydown", backspace_polygon_proxy)confirm_button.style.display = "none" cancel_button.style.display = "none" backspace_button.style.display = "none"
@@ -245,7 +243,14 @@ def close_polygon(event):
backspace_button.removeEventListener("click", backspace_polygon_proxy) polygon_points.clear() document.body.style.cursor = "auto"zone.style.cursor = "auto" def close_polygon(event): if event is not None and hasattr(event, "key") and event.key != "Enter": return # Polygon is already there, but we need to remove the events reset_polygon()def cancel_polygon(event):
@@ -253,19 +258,7 @@ def cancel_polygon(event):
return # Delete the polygon new_shape.remove() zone.removeEventListener("click", make_polygon_proxy)document.removeEventListener("keydown", close_polygon_proxy)document.removeEventListener("keydown", cancel_polygon_proxy)confirm_button.style.display = "none"cancel_button.style.display = "none"backspace_button.style.display = "none"confirm_button.removeEventListener("click", close_polygon_proxy)cancel_button.removeEventListener("click", cancel_polygon_proxy)backspace_button.removeEventListener("click", backspace_polygon_proxy)polygon_points.clear()document.body.style.cursor = "auto"reset_polygon()def backspace_polygon(event):
@@ -307,7 +300,7 @@ def open_shape(event):
zone.addEventListener("click", make_bbox_proxy) vertical_ruler.style.display = "block" horizontal_ruler.style.display = "block" document.body.style.cursor = "crosshair"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 "
@@ -331,7 +324,7 @@ def open_shape(event):
polygon.classList.add("shape") new_shape.appendChild(polygon) zone.appendChild(new_shape) document.body.style.cursor = "crosshair"zone.style.cursor = "crosshair"for button in list(document.getElementById("shape-selector").children):