pub struct Interpolation<T>where
T: Lerp,{ /* private fields */ }Expand description
A piecewise-linear map from an input range onto an output range: [0, 120] of scroll onto
[1, 0] of opacity, or onto two colors.
The output is anything with a Lerp: numbers, points, rects, and colors, which blend in
OKLab. Outside the input range the map clamps to the nearest end unless
extend lets the outer segments run on.
ⓘ
let fade = Interpolation::new([0.0, 120.0], [1.0, 0.0]);
assert_eq!(fade.at(60.0), 0.5);
let heat = Interpolation::new([0.0, 0.5, 1.0], [BLUE, WHITE, RED]);Animated::interpolate is the reactive form, for a modifier that follows a value.
Implementations§
Source§impl<T> Interpolation<T>where
T: Lerp,
impl<T> Interpolation<T>where
T: Lerp,
Sourcepub fn new<const N: usize>(input: [f64; N], output: [T; N]) -> Interpolation<T>
pub fn new<const N: usize>(input: [f64; N], output: [T; N]) -> Interpolation<T>
The map through input[i] → output[i]. The inputs ascend; a map of one stop is
constant. An empty map does not compile.
Sourcepub fn extend(self) -> Interpolation<T>
pub fn extend(self) -> Interpolation<T>
Lets both outer segments run on past the range instead of clamping. A color’s channels still stay in range.
Sourcepub fn extend_start(self) -> Interpolation<T>
pub fn extend_start(self) -> Interpolation<T>
Lets the first segment run on below the range.
Sourcepub fn extend_end(self) -> Interpolation<T>
pub fn extend_end(self) -> Interpolation<T>
Lets the last segment run on above the range.
Trait Implementations§
Source§impl<T> Clone for Interpolation<T>
impl<T> Clone for Interpolation<T>
Source§fn clone(&self) -> Interpolation<T>
fn clone(&self) -> Interpolation<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for Interpolation<T>
impl<T> Debug for Interpolation<T>
Source§impl<T> PartialEq for Interpolation<T>
impl<T> PartialEq for Interpolation<T>
impl<T> StructuralPartialEq for Interpolation<T>
Auto Trait Implementations§
impl<T> Forget for Interpolation<T>
impl<T> Freeze for Interpolation<T>
impl<T> Move for Interpolation<T>
impl<T> RefUnwindSafe for Interpolation<T>
impl<T> Send for Interpolation<T>
impl<T> Sync for Interpolation<T>
impl<T> Unpin for Interpolation<T>
impl<T> UnsafeUnpin for Interpolation<T>
impl<T> UnwindSafe for Interpolation<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more