pub struct Gradient<C: Mix + Clone>(/* private fields */);
Expand description
A linear interpolation between colors.
It’s used to smoothly transition between a series of colors, that can be
either evenly spaced or have customized positions. The gradient is
continuous between the control points, but it’s possible to iterate over a
number of evenly spaced points using the take
method. Any point outside
the domain of the gradient will have the same color as the closest control
point.
Implementations§
source§impl<C: Mix + Clone> Gradient<C>
impl<C: Mix + Clone> Gradient<C>
sourcepub fn new<I: IntoIterator<Item = C>>(colors: I) -> Gradient<C>
pub fn new<I: IntoIterator<Item = C>>(colors: I) -> Gradient<C>
Create a gradient of evenly spaced colors with the domain [0.0, 1.0]. There must be at least one color.
sourcepub fn with_domain(colors: Vec<(C::Scalar, C)>) -> Gradient<C>
pub fn with_domain(colors: Vec<(C::Scalar, C)>) -> Gradient<C>
Create a gradient of colors with custom spacing and domain. There must be at least one color and they are expected to be ordered by their position value.
sourcepub fn get(&self, i: C::Scalar) -> C
pub fn get(&self, i: C::Scalar) -> C
Get a color from the gradient. The color of the closest control point
will be returned if i
is outside the domain.
sourcepub fn take(&self, n: usize) -> Take<'_, C> ⓘ
pub fn take(&self, n: usize) -> Take<'_, C> ⓘ
Take n
evenly spaced colors from the gradient, as an iterator.
Trait Implementations§
Auto Trait Implementations§
impl<C> RefUnwindSafe for Gradient<C>
impl<C> Send for Gradient<C>
impl<C> Sync for Gradient<C>
impl<C> Unpin for Gradient<C>
impl<C> UnwindSafe for Gradient<C>
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
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
source§impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
source§fn convert_into(self) -> U
fn convert_into(self) -> U
source§fn convert_unclamped_into(self) -> U
fn convert_unclamped_into(self) -> U
source§fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains the unclamped color. Read more