Struct zng_color::gradient::GradientStops
source · pub struct GradientStops {
pub start: ColorStop,
pub middle: Vec<GradientStop>,
pub end: ColorStop,
}
Expand description
Stops in a gradient.
Use stops!
to create a new instance, you can convert from arrays for simpler gradients.
Fields§
§start: ColorStop
First color stop.
middle: Vec<GradientStop>
Optional stops between start and end.
end: ColorStop
Last color stop.
Implementations§
source§impl GradientStops
impl GradientStops
sourcepub fn new(start: impl Into<Rgba>, end: impl Into<Rgba>) -> Self
pub fn new(start: impl Into<Rgba>, end: impl Into<Rgba>) -> Self
Gradients stops with two colors from start
to end
.
sourcepub fn from_colors<C: Into<Rgba> + Copy>(colors: &[C]) -> Self
pub fn from_colors<C: Into<Rgba> + Copy>(colors: &[C]) -> Self
Gradient stops from colors spaced equally.
The stops look like a sequence of positional only color stops but the proportional distribution is pre-calculated.
If less than 2 colors are given, the missing stops are filled with transparent color.
sourcepub fn from_stripes<C: Into<Rgba> + Copy, T: Into<Factor>>(
colors: &[C],
transition: T,
) -> Self
pub fn from_stripes<C: Into<Rgba> + Copy, T: Into<Factor>>( colors: &[C], transition: T, ) -> Self
Gradient stops from colors forming stripes of same length.
The transition
parameter controls relative length of the transition between two stripes.
1.0
or 100.pct()
is the length of a stripe, set to 0.0
to get hard-lines.
sourcepub fn from_stops<C: Into<ColorStop> + Copy>(stops: &[C]) -> Self
pub fn from_stops<C: Into<ColorStop> + Copy>(stops: &[C]) -> Self
Gradient stops from color stops.
If less than 2 colors are given, the missing stops are filled with transparent color.
sourcepub fn set_alpha<A: Into<RgbaComponent>>(&mut self, alpha: A)
pub fn set_alpha<A: Into<RgbaComponent>>(&mut self, alpha: A)
Set the alpha of all colors in the gradient.
sourcepub fn layout_linear(
&self,
axis: LayoutAxis,
extend_mode: ExtendMode,
line: &mut PxLine,
render_stops: &mut Vec<RenderGradientStop>,
)
pub fn layout_linear( &self, axis: LayoutAxis, extend_mode: ExtendMode, line: &mut PxLine, render_stops: &mut Vec<RenderGradientStop>, )
Computes the linear gradient in the current LAYOUT
context.
The axis
value selects the layout axis the offsets layout on.
The render_stops
content is replaced with stops with offset in the 0..=1
range.
The line
points are moved to accommodate input offsets outside the line bounds.
sourcepub fn layout_radial(
&self,
axis: LayoutAxis,
extend_mode: ExtendMode,
render_stops: &mut Vec<RenderGradientStop>,
)
pub fn layout_radial( &self, axis: LayoutAxis, extend_mode: ExtendMode, render_stops: &mut Vec<RenderGradientStop>, )
Computes the layout for a radial gradient.
The render_stops
content is replace with stops with offset in the 0..=1
range.
Trait Implementations§
source§impl Clone for GradientStops
impl Clone for GradientStops
source§fn clone(&self) -> GradientStops
fn clone(&self) -> GradientStops
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for GradientStops
impl Debug for GradientStops
source§impl<'de> Deserialize<'de> for GradientStops
impl<'de> Deserialize<'de> for GradientStops
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>,
source§impl<L: Into<Length> + Copy> From<&[(Hsla, L)]> for GradientStops
impl<L: Into<Length> + Copy> From<&[(Hsla, L)]> for GradientStops
source§impl<L: Into<Length> + Copy> From<&[(Hsva, L)]> for GradientStops
impl<L: Into<Length> + Copy> From<&[(Hsva, L)]> for GradientStops
source§impl<L: Into<Length> + Copy> From<&[(Rgba, L)]> for GradientStops
impl<L: Into<Length> + Copy> From<&[(Rgba, L)]> for GradientStops
source§impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Hsla, L)]
impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Hsla, L)]
source§impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for &[(Hsla, L); N]
impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for &[(Hsla, L); N]
source§impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Hsva, L)]
impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Hsva, L)]
source§impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for &[(Hsva, L); N]
impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for &[(Hsva, L); N]
source§impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Rgba, L)]
impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Rgba, L)]
source§impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for &[(Rgba, L); N]
impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for &[(Rgba, L); N]
source§impl IntoVar<GradientStops> for &[Hsla]
impl IntoVar<GradientStops> for &[Hsla]
source§impl<const N: usize> IntoVar<GradientStops> for &[Hsla; N]
impl<const N: usize> IntoVar<GradientStops> for &[Hsla; N]
source§impl IntoVar<GradientStops> for &[Hsva]
impl IntoVar<GradientStops> for &[Hsva]
source§impl<const N: usize> IntoVar<GradientStops> for &[Hsva; N]
impl<const N: usize> IntoVar<GradientStops> for &[Hsva; N]
source§impl IntoVar<GradientStops> for &[Rgba]
impl IntoVar<GradientStops> for &[Rgba]
source§impl<const N: usize> IntoVar<GradientStops> for &[Rgba; N]
impl<const N: usize> IntoVar<GradientStops> for &[Rgba; N]
source§impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for [(Hsla, L); N]
impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for [(Hsla, L); N]
source§impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for [(Hsva, L); N]
impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for [(Hsva, L); N]
source§impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for [(Rgba, L); N]
impl<L: Into<Length> + Copy, const N: usize> IntoVar<GradientStops> for [(Rgba, L); N]
source§impl<const N: usize> IntoVar<GradientStops> for [Hsla; N]
impl<const N: usize> IntoVar<GradientStops> for [Hsla; N]
source§impl<const N: usize> IntoVar<GradientStops> for [Hsva; N]
impl<const N: usize> IntoVar<GradientStops> for [Hsva; N]
source§impl<const N: usize> IntoVar<GradientStops> for [Rgba; N]
impl<const N: usize> IntoVar<GradientStops> for [Rgba; N]
source§impl PartialEq for GradientStops
impl PartialEq for GradientStops
source§impl Serialize for GradientStops
impl Serialize for GradientStops
impl<L: Into<Length> + Copy> IntoValue<GradientStops> for &[(Hsla, L)]
impl<L: Into<Length> + Copy, const N: usize> IntoValue<GradientStops> for &[(Hsla, L); N]
impl<L: Into<Length> + Copy> IntoValue<GradientStops> for &[(Hsva, L)]
impl<L: Into<Length> + Copy, const N: usize> IntoValue<GradientStops> for &[(Hsva, L); N]
impl<L: Into<Length> + Copy> IntoValue<GradientStops> for &[(Rgba, L)]
impl<L: Into<Length> + Copy, const N: usize> IntoValue<GradientStops> for &[(Rgba, L); N]
impl IntoValue<GradientStops> for &[Hsla]
impl<const N: usize> IntoValue<GradientStops> for &[Hsla; N]
impl IntoValue<GradientStops> for &[Hsva]
impl<const N: usize> IntoValue<GradientStops> for &[Hsva; N]
impl IntoValue<GradientStops> for &[Rgba]
impl<const N: usize> IntoValue<GradientStops> for &[Rgba; N]
impl<L: Into<Length> + Copy, const N: usize> IntoValue<GradientStops> for [(Hsla, L); N]
impl<L: Into<Length> + Copy, const N: usize> IntoValue<GradientStops> for [(Hsva, L); N]
impl<L: Into<Length> + Copy, const N: usize> IntoValue<GradientStops> for [(Rgba, L); N]
impl<const N: usize> IntoValue<GradientStops> for [Hsla; N]
impl<const N: usize> IntoValue<GradientStops> for [Hsva; N]
impl<const N: usize> IntoValue<GradientStops> for [Rgba; N]
impl StructuralPartialEq for GradientStops
Auto Trait Implementations§
impl Freeze for GradientStops
impl RefUnwindSafe for GradientStops
impl Send for GradientStops
impl Sync for GradientStops
impl Unpin for GradientStops
impl UnwindSafe for GradientStops
Blanket Implementations§
source§impl<T> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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