Fix coordinate printing.

This commit is contained in:
Yaro Kasear 2025-12-09 14:47:52 -06:00
parent 0fb1991b5a
commit 8abf9bdcdf

View file

@ -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();