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<Self>
pub fn new( spec: Option<Vec<(f32, &str)>>, preset: Option<Presets>, ) -> Result<Self>
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<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 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