github.com/grzegorz-zur/bm@v0.0.0-20240312214136-6fc133e3e2c0/utility.go (about)

     1  package main
     2  
     3  func wrap(position, length, step int, direction Direction) int {
     4  	return ((position+step*int(direction))%length + length) % length
     5  }
     6  
     7  func visible(rune rune) rune {
     8  	switch {
     9  	case rune < 16:
    10  		return rune + '␀'
    11  	case rune == 255:
    12  		return '␡'
    13  	}
    14  	return rune
    15  }