buf2d/utils.go

41 lines
555 B
Go
Raw Permalink Normal View History

2020-10-01 13:14:36 +02:00
package buf2d
import "fmt"
2020-10-01 13:14:36 +02:00
func limit(v, min, max int) int {
return getmax(getmin(v, max), min)
}
func getmax(x, y int) int {
if x > y {
return x
}
return y
}
func getmin(x, y int) int {
if x < y {
return x
}
return y
}
type stringerImpl string
func (s *stringerImpl) String() string {
return string(*s)
}
func newStringer(str string) fmt.Stringer {
var impl stringerImpl = stringerImpl(str)
return &impl
}
func newStringerFromRune(rn rune) fmt.Stringer {
return newStringer(string(rn))
}
var (
spaceStringer = newStringer(" ")
)