Shader

class 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.

Subclasses

Shaders

GradientShader

PerlinNoiseShader

PerlinNoiseShader creates an image using the Perlin turbulence function.

Classes

Type

Members:

Methods

Deserialize

__init__

getFlattenableType

getTypeName

Returns the name of the object's class.

isAImage

Overloaded function.

isOpaque

Returns true if the shader is guaranteed to produce only opaque colors, subject to the Paint using the shader to apply an opaque alpha value.

makeWithColorFilter

Create a new shader that produces the same colors as invoking this shader and then applying the colorfilter.

makeWithLocalMatrix

Return a shader that will apply the specified localMatrix to this shader.

ref

Increment the reference count.

serialize

unique

May return true if the caller is the only owner.

unref

Decrement the reference count.

Attributes

kColorFilter_Type

kDrawLooper_Type

kDrawable_Type

kImageFilter_Type

kMaskFilter_Type

kPathEffect_Type

Methods

static Shader.Deserialize(type: skia.Flattanable.Type, b: buffer) skia.Flattanable
Shader.__init__(*args, **kwargs)
Shader.getFlattenableType(self: skia.Flattanable) skia.Flattanable.Type
Shader.getTypeName(self: skia.Flattanable) str

Returns the name of the object’s class.

Implemented in Drawable.

Shader.isAImage(*args, **kwargs)

Overloaded function.

  1. isAImage(self: skia.Shader, localMatrix: skia.Matrix, xy: List[skia.TileMode] = None) -> skia.Image

    Iff this shader is backed by a single Image, return its ptr (the caller must ref this if they want to keep it longer than the lifetime of the shader).

    If not, return nullptr.

  2. isAImage(self: skia.Shader) -> bool

Shader.isOpaque(self: skia.Shader) bool

Returns true if the shader is guaranteed to produce only opaque colors, subject to the Paint using the shader to apply an opaque alpha value.

Subclasses should override this to allow some optimizations.

Shader.makeWithColorFilter(self: skia.Shader, colorFilter: skia.ColorFilter) skia.Shader

Create a new shader that produces the same colors as invoking this shader and then applying the colorfilter.

Shader.makeWithLocalMatrix(self: skia.Shader, matrix: skia.Matrix) skia.Shader

Return a shader that will apply the specified localMatrix to this shader.

The specified matrix will be applied before any matrix associated with this shader.

Shader.ref(self: skia.RefCntBase) None

Increment the reference count.

Must be balanced by a call to unref().

Shader.serialize(self: skia.Flattanable) skia.Data
Shader.unique(self: skia.RefCntBase) bool

May return true if the caller is the only owner.

Ensures that all previous owner’s actions are complete.

Shader.unref(self: skia.RefCntBase) None

Decrement the reference count.

If the reference count is 1 before the decrement, then delete the object. Note that if this is the case, then the object needs to have been allocated via new, and not on the stack.

Attributes

Shader.kColorFilter_Type = <Type.kColorFilter_Type: 0>
Shader.kDrawLooper_Type = <Type.kDrawLooper_Type: 3>
Shader.kDrawable_Type = <Type.kDrawable_Type: 2>
Shader.kImageFilter_Type = <Type.kImageFilter_Type: 4>
Shader.kMaskFilter_Type = <Type.kMaskFilter_Type: 5>
Shader.kPathEffect_Type = <Type.kPathEffect_Type: 6>