pub struct Gradient { /* private fields */ }Expand description
A resolved gradient with concrete color stops, ready for interpolation.
Implementations§
Source§impl Gradient
impl Gradient
Sourcepub fn new(
stops: impl Into<Box<[GradientStop]>>,
space: ColorSpace,
) -> Result<Self, PaletteError>
pub fn new( stops: impl Into<Box<[GradientStop]>>, space: ColorSpace, ) -> Result<Self, PaletteError>
Construct a gradient from concrete color stops.
Returns Err if fewer than 2 stops or positions are not monotonically
increasing.
Sourcepub fn at(&self, t: f64) -> Color
pub fn at(&self, t: f64) -> Color
Interpolate the gradient at position t (clamped to [0, 1]).
NaN returns the first stop color.
Sourcepub fn sample(&self, n: usize) -> Box<[Color]>
pub fn sample(&self, n: usize) -> Box<[Color]>
Sample n evenly spaced colors from the gradient.
n == 0: returns empty slicen == 1: returns[at(0.0)]n >= 2: endpoints guaranteed exact
Sourcepub fn stops(&self) -> &[GradientStop]
pub fn stops(&self) -> &[GradientStop]
The color stops in this gradient.
Sourcepub fn space(&self) -> ColorSpace
pub fn space(&self) -> ColorSpace
The interpolation color space.
Trait Implementations§
impl StructuralPartialEq for Gradient
Auto Trait Implementations§
impl Freeze for Gradient
impl RefUnwindSafe for Gradient
impl Send for Gradient
impl Sync for Gradient
impl Unpin for Gradient
impl UnsafeUnpin for Gradient
impl UnwindSafe for Gradient
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 more