[][src]Enum tiny_skia::Shader

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

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)

A solid color shader.

LinearGradient(LinearGradient)

A linear gradient shader.

RadialGradient(RadialGradient)

A radial gradient shader.

Pattern(Pattern<'a>)

A pattern shader.

Implementations

impl<'a> Shader<'a>[src]

pub fn is_opaque(&self) -> bool[src]

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

pub fn transform(&mut self, ts: &Transform)[src]

Transforms the shader.

pub fn apply_opacity(&mut self, opacity: f32)[src]

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

impl<'a> Clone for Shader<'a>[src]

impl<'a> Debug for Shader<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Shader<'a>[src]

impl<'a> Send for Shader<'a>[src]

impl<'a> Sync for Shader<'a>[src]

impl<'a> Unpin for Shader<'a>[src]

impl<'a> UnwindSafe for Shader<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.