Enum tiny_skia::Shader[][src]

pub enum Shader<'a> {
    SolidColor(Color),
    LinearGradient(LinearGradient),
    RadialGradient(RadialGradient),
    Pattern(Pattern<'a>),
}
Expand description

A shader specifies 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 without having to modify the original shader. Only the paint’s alpha needs to be modified.

Variants

SolidColor(Color)

Tuple Fields

0: Color

A solid color shader.

LinearGradient(LinearGradient)

Tuple Fields

A linear gradient shader.

RadialGradient(RadialGradient)

Tuple Fields

A radial gradient shader.

Pattern(Pattern<'a>)

Tuple Fields

0: Pattern<'a>

A pattern shader.

Implementations

Checks if the shader is guaranteed to produce only opaque colors.

Transforms the shader.

Shifts shader’s opacity.

opacity will be clamped to the 0..=1 range.

This is roughly the same as Skia’s SkPaint::setAlpha.

Unlike Skia, we do not support global alpha/opacity, which is in Skia is set via the alpha channel of the SkPaint::fColor4f. Instead, you can shift the opacity of the shader to whatever value you need.

  • For SolidColor this function will multiply color.alpha by opacity.
  • For gradients this function will multiply all colors by opacity.
  • For Pattern this function will multiply Patter::opacity by opacity.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.