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>) -> GradientStops
pub fn new(start: impl Into<Rgba>, end: impl Into<Rgba>) -> GradientStops
Gradients stops with two colors from start
to end
.
sourcepub fn from_colors<C>(colors: &[C]) -> GradientStops
pub fn from_colors<C>(colors: &[C]) -> GradientStops
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, T>(colors: &[C], transition: T) -> GradientStops
pub fn from_stripes<C, T>(colors: &[C], transition: T) -> GradientStops
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>(stops: &[C]) -> GradientStops
pub fn from_stops<C>(stops: &[C]) -> GradientStops
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>(&mut self, alpha: A)where
A: Into<RgbaComponent>,
pub fn set_alpha<A>(&mut self, alpha: A)where
A: Into<RgbaComponent>,
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<GradientStop>,
)
pub fn layout_linear( &self, axis: LayoutAxis, extend_mode: ExtendMode, line: &mut PxLine, render_stops: &mut Vec<GradientStop>, )
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<GradientStop>,
)
pub fn layout_radial( &self, axis: LayoutAxis, extend_mode: ExtendMode, render_stops: &mut Vec<GradientStop>, )
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<GradientStops, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<GradientStops, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl<L> From<&[(Hsla, L)]> for GradientStops
impl<L> From<&[(Hsla, L)]> for GradientStops
source§fn from(stops: &[(Hsla, L)]) -> GradientStops
fn from(stops: &[(Hsla, L)]) -> GradientStops
source§impl<L, const N: usize> From<&[(Hsla, L); N]> for GradientStops
impl<L, const N: usize> From<&[(Hsla, L); N]> for GradientStops
source§impl<L> From<&[(Hsva, L)]> for GradientStops
impl<L> From<&[(Hsva, L)]> for GradientStops
source§fn from(stops: &[(Hsva, L)]) -> GradientStops
fn from(stops: &[(Hsva, L)]) -> GradientStops
source§impl<L, const N: usize> From<&[(Hsva, L); N]> for GradientStops
impl<L, const N: usize> From<&[(Hsva, L); N]> for GradientStops
source§impl<L> From<&[(Rgba, L)]> for GradientStops
impl<L> From<&[(Rgba, L)]> for GradientStops
source§fn from(stops: &[(Rgba, L)]) -> GradientStops
fn from(stops: &[(Rgba, L)]) -> GradientStops
source§impl<L, const N: usize> From<&[(Rgba, L); N]> for GradientStops
impl<L, const N: usize> From<&[(Rgba, L); N]> for GradientStops
source§impl From<&[Hsla]> for GradientStops
impl From<&[Hsla]> for GradientStops
source§fn from(colors: &[Hsla]) -> GradientStops
fn from(colors: &[Hsla]) -> GradientStops
source§impl<const N: usize> From<&[Hsla; N]> for GradientStops
impl<const N: usize> From<&[Hsla; N]> for GradientStops
source§impl From<&[Hsva]> for GradientStops
impl From<&[Hsva]> for GradientStops
source§fn from(colors: &[Hsva]) -> GradientStops
fn from(colors: &[Hsva]) -> GradientStops
source§impl<const N: usize> From<&[Hsva; N]> for GradientStops
impl<const N: usize> From<&[Hsva; N]> for GradientStops
source§impl From<&[Rgba]> for GradientStops
impl From<&[Rgba]> for GradientStops
source§fn from(colors: &[Rgba]) -> GradientStops
fn from(colors: &[Rgba]) -> GradientStops
source§impl<const N: usize> From<&[Rgba; N]> for GradientStops
impl<const N: usize> From<&[Rgba; N]> for GradientStops
source§impl<L, const N: usize> From<[(Hsla, L); N]> for GradientStops
impl<L, const N: usize> From<[(Hsla, L); N]> for GradientStops
source§impl<L, const N: usize> From<[(Hsva, L); N]> for GradientStops
impl<L, const N: usize> From<[(Hsva, L); N]> for GradientStops
source§impl<L, const N: usize> From<[(Rgba, L); N]> for GradientStops
impl<L, const N: usize> From<[(Rgba, L); N]> for GradientStops
source§impl<const N: usize> From<[Hsla; N]> for GradientStops
impl<const N: usize> From<[Hsla; N]> for GradientStops
source§impl<const N: usize> From<[Hsva; N]> for GradientStops
impl<const N: usize> From<[Hsva; N]> for GradientStops
source§impl<const N: usize> From<[Rgba; N]> for GradientStops
impl<const N: usize> From<[Rgba; N]> for GradientStops
source§impl<L> IntoVar<GradientStops> for &[(Hsla, L)]
impl<L> IntoVar<GradientStops> for &[(Hsla, L)]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<L, const N: usize> IntoVar<GradientStops> for &[(Hsla, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for &[(Hsla, L); N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<L> IntoVar<GradientStops> for &[(Hsva, L)]
impl<L> IntoVar<GradientStops> for &[(Hsva, L)]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<L, const N: usize> IntoVar<GradientStops> for &[(Hsva, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for &[(Hsva, L); N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<L> IntoVar<GradientStops> for &[(Rgba, L)]
impl<L> IntoVar<GradientStops> for &[(Rgba, L)]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<L, const N: usize> IntoVar<GradientStops> for &[(Rgba, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for &[(Rgba, L); N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl IntoVar<GradientStops> for &[Hsla]
impl IntoVar<GradientStops> for &[Hsla]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<const N: usize> IntoVar<GradientStops> for &[Hsla; N]
impl<const N: usize> IntoVar<GradientStops> for &[Hsla; N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl IntoVar<GradientStops> for &[Hsva]
impl IntoVar<GradientStops> for &[Hsva]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<const N: usize> IntoVar<GradientStops> for &[Hsva; N]
impl<const N: usize> IntoVar<GradientStops> for &[Hsva; N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl IntoVar<GradientStops> for &[Rgba]
impl IntoVar<GradientStops> for &[Rgba]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<const N: usize> IntoVar<GradientStops> for &[Rgba; N]
impl<const N: usize> IntoVar<GradientStops> for &[Rgba; N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<L, const N: usize> IntoVar<GradientStops> for [(Hsla, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for [(Hsla, L); N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<L, const N: usize> IntoVar<GradientStops> for [(Hsva, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for [(Hsva, L); N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<L, const N: usize> IntoVar<GradientStops> for [(Rgba, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for [(Rgba, L); N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<const N: usize> IntoVar<GradientStops> for [Hsla; N]
impl<const N: usize> IntoVar<GradientStops> for [Hsla; N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<const N: usize> IntoVar<GradientStops> for [Hsva; N]
impl<const N: usize> IntoVar<GradientStops> for [Hsva; N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl<const N: usize> IntoVar<GradientStops> for [Rgba; N]
impl<const N: usize> IntoVar<GradientStops> for [Rgba; N]
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl PartialEq for GradientStops
impl PartialEq for GradientStops
source§impl Serialize for GradientStops
impl Serialize for GradientStops
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,
impl<L> IntoValue<GradientStops> for &[(Hsla, L)]
impl<L, const N: usize> IntoValue<GradientStops> for &[(Hsla, L); N]
impl<L> IntoValue<GradientStops> for &[(Hsva, L)]
impl<L, const N: usize> IntoValue<GradientStops> for &[(Hsva, L); N]
impl<L> IntoValue<GradientStops> for &[(Rgba, L)]
impl<L, 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, const N: usize> IntoValue<GradientStops> for [(Hsla, L); N]
impl<L, const N: usize> IntoValue<GradientStops> for [(Hsva, L); N]
impl<L, 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§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§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> 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>
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