[−][src]Trait vek::ops::Clamp
A scalar or vector that can be constrained to be between two values (inclusive).
Required methods
pub fn clamped(self, lower: Bound, upper: Bound) -> Self
[src]
Constrains this value to be between lower
and upper
(inclusive).
This would rather make use of inclusive ranges, but it's an unstable feature.
Panics
Panics if lower
is greater than upper
. Swap the values yourself if necessary.
use vek::ops::Clamp; assert_eq!(7.clamped(5, 10), 7); assert_eq!(4.clamped(5, 10), 5); assert_eq!(5.clamped(5, 10), 5); assert_eq!(10.clamped(5, 10), 10); assert_eq!(11.clamped(5, 10), 10);
Provided methods
pub fn clamp(val: Self, lower: Bound, upper: Bound) -> Self
[src]
Alias to clamped
, which doesn't take self
.
Panics
Panics if lower
is greater than upper
. Swap the values yourself if necessary.
pub fn clamped01(self) -> Self where
Bound: Zero + One,
[src]
Bound: Zero + One,
Constrains this value to be between 0 and 1 (inclusive).
pub fn clamp01(val: Self) -> Self where
Bound: Zero + One,
[src]
Bound: Zero + One,
Alias to clamped01
, which doesn't take self
.
pub fn clamped_minus1_1(self) -> Self where
Bound: One + Neg<Output = Bound>,
[src]
Bound: One + Neg<Output = Bound>,
Constrains this value to be between -1 and 1 (inclusive).
pub fn clamp_minus1_1(val: Self) -> Self where
Bound: One + Neg<Output = Bound>,
[src]
Bound: One + Neg<Output = Bound>,
Alias to clamped_minus1_1
, which doesn't take self
.