Struct webrender_api::GradientBuilder
source · pub struct GradientBuilder {
stops: Vec<GradientStop>,
}
Expand description
Construct a gradient to be used in display lists.
Each gradient needs at least two stops.
Fields§
§stops: Vec<GradientStop>
Implementations§
source§impl GradientBuilder
impl GradientBuilder
sourcepub fn with_stops(stops: Vec<GradientStop>) -> GradientBuilder
pub fn with_stops(stops: Vec<GradientStop>) -> GradientBuilder
Create a gradient builder with a list of stops.
sourcepub fn push(&mut self, stop: GradientStop)
pub fn push(&mut self, stop: GradientStop)
Push an additional stop for the gradient.
sourcepub fn stops(&self) -> &[GradientStop]
pub fn stops(&self) -> &[GradientStop]
Get a reference to the list of stops.
sourcepub fn into_stops(self) -> Vec<GradientStop>
pub fn into_stops(self) -> Vec<GradientStop>
Return the gradient stops vector.
sourcepub fn gradient(
&mut self,
start_point: LayoutPoint,
end_point: LayoutPoint,
extend_mode: ExtendMode,
) -> Gradient
pub fn gradient( &mut self, start_point: LayoutPoint, end_point: LayoutPoint, extend_mode: ExtendMode, ) -> Gradient
Produce a linear gradient, normalize the stops.
sourcepub fn radial_gradient(
&mut self,
center: LayoutPoint,
radius: LayoutSize,
extend_mode: ExtendMode,
) -> RadialGradient
pub fn radial_gradient( &mut self, center: LayoutPoint, radius: LayoutSize, extend_mode: ExtendMode, ) -> RadialGradient
Produce a radial gradient, normalize the stops.
Will replace the gradient with a single color if the radius negative.
sourcepub fn conic_gradient(
&mut self,
center: LayoutPoint,
angle: f32,
extend_mode: ExtendMode,
) -> ConicGradient
pub fn conic_gradient( &mut self, center: LayoutPoint, angle: f32, extend_mode: ExtendMode, ) -> ConicGradient
Produce a conic gradient, normalize the stops.
sourcefn normalize(&mut self, extend_mode: ExtendMode) -> (f32, f32)
fn normalize(&mut self, extend_mode: ExtendMode) -> (f32, f32)
Gradients can be defined with stops outside the range of [0, 1] when this happens the gradient needs to be normalized by adjusting the gradient stops and gradient line into an equivalent gradient with stops in the range [0, 1]. this is done by moving the beginning of the gradient line to where stop[0] and the end of the gradient line to stop[n-1]. this function adjusts the stops in place, and returns the amount to adjust the gradient line start and stop.