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

48 lines
1.2 KiB
Go

package ui
import "strings"
// shadeBlock maps fractional fill within a row to Unicode shade characters: █ ▓ ▒ ░
func shadeBlock(level, rowBottom, rowTop float64) string {
if level >= rowTop {
return "█"
}
if level > rowBottom {
frac := (level - rowBottom) / (rowTop - rowBottom)
switch {
case frac >= 0.75:
return "▓"
case frac >= 0.50:
return "▒"
case frac >= 0.25:
return "░"
}
}
return " "
}
// renderAscii draws thin single-character columns with shade blocks (█ ▓ ▒ ░),
// using the same dense 1-wide/1-gap layout as ClassicPeak.
func (v *Visualizer) renderAscii(bands []float64) string {
height := v.Rows
activeCols := classicPeakColsForWidth(PanelWidth)
cols := resampleBandsLinear(bands, activeCols)
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)
for i, level := range cols {
content.WriteString(shadeBlock(level, rowBottom, rowTop))
if i < len(cols)-1 {
content.WriteByte(' ')
}
}
lines[row] = specWrap(rowBottom, content.String())
}
return strings.Join(lines, "\n")
}