Files
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

41 lines
1.1 KiB
Go

package ui
import "strings"
// renderColumns draws many thin single-character-wide columns, interpolating
// between bands so adjacent columns vary slightly for a dense, organic look.
func (v *Visualizer) renderColumns(bands []float64) string {
height := v.Rows
bandCount := len(bands)
// Compute per-band column counts; cols below is a flat level per display column.
bandCols := make([]int, bandCount)
for b := range bandCount {
bandCols[b] = visBandWidth(bandCount, b)
}
cols := interpolateBandColumns(bands, bandCols)
lines := make([]string, height)
for row := range height {
var content strings.Builder
rowBottom := float64(height-1-row) / float64(height)
rowTop := float64(height-row) / float64(height)
offset := 0
for b := range bandCount {
for c := range bandCols[b] {
level := cols[offset+c]
content.WriteString(fracBlock(level, rowBottom, rowTop))
}
offset += bandCols[b]
if b < bandCount-1 {
content.WriteByte(' ')
}
}
lines[row] = specWrap(rowBottom, content.String())
}
return strings.Join(lines, "\n")
}