2020-10-01 13:14:36 +02:00
|
|
|
package buf2d
|
|
|
|
|
2021-01-15 21:40:09 +01:00
|
|
|
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
|
|
|
|
}
|
2021-01-15 21:40:09 +01:00
|
|
|
|
|
|
|
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(" ")
|
|
|
|
)
|