[−][src]Function physics2d::math::clamp01
pub fn clamp01(x: f32) -> f32
Clamps (limits) the value of x
in the inclusive range from 0.0
to 1.0
.
If x < 0.0
, 0.0
is returned. If x > 1.0
, 1.0
is returned.
Examples
assert_eq!(clamp01(-10.0), 0.0); assert_eq!(clamp01(0.12345678), 0.12345678); assert_eq!(clamp01(999.8989), 1.0);