pub struct Interpolator { /* private fields */ }Expand description
A interpolator that interpolates values in range.
Implementations§
Source§impl Interpolator
impl Interpolator
Sourcepub fn new(lower: f32, upper: f32) -> Self
pub fn new(lower: f32, upper: f32) -> Self
Create a new interpolator with the given lower and upper bounds.
§Examples
let interpolator = Interpolator::new(0.0, 1.0);
assert_eq!(interpolator.head(), 0.0);
assert_eq!(interpolator.tail(), 1.0);Sourcepub fn head(&self) -> f32
pub fn head(&self) -> f32
Get the left most value of the interpolator, if not set, the lower bound is returned.
§Examples
let mut interpolator = Interpolator::default();
assert_eq!(interpolator.head(), 0.0);
interpolator.insert(0, 0.5);
assert_eq!(interpolator.head(), 0.5);Sourcepub fn tail(&self) -> f32
pub fn tail(&self) -> f32
Get the right most value of the interpolator, if not set, the upper bound is returned.
§Examples
let mut interpolator = Interpolator::default();
assert_eq!(interpolator.tail(), 1.0);
interpolator.insert(65535, 0.5);
assert_eq!(interpolator.tail(), 0.5);Sourcepub fn insert(&mut self, key: u16, value: f32)
pub fn insert(&mut self, key: u16, value: f32)
Insert a new key value pair into the interpolator, overwriting any existing value.
§Examples
let mut gradient = Interpolator::default();
gradient.insert(0, 0.5);
gradient.insert(65535, 0.5);
assert_eq!(gradient.head(), 0.5);
assert_eq!(gradient.tail(), 0.5);Source§impl Interpolator
impl Interpolator
Trait Implementations§
Source§impl Clone for Interpolator
impl Clone for Interpolator
Source§fn clone(&self) -> Interpolator
fn clone(&self) -> Interpolator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Interpolator
impl Debug for Interpolator
Source§impl Default for Interpolator
impl Default for Interpolator
Source§impl<'de> Deserialize<'de> for Interpolator
impl<'de> Deserialize<'de> for Interpolator
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Interpolator
impl RefUnwindSafe for Interpolator
impl Send for Interpolator
impl Sync for Interpolator
impl Unpin for Interpolator
impl UnwindSafe for Interpolator
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,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().