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: ColorStopFirst color stop.
middle: Vec<GradientStop>Optional stops between start and end.
end: ColorStopLast 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 Hash for GradientStops
impl Hash for GradientStops
Source§impl<L> IntoVar<GradientStops> for &[(Hsla, L)]
impl<L> IntoVar<GradientStops> for &[(Hsla, L)]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§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_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl<L> IntoVar<GradientStops> for &[(Hsva, L)]
impl<L> IntoVar<GradientStops> for &[(Hsva, L)]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§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_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl<L> IntoVar<GradientStops> for &[(Rgba, L)]
impl<L> IntoVar<GradientStops> for &[(Rgba, L)]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§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_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl IntoVar<GradientStops> for &[Hsla]
impl IntoVar<GradientStops> for &[Hsla]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl<const N: usize> IntoVar<GradientStops> for &[Hsla; N]
impl<const N: usize> IntoVar<GradientStops> for &[Hsla; N]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl IntoVar<GradientStops> for &[Hsva]
impl IntoVar<GradientStops> for &[Hsva]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl<const N: usize> IntoVar<GradientStops> for &[Hsva; N]
impl<const N: usize> IntoVar<GradientStops> for &[Hsva; N]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl IntoVar<GradientStops> for &[Rgba]
impl IntoVar<GradientStops> for &[Rgba]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl<const N: usize> IntoVar<GradientStops> for &[Rgba; N]
impl<const N: usize> IntoVar<GradientStops> for &[Rgba; N]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§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_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§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_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§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_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl<const N: usize> IntoVar<GradientStops> for [Hsla; N]
impl<const N: usize> IntoVar<GradientStops> for [Hsla; N]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl<const N: usize> IntoVar<GradientStops> for [Hsva; N]
impl<const N: usize> IntoVar<GradientStops> for [Hsva; N]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl<const N: usize> IntoVar<GradientStops> for [Rgba; N]
impl<const N: usize> IntoVar<GradientStops> for [Rgba; N]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§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 Eq for GradientStops
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 T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.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,
§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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
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