pub struct GradientRamp {
pub shape: RampShape,
pub stops: Vec<(f32, Color)>,
pub tile: TileMode,
pub transform: Affine,
}Expand description
What a layer does at compositing, for painting a scene by hand. A gradient with any number of stops, for a path: its shape, its colours, what it does past its ends, and where it sits.
The shape is in the gradient’s own space and transform takes it to the path’s, so a
gradient that is turned, skewed or squashed — an SVG gradientTransform, a bounding
box’s units — is drawn exactly: the renderer maps each pixel back into the gradient’s
space, where the shape is simple.
use frus_core::{Affine, Color, GradientRamp, Point, RampShape, TileMode};
let ramp = GradientRamp {
shape: RampShape::Linear { from: Point::new(0.0, 0.0), to: Point::new(100.0, 0.0) },
stops: vec![(0.0, Color::BLACK), (1.0, Color::WHITE)],
tile: TileMode::Clamp,
transform: Affine::default(),
};
assert_eq!(ramp.t_at(Point::new(25.0, 40.0)), Some(0.25));Fields§
§shape: RampShapeWhere the colours run, in the gradient’s own space.
stops: Vec<(f32, Color)>(offset, colour) pairs, offsets from 0 to 1 in order. A colour holds before
the first stop and after the last.
tile: TileModeWhat happens past the ends of the shape.
transform: AffineThe gradient’s space to the path’s.
Implementations§
Source§impl GradientRamp
impl GradientRamp
Sourcepub fn t_at(&self, p: Point) -> Option<f32>
pub fn t_at(&self, p: Point) -> Option<f32>
How far through the gradient the point p (in the path’s space) is, tiled; None
where nothing is drawn — past the ends of a TileMode::Decal one, or outside
both circles’ reach. What the renderer computes for every pixel.
Trait Implementations§
Source§impl Clone for GradientRamp
impl Clone for GradientRamp
Source§fn clone(&self) -> GradientRamp
fn clone(&self) -> GradientRamp
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GradientRamp
impl Debug for GradientRamp
Source§impl PartialEq for GradientRamp
impl PartialEq for GradientRamp
impl StructuralPartialEq for GradientRamp
Auto Trait Implementations§
impl Freeze for GradientRamp
impl RefUnwindSafe for GradientRamp
impl Send for GradientRamp
impl Sync for GradientRamp
impl Unpin for GradientRamp
impl UnsafeUnpin for GradientRamp
impl UnwindSafe for GradientRamp
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.