RadialGradientBuilder

Struct RadialGradientBuilder 

Source
pub struct RadialGradientBuilder { /* private fields */ }
Expand description

A builder for creating radial gradients.

§Examples

use typwire::{Center, Gradient, Ratio, Stop, color};

let gradient = Gradient::radial_builder()
    .stops(vec![
        Stop::new(color::BLACK, Ratio::new(0.0)),
        Stop::new(color::WHITE, Ratio::new(1.0)),
    ])
    .center(Center::new(Ratio::new(0.5), Ratio::new(0.5)))
    .radius(Ratio::new(1.0))
    .focal_center(Center::new(Ratio::new(0.5), Ratio::new(0.5)))
    .focal_radius(Ratio::new(0.5))
    .build()
    .unwrap();

Implementations§

Source§

impl RadialGradientBuilder

Source

pub fn stops(self, stops: Vec<Stop>) -> Self

Sets the stops for the gradient.

§Examples
use typwire::{Gradient, Stop};

let builder = Gradient::radial_builder().stops(vec![]);
Source

pub fn stop(self, stop: Stop) -> Self

Adds a single stop to the gradient.

§Examples
use typwire::{Gradient, Ratio, Stop, color};

let builder = Gradient::radial_builder().stop(Stop::new(color::BLACK, Ratio::new(0.0)));
Source

pub const fn center(self, center: Center) -> Self

Sets the center point for the radial gradient.

§Examples
use typwire::{Center, Gradient, Ratio};

let builder = Gradient::radial_builder().center(Center::new(Ratio::new(0.5), Ratio::new(0.5)));
Source

pub const fn radius(self, radius: Ratio) -> Self

Sets the radius for the radial gradient.

§Examples
use typwire::{Gradient, Ratio};

let builder = Gradient::radial_builder().radius(Ratio::new(1.0));
Source

pub const fn focal_center(self, focal_center: Center) -> Self

Sets the focal center for the radial gradient.

§Examples
use typwire::{Center, Gradient, Ratio};

let builder =
    Gradient::radial_builder().focal_center(Center::new(Ratio::new(0.5), Ratio::new(0.5)));
Source

pub const fn focal_radius(self, focal_radius: Ratio) -> Self

Sets the focal radius for the radial gradient.

§Examples
use typwire::{Gradient, Ratio};

let builder = Gradient::radial_builder().focal_radius(Ratio::new(0.5));
Source

pub const fn space(self, space: ColorSpace) -> Self

Sets the color space for the gradient.

§Examples
use typwire::{ColorSpace, Gradient};

let builder = Gradient::radial_builder().space(ColorSpace::Rgb);
Source

pub fn build(self) -> Result<Gradient, GradientBuilderError>

Builds the radial gradient.

§Errors

Returns a GradientBuilderError if required fields are missing.

§Examples
use typwire::{Center, Gradient, Ratio, Stop, color};

let gradient = Gradient::radial_builder()
    .stops(vec![
        Stop::new(color::BLACK, Ratio::new(0.0)),
        Stop::new(color::WHITE, Ratio::new(1.0)),
    ])
    .center(Center::new(Ratio::new(0.5), Ratio::new(0.5)))
    .radius(Ratio::new(1.0))
    .focal_center(Center::new(Ratio::new(0.5), Ratio::new(0.5)))
    .focal_radius(Ratio::new(0.5))
    .build()
    .unwrap();

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.