pub type Shader = RCHandle<SkShader>;
Aliased Type§
struct Shader(/* private fields */);
Implementations§
Source§impl Shader
impl Shader
Shaders specify the source color(s) for what is being drawn. If a paint has no shader, then the paint’s color is used. If the paint has a shader, then the shader’s color(s) are use instead, but they are modulated by the paint’s alpha. This makes it easy to create a shader once (e.g. bitmap tiling or gradient) and then change its transparency w/o having to modify the original shader… only the paint’s alpha needs to be modified.
Sourcepub fn is_opaque(&self) -> bool
pub fn is_opaque(&self) -> bool
Returns true
if the shader is guaranteed to produce only opaque
colors, subject to the crate::Paint
using the shader to apply an opaque
alpha value. Subclasses should override this to allow some
optimizations.
Sourcepub fn image(&self) -> Option<(Image, Matrix, (TileMode, TileMode))>
pub fn image(&self) -> Option<(Image, Matrix, (TileMode, TileMode))>
Returns iff this shader is backed by a single Image
.
If not, returns None
.
pub fn is_a_image(&self) -> bool
Sourcepub fn with_local_matrix(&self, matrix: &Matrix) -> Self
pub fn with_local_matrix(&self, matrix: &Matrix) -> Self
Return a shader that will apply the specified local_matrix
to this shader.
The specified matrix will be applied before any matrix associated with this shader.
Sourcepub fn with_color_filter(&self, color_filter: impl Into<ColorFilter>) -> Self
pub fn with_color_filter(&self, color_filter: impl Into<ColorFilter>) -> Self
Create a new shader that produces the same colors as invoking this shader and then applying the color filter.
Sourcepub fn with_working_color_space(
&self,
color_space: impl Into<ColorSpace>,
) -> Self
pub fn with_working_color_space( &self, color_space: impl Into<ColorSpace>, ) -> Self
Return a shader that will compute this shader in a specific color space. By default, all shaders operate in the destination (surface) color space. The results of a shader are still always converted to the destination - this API has no impact on simple shaders or images. Primarily, it impacts shaders that perform mathematical operations, like Blend shaders, or runtime shaders.