pub struct Gradient {
pub kind: GradientKind,
pub extend: Extend,
pub interpolation_cs: ColorSpaceTag,
pub hue_direction: HueDirection,
pub stops: ColorStops,
}
Expand description
Definition of a gradient that transitions between two or more colors.
Fields§
§kind: GradientKind
Kind and properties of the gradient.
extend: Extend
Extend mode.
interpolation_cs: ColorSpaceTag
The color space to be used for interpolation.
The colors in the color stops will be converted to this color space.
This defaults to sRGB.
hue_direction: HueDirection
When interpolating within a cylindrical color space, the direction for the hue.
This is interpreted as described in CSS Color Module Level 4 § 12.4.
stops: ColorStops
Color stop collection.
Implementations§
Source§impl Gradient
impl Gradient
Sourcepub fn new_linear(start: impl Into<Point>, end: impl Into<Point>) -> Self
pub fn new_linear(start: impl Into<Point>, end: impl Into<Point>) -> Self
Creates a new linear gradient for the specified start and end points.
Sourcepub fn new_radial(center: impl Into<Point>, radius: f32) -> Self
pub fn new_radial(center: impl Into<Point>, radius: f32) -> Self
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,
) -> Self
pub fn new_two_point_radial( start_center: impl Into<Point>, start_radius: f32, end_center: impl Into<Point>, end_radius: f32, ) -> Self
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,
) -> Self
pub fn new_sweep( center: impl Into<Point>, start_angle: f32, end_angle: f32, ) -> Self
Creates a new sweep gradient for the specified center point, start and end angles.
Sourcepub const fn with_extend(self, mode: Extend) -> Self
pub const fn with_extend(self, mode: Extend) -> Self
Builder method for setting the gradient extend mode.
Sourcepub const fn with_interpolation_cs(
self,
interpolation_cs: ColorSpaceTag,
) -> Self
pub const fn with_interpolation_cs( self, interpolation_cs: ColorSpaceTag, ) -> Self
Builder method for setting the interpolation color space.
Sourcepub const fn with_hue_direction(self, hue_direction: HueDirection) -> Self
pub const fn with_hue_direction(self, hue_direction: HueDirection) -> Self
Builder method for setting the hue direction when interpolating within a cylindrical color space.
Sourcepub fn with_stops(self, stops: impl ColorStopsSource) -> Self
pub fn with_stops(self, stops: impl ColorStopsSource) -> Self
Builder method for setting the color stop collection.
Sourcepub fn with_alpha(self, alpha: f32) -> Self
pub fn with_alpha(self, alpha: f32) -> Self
Returns the gradient with the alpha component for all color stops set to alpha
.
Sourcepub fn multiply_alpha(self, alpha: f32) -> Self
pub fn multiply_alpha(self, alpha: f32) -> Self
Returns the gradient with the alpha component for all color stops
multiplied by alpha
.