41 lines
555 B
Go
41 lines
555 B
Go
package buf2d
|
|
|
|
import "fmt"
|
|
|
|
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(" ")
|
|
)
|