pub struct Gradient {
pub kind: GradientKind,
pub extend: Extend,
pub interpolation_cs: ColorSpaceTag,
pub hue_direction: HueDirection,
pub interpolation_alpha_space: InterpolationAlphaSpace,
pub stops: ColorStops,
}Expand description
Definition of a gradient that transitions between two or more colors.
Fields§
§kind: GradientKindKind and properties of the gradient.
extend: ExtendExtend mode.
interpolation_cs: ColorSpaceTagThe color space to be used for interpolation.
The gradient’s color ramps will be interpolated linearly in this color space between the specified color stops.
This defaults to sRGB.
hue_direction: HueDirectionWhen interpolating within a cylindrical color space, the direction for the hue.
This is interpreted as described in CSS Color Module Level 4 § 12.4.
interpolation_alpha_space: InterpolationAlphaSpaceAlpha space to be used for interpolation
stops: ColorStopsColor stop collection.
Implementations§
Source§impl Gradient
impl Gradient
Sourcepub fn new_linear(start: impl Into<Point>, end: impl Into<Point>) -> Gradient
pub fn new_linear(start: impl Into<Point>, end: impl Into<Point>) -> Gradient
Creates a new linear gradient for the specified start and end points.
Sourcepub fn new_radial(center: impl Into<Point>, radius: f32) -> Gradient
pub fn new_radial(center: impl Into<Point>, radius: f32) -> Gradient
Creates a new radial gradient for the specified center point and radius.
Sourcepub fn new_two_point_radial(
start_center: impl Into<Point>,
start_radius: f32,
end_center: impl Into<Point>,
end_radius: f32,
) -> Gradient
pub fn new_two_point_radial( start_center: impl Into<Point>, start_radius: f32, end_center: impl Into<Point>, end_radius: f32, ) -> Gradient
Creates a new two point radial gradient for the specified center points and radii.
Sourcepub fn new_sweep(
center: impl Into<Point>,
start_angle: f32,
end_angle: f32,
) -> Gradient
pub fn new_sweep( center: impl Into<Point>, start_angle: f32, end_angle: f32, ) -> Gradient
Creates a new sweep gradient for the specified center point, start and end angles.
Sourcepub const fn with_extend(self, mode: Extend) -> Gradient
pub const fn with_extend(self, mode: Extend) -> Gradient
Builder method for setting the gradient extend mode.
Sourcepub const fn with_interpolation_cs(
self,
interpolation_cs: ColorSpaceTag,
) -> Gradient
pub const fn with_interpolation_cs( self, interpolation_cs: ColorSpaceTag, ) -> Gradient
Builder method for setting the interpolation color space.
Sourcepub const fn with_interpolation_alpha_space(
self,
interpolation_alpha_space: InterpolationAlphaSpace,
) -> Gradient
pub const fn with_interpolation_alpha_space( self, interpolation_alpha_space: InterpolationAlphaSpace, ) -> Gradient
Builder method for setting the interpolation alpha space.
Sourcepub const fn with_hue_direction(self, hue_direction: HueDirection) -> Gradient
pub const fn with_hue_direction(self, hue_direction: HueDirection) -> Gradient
Builder method for setting the hue direction when interpolating within a cylindrical color space.
Sourcepub fn with_stops(self, stops: impl ColorStopsSource) -> Gradient
pub fn with_stops(self, stops: impl ColorStopsSource) -> Gradient
Builder method for setting the color stop collection.
Sourcepub fn with_alpha(self, alpha: f32) -> Gradient
pub fn with_alpha(self, alpha: f32) -> Gradient
Returns the gradient with the alpha component for all color stops set to alpha.
Sourcepub fn multiply_alpha(self, alpha: f32) -> Gradient
pub fn multiply_alpha(self, alpha: f32) -> Gradient
Returns the gradient with the alpha component for all color stops
multiplied by alpha.
Trait Implementations§
impl StructuralPartialEq for Gradient
Auto Trait Implementations§
impl Freeze for Gradient
impl RefUnwindSafe for Gradient
impl Send for Gradient
impl Sync for Gradient
impl Unpin for Gradient
impl UnwindSafe for Gradient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.