[−][src]Struct piet::LinearGradient
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: UnitPoint
end: UnitPoint
stops: ArrayVec<[GradientStop; 3]>
Methods
impl LinearGradient
[src][−]
pub fn new(
start: UnitPoint,
end: UnitPoint,
stops: impl GradientStops
) -> LinearGradient
[src][−]
start: UnitPoint,
end: UnitPoint,
stops: impl GradientStops
) -> LinearGradient
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
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,