From 8abf9bdcdf0eaba58c5768fe6af6bf042ac56901 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Tue, 9 Dec 2025 14:47:52 -0600 Subject: [PATCH] Fix coordinate printing. --- inventory/templates/testing.html | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/inventory/templates/testing.html b/inventory/templates/testing.html index 5b248a4..05f8593 100644 --- a/inventory/templates/testing.html +++ b/inventory/templates/testing.html @@ -261,10 +261,10 @@ function snapToGrid(x, y) { } function normalizeRect(shape) { - const ix1 = shape.x1 / {{ grid_size }}; - const iy1 = shape.y1 / {{ grid_size }}; - const ix2 = shape.x2 / {{ grid_size }}; - const iy2 = shape.y2 / {{ grid_size }}; + const ix1 = Math.round(shape.x1 / {{ grid_size }}); + const iy1 = Math.round(shape.y1 / {{ grid_size }}); + const ix2 = Math.round(shape.x2 / {{ grid_size }}); + const iy2 = Math.round(shape.y2 / {{ grid_size }}); const ix = Math.min(ix1, ix2); const iy = Math.min(iy1, iy2); @@ -525,18 +525,7 @@ gridEl.addEventListener('pointermove', (e) => { dotEl.style.left = `${renderX}px`; } - const type = getActiveType(); - - var coordsX = `${renderX}px`; - var coordsY = `${renderY}px`; - if (type === 'fullGrid' || type === 'verticalGrid') { - coordsX = `${ix}g`; - } - if (type === 'fullGrid' || type === 'horizontalGrid') { - coordsY = `${iy}g`; - } - - coordsEl.innerText = `(${coordsX}, ${coordsY})`; + coordsEl.innerText = `(x=${ix} (${snapX}px) y=${iy} (${snapY}px) )`; if (currentShape) { const tool = currentShape.tool; @@ -584,8 +573,6 @@ gridEl.addEventListener('pointerdown', (e) => { e.preventDefault(); gridEl.setPointerCapture(e.pointerId); - if (e.target.closest('#toolBar')) return; - const { x: snapX, y: snapY } = snapToGrid(e.clientX, e.clientY); const tool = getActiveTool();