From e46c2a6a110e803cab1e50095dd8ef60add8c788 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 22 Mar 2026 16:37:48 +0100 Subject: fix(cnn_v3/tools): fit zoom canvas to panel width by scaling canvas attributes --- cnn_v3/tools/tester.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'cnn_v3/tools/tester.js') diff --git a/cnn_v3/tools/tester.js b/cnn_v3/tools/tester.js index a138e12..fd2b7bd 100644 --- a/cnn_v3/tools/tester.js +++ b/cnn_v3/tools/tester.js @@ -493,11 +493,13 @@ class CNNv3Tester { const wrap = document.getElementById('chzoomWrap'); const dst = document.getElementById('chzoom'); const lbl = document.getElementById('chzoomLbl'); - // Size: fill panel width, height follows aspect ratio - dst.width = tex.width; - dst.height = tex.height; - dst.style.width = '100%'; - dst.style.height = 'auto'; + // Size: fit canvas to available container width (height:auto doesn't work on ) + const maxW = wrap.clientWidth - 12; // subtract wrap padding + const scale = Math.min(1, maxW / tex.width); + dst.width = Math.round(tex.width * scale); + dst.height = Math.round(tex.height * scale); + dst.style.width = ''; + dst.style.height = ''; lbl.textContent = label; wrap.style.display = 'flex'; // Re-render via WebGPU (WebGPU canvas pixels are not readable by drawImage) -- cgit v1.2.3