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

GradientInfo

GradientType

If the shader subclass can be represented as a gradient, asAGradient returns

Type

Members:

Methods

Deserialize

__init__

asAGradient

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

kColor_GradientType

kConical_GradientType

kDrawLooper_Type

kDrawable_Type

kImageFilter_Type

kLast_GradientType

kLinear_GradientType

kMaskFilter_Type

kNone_GradientType

kPathEffect_Type

kPixelRef_Type

kRadial_GradientType

kShaderBase_Type

kSweep_GradientType

kUnused_Type

kUnused_Type2

kUnused_Type3

kUnused_Type4

Methods

static Shader.Deserialize(data: buffer) skia.Shader
Shader.__init__(*args, **kwargs)
Shader.asAGradient(self: skia.Shader, info: skia.Shader.GradientInfo) skia.Shader.GradientType
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.kColor_GradientType = <GradientType.kColor_GradientType: 1>
Shader.kConical_GradientType = <GradientType.kConical_GradientType: 5>
Shader.kDrawLooper_Type = <Type.kDrawLooper_Type: 2>
Shader.kDrawable_Type = <Type.kDrawable_Type: 1>
Shader.kImageFilter_Type = <Type.kImageFilter_Type: 3>
Shader.kLast_GradientType = <GradientType.kConical_GradientType: 5>
Shader.kLinear_GradientType = <GradientType.kLinear_GradientType: 2>
Shader.kMaskFilter_Type = <Type.kMaskFilter_Type: 4>
Shader.kNone_GradientType = <GradientType.kNone_GradientType: 0>
Shader.kPathEffect_Type = <Type.kPathEffect_Type: 5>
Shader.kPixelRef_Type = <Type.kPixelRef_Type: 6>
Shader.kRadial_GradientType = <GradientType.kRadial_GradientType: 3>
Shader.kShaderBase_Type = <Type.kShaderBase_Type: 8>
Shader.kSweep_GradientType = <GradientType.kSweep_GradientType: 4>
Shader.kUnused_Type = <Type.kUnused_Type: 9>
Shader.kUnused_Type2 = <Type.kUnused_Type2: 10>
Shader.kUnused_Type3 = <Type.kUnused_Type3: 11>
Shader.kUnused_Type4 = <Type.kUnused_Type4: 7>