MCPcopy Create free account
hub / github.com/B33pBeeps/redthread / pickStringChar

Function pickStringChar

internal/app/wire.go:229–245  ·  view source on GitHub ↗

pickStringChar maps a local (dx, dy) direction to a line character, accounting for terminal cell aspect ratio (~2:1 tall:wide). Without this correction, near-horizontal lines would often pick diagonal chars.

(dx, dy float32)

Source from the content-addressed store, hash-verified

227// accounting for terminal cell aspect ratio (~2:1 tall:wide). Without this
228// correction, near-horizontal lines would often pick diagonal chars.
229func pickStringChar(dx, dy float32) rune {
230 // Treat one vertical cell as if it were 2 wide for angle calc —
231 // matches the visual aspect of the terminal.
232 aDy := dy * 2
233 ax := absF(dx)
234 ay := absF(aDy)
235 switch {
236 case ax > 1.8*ay:
237 return '─'
238 case ay > 1.8*ax:
239 return '│'
240 case dx*dy < 0: // up-right or down-left → `/`
241 return '╱'
242 default: // down-right or up-left → `\`
243 return '╲'
244 }
245}
246
247func absF(x float32) float32 {
248 if x < 0 {

Callers 1

drawCurveFunction · 0.85

Calls 1

absFFunction · 0.85

Tested by

no test coverage detected