[][src]Enum piet::PaintBrush

pub enum PaintBrush {
    Color(Color),
    Linear(LinearGradient),
    Radial(RadialGradient),
    Fixed(FixedGradient),
}

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

Color(Color)Linear(LinearGradient)Radial(RadialGradient)Fixed(FixedGradient)

Trait Implementations

impl<P: RenderContext> IntoBrush<P> for PaintBrush[src]

impl From<Color> for PaintBrush[src]

impl From<LinearGradient> for PaintBrush[src]

impl From<RadialGradient> for PaintBrush[src]

impl From<FixedGradient> for PaintBrush[src]

impl From<FixedLinearGradient> for PaintBrush[src]

impl From<FixedRadialGradient> for PaintBrush[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]