mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Improved beatgrid visibility
This commit is contained in:
1 parent
815b700075
commit
2f9b1d59ae
1 file changed
+9
-2
@@ -122,6 +122,9 @@ export function drawBeatgrid(
|
|||||||
const span = endSec - startSec
|
const span = endSec - startSec
|
||||||
const beatPx = (beat / span) * w
|
const beatPx = (beat / span) * w
|
||||||
const showBeats = beatPx >= 6 * dpr
|
const showBeats = beatPx >= 6 * dpr
|
||||||
|
const outline = Math.max(1, Math.round(dpr))
|
||||||
|
const beatW = Math.max(1, Math.round(dpr))
|
||||||
|
const barW = Math.max(2, Math.round(2 * dpr))
|
||||||
let k = Math.ceil((startSec - gridAnchor) / beat)
|
let k = Math.ceil((startSec - gridAnchor) / beat)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const bt = gridAnchor + k * beat
|
const bt = gridAnchor + k * beat
|
||||||
@@ -131,7 +134,11 @@ export function drawBeatgrid(
|
|||||||
if (bt < startSec) continue
|
if (bt < startSec) continue
|
||||||
if (!downbeat && !showBeats) continue
|
if (!downbeat && !showBeats) continue
|
||||||
const x = Math.round(((bt - startSec) / span) * w)
|
const x = Math.round(((bt - startSec) / span) * w)
|
||||||
ctx.fillStyle = downbeat ? 'rgba(255,255,255,0.5)' : 'rgba(255,255,255,0.2)'
|
const lw = downbeat ? barW : beatW
|
||||||
ctx.fillRect(x, 0, downbeat ? Math.max(1, Math.round(dpr)) : 1, h)
|
// Dark outline so the line reads on any waveform colour, then a bright line.
|
||||||
|
ctx.fillStyle = 'rgba(0,0,0,0.6)'
|
||||||
|
ctx.fillRect(x - Math.floor(lw / 2) - outline, 0, lw + outline * 2, h)
|
||||||
|
ctx.fillStyle = downbeat ? 'rgba(255,255,255,0.95)' : 'rgba(255,255,255,0.65)'
|
||||||
|
ctx.fillRect(x - Math.floor(lw / 2), 0, lw, h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user