Files
bjarneo--cliamp/ui/vis_bars_outline.go
wehub-resource-sync ead81af521
Deploy to GitHub Pages / deploy (push) Failing after 0s
CI / go (push) Has been cancelled
CI / build (darwin, macos-14) (push) Has been cancelled
CI / build (windows, windows-2025) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:13 +08: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")
}