From 63ca44d19d77c243de1d132b8c0ec0b92595246c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Fern=C3=A1ndez=20Serrata?= Date: Mon, 4 Mar 2024 23:43:10 -0400 Subject: [PATCH] resize displayed canvas once per debounce --- src/main.js | 7 +++++-- src/style.css | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.js b/src/main.js index 262ec1b..4a737db 100644 --- a/src/main.js +++ b/src/main.js @@ -187,9 +187,12 @@ const RGBDR_anim = (() => { And set font-size accordingly */ const resize = () => { + const { clientWidth, clientHeight } = body + canv.style.width = clientWidth + 'px' + canv.style.height = clientHeight + 'px' const scale = devicePixelRatio - canv.width = body.clientWidth * scale >>> 0 - canv.height = body.clientHeight * scale >>> 0 + canv.width = clientWidth * scale >>> 0 + canv.height = clientHeight * scale >>> 0 // is normalization necessary? //ctx.scale(scale, scale) ctx.font = `bold ${get_droplet_size()}px monospace` diff --git a/src/style.css b/src/style.css index ee33fdb..5768352 100644 --- a/src/style.css +++ b/src/style.css @@ -9,7 +9,5 @@ canvas { position: absolute; left: 0; top: 0; - width: 100vw; - height: 100vh; image-rendering: pixelated } \ No newline at end of file