diff --git a/index.html b/index.html index d68e926..be8a784 100644 --- a/index.html +++ b/index.html @@ -535,8 +535,17 @@ function drawSpectrum() { const vuCanvas = document.getElementById('vuMeter'); if (vuCanvas && tracks.length && analyserL && analyserR) { const vuctx = vuCanvas.getContext('2d'); - const vw = vuCanvas.width, vh = vuCanvas.height; - vuctx.clearRect(0, 0, vw, vh); + const vuRect = vuCanvas.getBoundingClientRect(); + const vuDpr = window.devicePixelRatio || 1; + const bufW = Math.round(vuRect.width * vuDpr); + const bufH = Math.round(vuRect.height * vuDpr); + if (vuCanvas.width !== bufW || vuCanvas.height !== bufH) { + vuCanvas.width = bufW; + vuCanvas.height = bufH; + } + vuctx.setTransform(vuDpr, 0, 0, vuDpr, 0, 0); + vuctx.clearRect(0, 0, vuRect.width, vuRect.height); + const vw = vuRect.width; const rowH = 6; const gap = 4; const labelW = 12;