Type Alias Shader

Source
pub type Shader = RCHandle<SkShader>;

Aliased Type§

pub struct Shader(/* private fields */);

Implementations§

Source§

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.

Source

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.

Source

pub fn image(&self) -> Option<(Image, Matrix, (TileMode, TileMode))>

Returns iff this shader is backed by a single Image. If not, returns None.

Source

pub fn is_a_image(&self) -> bool

Source

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.

Source

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.

Source

pub fn with_working_color_space( &self, input_cs: impl Into<Option<ColorSpace>>, output_cs: impl Into<Option<ColorSpace>>, ) -> Self

Return a shader that will compute this shader in a context such that any child shaders return RGBA values converted to the input_cs colorspace.

It is then assumed that the RGBA values returned by this shader have been transformed into output_cs by the shader being wrapped. By default, shaders are assumed to return values in the destination colorspace and premultiplied. Using a different output_cs than input_cs allows custom shaders to replace the color management Skia normally performs w/o forcing authors to otherwise manipulate surface/image color info to avoid unnecessary or incorrect work.

If the shader is not performing colorspace conversion but needs to operate in the input_cs then it should have output_cs be the same as input_cs. Regardless of the output_cs here, the RGBA values of the returned Shader are always converted from output_cs to the destination surface color space.

A None input_cs is assumed to be the destination CS. A None output_cs is assumed to be the input_cs.

Source§

impl Shader

Source

pub fn fractal_perlin_noise( base_frequency: (scalar, scalar), num_octaves: usize, seed: scalar, tile_size: impl Into<Option<ISize>>, ) -> Option<Self>

Source

pub fn turbulence_perlin_noise( base_frequency: (scalar, scalar), num_octaves: usize, seed: scalar, tile_size: impl Into<Option<ISize>>, ) -> Option<Self>

Source§

impl Shader

Source

pub fn linear_gradient<'a>( points: (impl Into<Point>, impl Into<Point>), colors: impl Into<GradientShaderColors<'a>>, pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, flags: impl Into<Option<Flags>>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Self>

Source

pub fn linear_gradient_with_interpolation<'a>( points: (impl Into<Point>, impl Into<Point>), colors: (&[Color4f], impl Into<Option<ColorSpace>>), pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, interpolation: impl Into<Interpolation>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Self>

Source

pub fn radial_gradient<'a>( center: impl Into<Point>, radius: scalar, colors: impl Into<GradientShaderColors<'a>>, pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, flags: impl Into<Option<Flags>>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Self>

Source

pub fn radial_gradient_with_interpolation<'a>( center_and_radius: (impl Into<Point>, scalar), colors: (&[Color4f], impl Into<Option<ColorSpace>>), pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, interpolation: impl Into<Interpolation>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Shader>

Source

pub fn two_point_conical_gradient<'a>( start: impl Into<Point>, start_radius: scalar, end: impl Into<Point>, end_radius: scalar, colors: impl Into<GradientShaderColors<'a>>, pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, flags: impl Into<Option<Flags>>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Self>

Source

pub fn two_point_conical_gradient_with_interpolation<'a>( start_and_radius: (impl Into<Point>, scalar), end_and_radius: (impl Into<Point>, scalar), colors: (&[Color4f], impl Into<Option<ColorSpace>>), pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, interpolation: impl Into<Interpolation>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Shader>

Source

pub fn sweep_gradient<'a>( center: impl Into<Point>, colors: impl Into<GradientShaderColors<'a>>, pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, angles: impl Into<Option<(scalar, scalar)>>, flags: impl Into<Option<Flags>>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Self>

Source

pub fn sweep_gradient_with_interpolation<'a>( center: impl Into<Point>, colors: (&[Color4f], impl Into<Option<ColorSpace>>), pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, angles: impl Into<Option<(scalar, scalar)>>, interpolation: impl Into<Interpolation>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Shader>

Trait Implementations§

Source§

impl Debug for Shader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Shader

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for Shader

Source§

impl Sync for Shader