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>) -> 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 Hash for GradientStops
impl Hash for GradientStops
Source§impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Hsla, L)]
impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Hsla, L)]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
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§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Hsva, L)]
impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Hsva, L)]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
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§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
Source§impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Rgba, L)]
impl<L: Into<Length> + Copy> IntoVar<GradientStops> for &[(Rgba, L)]
Source§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
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§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: 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§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
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§fn into_var(self) -> Var<GradientStops>
fn into_var(self) -> Var<GradientStops>
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§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
impl Eq 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 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<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
§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