pub struct ColorGradient { /* private fields */ }Expand description
A class to represent a gradient of colors.
Implementations§
Source§impl ColorGradient
impl ColorGradient
Sourcepub fn new(
spec: Option<Vec<(f32, &str)>>,
preset: Option<Presets>,
) -> Result<ColorGradient, ImgGenSpecError>
pub fn new( spec: Option<Vec<(f32, &str)>>, preset: Option<Presets>, ) -> Result<ColorGradient, ImgGenSpecError>
Instantiate a ColorGradient object.
The spec parameter is an optional list of (f32, String) pairs.
The float value is a percentage ranging [0.0, 1.0] that describes
where the color (the str value) should take place.
See SolidColor::from_string() for supported String values that describe the color.
If spec parameter is not specified, then the optional preset parameter
(which defaults to Presets::MonoChrome) is used instead.
Sourcepub fn get_color_at(&self, position: f32, spread: &Spread) -> SolidColor
pub fn get_color_at(&self, position: f32, spread: &Spread) -> SolidColor
A helper function to get the interpolated color of the gradient at the specified position.
If position is beyond the range [0, 1.0], then the spread parameter is
applied accordingly. See the Spread for more details.
Trait Implementations§
Source§impl Clone for ColorGradient
impl Clone for ColorGradient
Source§fn clone(&self) -> ColorGradient
fn clone(&self) -> ColorGradient
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 Debug for ColorGradient
impl Debug for ColorGradient
Source§impl<'de> Deserialize<'de> for ColorGradient
impl<'de> Deserialize<'de> for ColorGradient
Source§fn deserialize<D>(
deserializer: D,
) -> Result<ColorGradient, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<ColorGradient, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for ColorGradient
impl Serialize for ColorGradient
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for ColorGradient
impl RefUnwindSafe for ColorGradient
impl Send for ColorGradient
impl Sync for ColorGradient
impl Unpin for ColorGradient
impl UnsafeUnpin for ColorGradient
impl UnwindSafe for ColorGradient
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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