pub enum PaintBrush {
Color(Color),
Linear(LinearGradient),
Radial(RadialGradient),
Fixed(FixedGradient),
}
Expand description
A color or a gradient.
This type is provided as a convenience, so that library consumers can easily write methods and types that use or reference something that can be used as a brush, without needing to know what it is.
§Examples
use piet::{Color, PaintBrush, RadialGradient};
use piet::kurbo::Rect;
struct Widget {
frame: Rect,
background: PaintBrush,
}
fn make_widget<T: Into<PaintBrush>>(frame: Rect, bg: T) -> Widget {
Widget {
frame,
background: bg.into(),
}
}
let color_widget = make_widget(Rect::ZERO, Color::BLACK);
let rad_grad = RadialGradient::new(0.8, (Color::WHITE, Color::BLACK));
let gradient_widget = make_widget(Rect::ZERO, rad_grad);
Variants§
Trait Implementations§
Source§impl Clone for PaintBrush
impl Clone for PaintBrush
Source§fn clone(&self) -> PaintBrush
fn clone(&self) -> PaintBrush
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PaintBrush
impl Debug for PaintBrush
Source§impl From<Color> for PaintBrush
impl From<Color> for PaintBrush
Source§fn from(src: Color) -> PaintBrush
fn from(src: Color) -> PaintBrush
Converts to this type from the input type.
Source§impl From<FixedGradient> for PaintBrush
impl From<FixedGradient> for PaintBrush
Source§fn from(src: FixedGradient) -> PaintBrush
fn from(src: FixedGradient) -> PaintBrush
Converts to this type from the input type.
Source§impl From<FixedLinearGradient> for PaintBrush
impl From<FixedLinearGradient> for PaintBrush
Source§fn from(src: FixedLinearGradient) -> PaintBrush
fn from(src: FixedLinearGradient) -> PaintBrush
Converts to this type from the input type.
Source§impl From<FixedRadialGradient> for PaintBrush
impl From<FixedRadialGradient> for PaintBrush
Source§fn from(src: FixedRadialGradient) -> PaintBrush
fn from(src: FixedRadialGradient) -> PaintBrush
Converts to this type from the input type.
Source§impl From<LinearGradient> for PaintBrush
impl From<LinearGradient> for PaintBrush
Source§fn from(src: LinearGradient) -> PaintBrush
fn from(src: LinearGradient) -> PaintBrush
Converts to this type from the input type.
Source§impl From<RadialGradient> for PaintBrush
impl From<RadialGradient> for PaintBrush
Source§fn from(src: RadialGradient) -> PaintBrush
fn from(src: RadialGradient) -> PaintBrush
Converts to this type from the input type.
impl<P> IntoBrush<P> for PaintBrushwhere
P: RenderContext,
Auto Trait Implementations§
impl Freeze for PaintBrush
impl RefUnwindSafe for PaintBrush
impl Send for PaintBrush
impl Sync for PaintBrush
impl Unpin for PaintBrush
impl UnwindSafe for PaintBrush
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
Source§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.