go-opengl-pixel/math.go

16 lines
299 B
Go
Raw Normal View History

2021-06-22 15:45:22 -05:00
package pixel
// Clamp returns x clamped to the interval [min, max].
//
// If x is less than min, min is returned. If x is more than max, max is returned. Otherwise, x is
// returned.
func Clamp(x, min, max float64) float64 {
if x < min {
return min
}
if x > max {
return max
}
return x
}