Files
fluids/utils/clamp.go

28 lines
414 B
Go
Raw Permalink Normal View History

package utils
// returns adjusted value between start and end, whichever is closer
// unless value is between, in which case it returns value
func Clamp(value, start, end int) int {
if value < start {
return start
}
if value < end {
return value
}
return end
}
func Clamp32(value, start, end float32) float32 {
if value < start {
return start
}
if value < end {
return value
}
return end
}