pub struct LinearGradientBuilder { /* private fields */ }Expand description
A builder for creating linear gradients.
§Examples
use typwire::{Angle, ColorSpace, Gradient, Ratio, Stop, color};
let gradient = Gradient::linear_builder()
.stops(vec![
Stop::new(color::BLACK, Ratio::new(0.0)),
Stop::new(color::WHITE, Ratio::new(1.0)),
])
.angle(Angle::new(45.0))
.build()
.unwrap();Implementations§
Source§impl LinearGradientBuilder
impl LinearGradientBuilder
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::linear_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::linear_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 linear gradient.
§Examples
use typwire::{Angle, Gradient};
let builder = Gradient::linear_builder().angle(Angle::new(45.0));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::linear_builder().space(ColorSpace::Rgb);Sourcepub fn build(self) -> Result<Gradient, GradientBuilderError>
pub fn build(self) -> Result<Gradient, GradientBuilderError>
Builds the linear gradient.
§Errors
Returns a GradientBuilderError if required fields are missing.
§Examples
use typwire::{Angle, Gradient, Ratio, Stop, color};
let gradient = Gradient::linear_builder()
.stops(vec![
Stop::new(color::BLACK, Ratio::new(0.0)),
Stop::new(color::WHITE, Ratio::new(1.0)),
])
.angle(Angle::new(45.0))
.build()
.unwrap();Auto Trait Implementations§
impl Forget for LinearGradientBuilder
impl Freeze for LinearGradientBuilder
impl Move for LinearGradientBuilder
impl RefUnwindSafe for LinearGradientBuilder
impl Send for LinearGradientBuilder
impl Sync for LinearGradientBuilder
impl Unpin for LinearGradientBuilder
impl UnsafeUnpin for LinearGradientBuilder
impl UnwindSafe for LinearGradientBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more