[][src]Struct piet::LinearGradient

pub struct LinearGradient {
    start: UnitPoint,
    end: UnitPoint,
    stops: ArrayVec<[GradientStop; 3]>,
}

A description of a linear gradient in the unit rect, which can be resolved to a fixed gradient.

The start and end points in the gradient are given in UnitPoint coordinates, which are then resolved to image-space coordinates for any given concrete Rect.

When the fixed coordinates are known, use FixedLinearGradient instead.

Fields

start: UnitPointend: UnitPointstops: ArrayVec<[GradientStop; 3]>

Methods

impl LinearGradient[src]

pub fn new(
    start: UnitPoint,
    end: UnitPoint,
    stops: impl GradientStops
) -> LinearGradient
[src]

Create a new linear gradient.

The start and end coordinates are UnitPoint coordinates, relative to the geometry of the shape being drawn.

Examples

use piet::{Color, RenderContext, LinearGradient, UnitPoint};
use piet::kurbo::{Circle, Point};

let circle = Circle::new(Point::new(100.0, 100.0), 50.0);
let gradient = LinearGradient::new(
    UnitPoint::TOP,
    UnitPoint::BOTTOM,
    (Color::WHITE, Color::BLACK)
);
render_ctx.fill(circle, &gradient);

fn resolve(&self, rect: Rect) -> FixedLinearGradient[src]

Generate a FixedLinearGradient by mapping points in the unit square onto points in rect.

Trait Implementations

impl Clone for LinearGradient[src]

Auto Trait Implementations

impl Send for LinearGradient

impl Sync for LinearGradient

impl Unpin for LinearGradient

Blanket Implementations

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

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

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

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.