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
impl RadialGradientBuilder
Sourcepub fn stops(self, stops: Vec<Stop>) -> Self
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![]);Sourcepub fn stop(self, stop: Stop) -> Self
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)));Sourcepub const fn center(self, center: Center) -> Self
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)));Sourcepub const fn radius(self, radius: Ratio) -> Self
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));Sourcepub const fn focal_center(self, focal_center: Center) -> Self
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)));Sourcepub const fn focal_radius(self, focal_radius: Ratio) -> Self
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));Sourcepub const fn space(self, space: ColorSpace) -> Self
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);Sourcepub fn build(self) -> Result<Gradient, GradientBuilderError>
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();