use a zero waveform image with single horizontal line when none exists

This commit is contained in:
Drew Weymouth
2025-08-01 17:52:05 -07:00
parent 8078b7082f
commit 8e3ec5e11b
3 changed files with 20 additions and 1 deletions
+10 -1
View File
@@ -28,7 +28,16 @@ type WaveformImageGenerator struct {
type WaveformImage = image.NRGBA
func NewWaveformImage() *WaveformImage {
return image.NewNRGBA(image.Rect(0, 0, 1024, 48))
img := image.NewNRGBA(image.Rect(0, 0, 1024, 48))
centerTop := img.Rect.Dy() / 2 // 24
centerBottom := centerTop - 1 // 23
// color in center line
for x := 0; x < img.Bounds().Dx(); x++ {
setPixel(img, x, centerTop, color.NRGBA{R: 255, G: 255, B: 255, A: 255})
setPixel(img, x, centerBottom, color.NRGBA{R: 255, G: 255, B: 255, A: 255})
}
return img
}
type WaveformImageJob struct {