pub struct ConicGradientBuilder { /* private fields */ }Expand description
A builder for creating conic gradients.
§Examples
use typwire::{Angle, Center, Gradient, Ratio, Stop, color};
let gradient = Gradient::conic_builder()
.stops(vec![
Stop::new(color::BLACK, Ratio::new(0.0)),
Stop::new(color::WHITE, Ratio::new(0.0)),
])
.angle(Angle::new(45.0))
.center(Center::new(Ratio::new(0.5), Ratio::new(0.5)))
.build()
.unwrap();Implementations§
Source§impl ConicGradientBuilder
impl ConicGradientBuilder
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::conic_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::conic_builder().stop(Stop::new(color::BLACK, Ratio::new(0.0)));Sourcepub const fn angle(self, angle: Angle) -> Self
pub const fn angle(self, angle: Angle) -> Self
Sets the angle for the conic gradient.
§Examples
use typwire::{Angle, Gradient};
let builder = Gradient::conic_builder().angle(Angle::new(45.0));Sourcepub const fn center(self, center: Center) -> Self
pub const fn center(self, center: Center) -> Self
Sets the center point for the conic gradient.
§Examples
use typwire::{Center, Gradient, Ratio};
let builder = Gradient::conic_builder().center(Center::new(Ratio::new(0.5), 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::conic_builder().space(ColorSpace::Rgb);Sourcepub fn build(self) -> Result<Gradient, GradientBuilderError>
pub fn build(self) -> Result<Gradient, GradientBuilderError>
Builds the conic gradient.
§Errors
Returns a GradientBuilderError if required fields are missing.
§Examples
use typwire::{Angle, Center, Gradient, Ratio, Stop, color};
let gradient = Gradient::conic_builder()
.stops(vec![
Stop::new(color::BLACK, Ratio::new(0.0)),
Stop::new(color::WHITE, Ratio::new(1.0)),
])
.angle(Angle::new(45.0))
.center(Center::new(Ratio::new(0.5), Ratio::new(0.5)))
.build()
.unwrap();