[−][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]
fn clone(&self) -> LinearGradient
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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,
fn borrow_mut(&mut self) -> &mut T
[src]
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>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,