Struct webrender_api::gradient_builder::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

source

pub fn new() -> Self

Create a new gradient builder.

source

pub fn with_stops(stops: Vec<GradientStop>) -> GradientBuilder

Create a gradient builder with a list of stops.

source

pub fn push(&mut self, stop: GradientStop)

Push an additional stop for the gradient.

source

pub fn stops(&self) -> &[GradientStop]

Get a reference to the list of stops.

source

pub fn into_stops(self) -> Vec<GradientStop>

Return the gradient stops vector.

source

pub fn gradient( &mut self, start_point: LayoutPoint, end_point: LayoutPoint, extend_mode: ExtendMode, ) -> Gradient

Produce a linear gradient, normalize the stops.

source

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.

source

pub fn conic_gradient( &mut self, center: LayoutPoint, angle: f32, extend_mode: ExtendMode, ) -> ConicGradient

Produce a conic gradient, normalize the stops.

source

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.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.