pub enum Shader {
Linear {
start: Point,
end: Point,
stops: Vec<GradientStop>,
spread: SpreadMode,
local: Matrix,
},
Radial {
center: Point,
radius: f32,
stops: Vec<GradientStop>,
spread: SpreadMode,
focus: Option<FocalCircle>,
local: Matrix,
},
Sweep {
center: Point,
start_angle: f32,
stops: Vec<GradientStop>,
local: Matrix,
},
Image {
image: Image,
sampling: Sampling,
local: Matrix,
},
}Expand description
Shader determines the color painted at each point of a drawing operation.
Shader coordinates begin in the draw’s local coordinate space, so shaders follow the same transforms as their geometry.
Variants§
Linear
Linear interpolates colors along the line from start to end.
Fields
stops: Vec<GradientStop>stops defines the colors along the gradient.
spread: SpreadModespread controls colors outside the zero-to-one span.
local: Matrixlocal transforms the shader independently of the drawn geometry.
Use Matrix::IDENTITY when no additional transform is needed.
Radial
Radial interpolates between a start circle and an end circle.
Fields
stops: Vec<GradientStop>stops defines the colors along the gradient.
spread: SpreadModespread controls colors outside the zero-to-one span.
focus: Option<FocalCircle>focus is the optional start circle.
None starts at a zero-radius circle centered on center.
Sweep
Sweep interpolates colors around one full clockwise turn.
Fields
stops: Vec<GradientStop>stops defines the colors around the sweep.
Image
Image samples an image across the drawn geometry.
Implementations§
Source§impl Shader
impl Shader
Sourcepub fn stops(&self) -> &[GradientStop]
pub fn stops(&self) -> &[GradientStop]
stops returns this gradient’s stops or an empty slice for image shaders.
Sourcepub fn fold_color_filter(&mut self, filter: &ColorFilter) -> bool
pub fn fold_color_filter(&mut self, filter: &ColorFilter) -> bool
fold_color_filter applies a color filter directly to gradient stops.
It returns false for image shaders, whose colors must be filtered
during sampling.