pub trait Clamp {
// Required method
fn clamp(self) -> Self;
}
Expand description
An operator for restricting a color’s components to their expected ranges.
IsWithinBounds
can be used to check if the components are within their
range bounds.
See also ClampAssign
.
use palette::{Srgb, IsWithinBounds, Clamp};
let unclamped = Srgb::new(1.3f32, 0.5, -3.0);
assert!(!unclamped.is_within_bounds());
let clamped = unclamped.clamp();
assert!(clamped.is_within_bounds());
assert_eq!(clamped, Srgb::new(1.0, 0.5, 0.0));
Required Methods§
Object Safety§
This trait is not object safe.