From 71577039f8dda70818f5bfd35f34c222d0614ab4 Mon Sep 17 00:00:00 2001
From: evgbus <6546718+evgbus@users.noreply.github.com>
Date: Mon, 29 Dec 2025 23:59:04 +0300
Subject: [PATCH] Added "Draw from center" option to Analog ROI editor (#3975)
---
sd-card/html/edit_analog.html | 53 ++++++++++++++++++++++++++---------
1 file changed, 40 insertions(+), 13 deletions(-)
diff --git a/sd-card/html/edit_analog.html b/sd-card/html/edit_analog.html
index bc2ab661..dba8c0a0 100644
--- a/sd-card/html/edit_analog.html
+++ b/sd-card/html/edit_analog.html
@@ -156,6 +156,7 @@ The following settings are only used for easier setup, they are not persi
+
@@ -196,6 +197,7 @@ The following settings are only used for easier setup, they are not persi
enhanceCon = false,
lockAspectRatio = true,
lockSizes = false,
+ drawFromCenter = true,
domainname = getDomainname();
function doReboot() {
@@ -316,7 +318,11 @@ The following settings are only used for easier setup, they are not persi
function changelockSizes() {
lockSizes = document.getElementById("lockSizes").checked;
- UpdateROIs();
+ UpdateROIs();
+ }
+
+ function changeDrawFromCenter() {
+ drawFromCenter = document.getElementById("drawFromCenter").checked;
}
function changeCCW() {
@@ -800,8 +806,12 @@ The following settings are only used for easier setup, they are not persi
zw = getCoords(this)
rect.startX = e.pageX - zw.left;
rect.startY = e.pageY - zw.top;
+ if (drawFromCenter) {
+ rect.centerX = rect.startX;
+ rect.centerY = rect.startY;
+ }
document.getElementById("refx").value = rect.startX;
- document.getElementById("refy").value = rect.startY;
+ document.getElementById("refy").value = rect.startY;
drag = true;
}
@@ -822,16 +832,33 @@ The following settings are only used for easier setup, they are not persi
}
function mouseMove(e) {
- if (drag) {
- zw = getCoords(this)
+ const mouseX = e.pageX - zw.left;
+ const mouseY = e.pageY - zw.top;
- if (lockAspectRatio) {
- rect.h = (e.pageY - zw.top) - rect.startY;
- rect.w = Math.round(rect.h * ROIInfo[aktindex]["ar"]);
- }
- else {
- rect.w = (e.pageX - zw.left) - rect.startX;
- rect.h = (e.pageY - zw.top) - rect.startY;
+ if (drag) {
+ zw = getCoords(this)
+
+ if (drawFromCenter) {
+ if (lockAspectRatio) {
+ rect.h = Math.abs(mouseY - rect.centerY) * 2;
+ rect.w = Math.round(rect.h * ROIInfo[aktindex]["ar"]);
+ } else {
+ rect.w = Math.abs(mouseX - rect.centerX) * 2;
+ rect.h = Math.abs(mouseY - rect.centerY) * 2;
+ }
+
+ rect.startX = rect.centerX - rect.w / 2;
+ rect.startY = rect.centerY - rect.h / 2;
+ document.getElementById("refx").value = Math.round(rect.startX);
+ document.getElementById("refy").value = Math.round(rect.startY);
+ } else {
+ if (lockAspectRatio) {
+ rect.h = mouseY - rect.startY;
+ rect.w = Math.round(rect.h * ROIInfo[aktindex]["ar"]);
+ } else {
+ rect.w = mouseX - rect.startX;
+ rect.h = mouseY - rect.startY;
+ }
}
document.getElementById("refdx").value = rect.w;
document.getElementById("refdy").value = rect.h;
@@ -843,8 +870,8 @@ The following settings are only used for easier setup, they are not persi
var context = canvas.getContext('2d');
zw = getCoords(this);
- x = e.pageX - zw.left;
- y = e.pageY - zw.top;
+ x = mouseX;
+ y = mouseY;
context.lineWidth = 2;
context.strokeStyle = "#00FF00";