mirror of
https://codeberg.org/armin/noiz.git
synced 2026-09-01 05:50:52 +02:00
Make VU meter canvas DPR-aware for sharp edges on Retina displays
This commit is contained in:
parent
af866881ff
commit
56faa28f6b
1 changed files with 11 additions and 2 deletions
13
index.html
13
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue