From e4a6ae2d7d14ffee1319b3c38fe9c44a86df38ea Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Mon, 15 Jun 2020 13:09:16 -0400 Subject: [PATCH] Fix slight error in calculating width and height --- xray.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xray.js b/xray.js index b6cda8d..a872ff1 100644 --- a/xray.js +++ b/xray.js @@ -17,7 +17,7 @@ let scale; document.addEventListener("DOMContentLoaded", e => { document.querySelector("#reset-button").addEventListener("click", reset); - + document.querySelector("#load-button").addEventListener("click", e => { console.log("Trying to load..."); const baseInput = document.querySelector("#base-url").value; @@ -329,11 +329,10 @@ function setup() { const scaleH = availableHeight / baseImg.height; scale = Math.min(scaleW, scaleH); - const width = availableWidth * scale / scaleW; - const height = availableHeight * scale / scaleH; + width = Math.floor(availableWidth * scale / scaleW); + height = Math.floor(availableHeight * scale / scaleH); [baseCtx, baseCtxResized, overlayCtx, overlayCtxResized].forEach(ctx => { - console.log(ctx.canvas) ctx.canvas.width = width; ctx.canvas.height = height; ctx.canvas.style.left = (availableWidth - width) / 2 + "px";