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 more