summaryrefslogtreecommitdiff
path: root/cnn_v3
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-03-22 16:37:48 +0100
committerskal <pascal.massimino@gmail.com>2026-03-22 16:37:48 +0100
commite46c2a6a110e803cab1e50095dd8ef60add8c788 (patch)
treedd91aeb0854379a817c636662f87a77cee555409 /cnn_v3
parent7249a40c54e9ce3fc144a37f7c1ff8c082e62191 (diff)
fix(cnn_v3/tools): fit zoom canvas to panel width by scaling canvas attributes
Diffstat (limited to 'cnn_v3')
-rw-r--r--cnn_v3/tools/tester.js12
1 files changed, 7 insertions, 5 deletions
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 <canvas>)
+ 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)