Files
bjarneo--cliamp/ui/vis_bars_outline.go
Bjarne Øverli 6d056f9580
Release / build (amd64, darwin, macos-latest) (push) Has been cancelled
Release / build (amd64, linux, ubuntu-latest) (push) Has been cancelled
Release / build (amd64, windows, windows-latest) (push) Has been cancelled
Release / build (arm64, darwin, macos-latest) (push) Has been cancelled
Release / build (arm64, linux, ubuntu-latest) (push) Has been cancelled
Release / release (push) Has been cancelled
Release / update-homebrew (push) Has been cancelled
Speed up visualizer FFT and rendering pipeline
2026-04-20 18:40:53 +02:00

44 lines
1.0 KiB
Go

package ui
import "strings"
// renderBarsOutline draws only the top edge of each bar as a horizontal line,
// with empty space below — a minimal line-graph style visualizer.
func (v *Visualizer) renderBarsOutline(bands []float64) string {
height := v.Rows
lines := make([]string, height)
bandCount := len(bands)
for row := range height {
var content strings.Builder
rowBottom := float64(height-1-row) / float64(height)
rowTop := float64(height-row) / float64(height)
for i, level := range bands {
bw := visBandWidth(bandCount, i)
if level >= rowTop {
// Fully below the peak — empty inside.
for range bw {
content.WriteByte(' ')
}
} else if level > rowBottom {
// This row contains the peak — draw the outline.
for range bw {
content.WriteRune('─')
}
} else {
// Above the peak — empty.
for range bw {
content.WriteByte(' ')
}
}
if i < bandCount-1 {
content.WriteByte(' ')
}
}
lines[row] = specWrap(rowBottom, content.String())
}
return strings.Join(lines, "\n")
}