package tui type Direction int const ( Down = iota Up Right Left ) func (d Direction) axis() int { switch d { case Down, Up: return 1 default: return 0 } } func (d Direction) reverse() bool { switch d { case Down, Right: return false default: return true } } type rect struct { min [2]int max [2]int }