skia
Python Skia binding module.
Functions
Returns true if |
|
Set the result with fill type winding to area equivalent to path. |
|
Returns true if 'mode' is a coefficient-based blend mode (<= kLastCoeffMode). |
|
Returns name of blendMode as null-terminated C string. |
|
Returns color value from 8-bit component values. |
|
Returns alpha byte from color value. |
|
Returns blue component of color, from zero to 255. |
|
Returns green component of color, from zero to 255. |
|
Returns red component of color, from zero to 255. |
|
Returns unpremultiplied color with red, blue, and green set from c; and alpha set from a. |
|
Returns color value from 8-bit component values. |
|
Returns color value from 8-bit component values, with alpha set fully opaque to 255. |
|
Converts ARGB to its HSV components. |
|
Returns the number of bytes required to store a pixel, including unused padding. |
|
Returns true if |
|
Returns true if canonical can be set to a valid |
|
Returns true if all pixels are opaque. |
|
Given an encoded origin and the width and height of the source data, returns a matrix that transforms the source rectangle with upper left corner at [0, 0] and origin to a correctly oriented destination rectangle of [0, 0, w, h]. |
|
Converts HSV components to an ARGB color. |
|
Set this path to the result of applying the Op to this path and the specified path: this = (this op operand). |
|
Returns a SkPMColor value from unpremultiplied 8-bit component values. |
|
Returns pmcolor closest to color c. |
|
Converts RGB to its HSV components. |
|
Set this path to a set of non-overlapping contours that describe the same area as the original path. |
|
Set the resulting rectangle to the tight bounds of the path. |
Classes
Members: |
|
Members: |
|
Stack helper class calls |
|
|
|
Members: |
|
For Porter-Duff SkBlendModes (those <= kLastCoeffMode), these coefficients |
|
Members: |
|
Indicates whether an allocation should count against a cache budget. |
|
|
|
Members: |
|
|
|
RGBA color value, holding four floating point components. |
|
Describes different color channels one can manipulate. |
|
Used to represent the channels available in a color type or texture format |
|
ColorFilters are optional objects in the drawing pipeline. |
|
Describes pixel and encoding. |
|
Members: |
|
Describes geometric operations (ala |
|
|
|
|
|
High-level API for creating a document-based canvas. |
|
Base-class for objects that draw into |
|
Enum describing format of encoded data. |
|
Image orientation values from their encoded EXIF data |
|
Members: |
|
|
|
|
|
Represents a set of actual arguments for a font. |
|
Members: |
|
The metrics of an |
|
Font manager that knows system fonts. |
|
Possible 3D APIs that may be used by Ganesh. |
|
alias of |
|
Members: |
|
alias of |
|
alias of |
|
Struct to supply options to flush calls. |
|
A GrContext's cache of backend context state can be partially invalidated. |
|
Members: |
|
Used to say whether a texture has mip levels allocated or not. |
|
Members: |
|
Members: |
|
Members: |
|
Members: |
|
Members: |
|
Members: |
|
The BackendContext contains all of the base Vulkan objects needed by the GrVkGpu. |
|
When wrapping a GrBackendTexture or GrBackendRendenderTarget, the fCurrentQueueFamily should either be VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_EXTERNAL, or VK_QUEUE_FAMILY_FOREIGN_EXT. |
|
Configuration struct for |
|
Color filter that provides transformations to improve contrast for users with low vision. |
|
|
|
|
|
|
|
Base class for image filters. |
|
Describes pixel dimensions and encoding. |
|
|
|
4x4 matrix used by |
|
|
|
|
|
Members: |
|
Perform a series of path operations, optimized for unioning many paths together. |
|
Uses the value in the src alpha channel to set the dst pixel. |
|
|
|
|
|
Members: |
|
|
|
Members: |
|
The logical operations that can be performed when combining two paths. |
|
Members: |
|
Members: |
|
|
|
Description of how the LCD strips are arranged for each pixel. |
|
This class is the smart container for pixel memory, and is used with |
|
|
|
|
|
|
|
|
|
A compressed form of a rotation+scale matrix. |
|
|
|
|
|
alias of |
|
alias of |
|
alias of |
|
Shaders specify the source color(s) for what is being drawn. |
|
|
|
|
|
Describes properties and constraints of a given |
|
alias of |
|
Applies a table lookup on each of the alpha values in the mask. |
|
|
|
Helper class for constructing |
|
Members: |
|
Members: |
|
The |
|
An immutable set of vertex data that can be used with |
|
Members: |
|
Members: |
|
Subclasses |
|
Specifies the structure of planes for a YUV image with optional alpha. |
|
Helper to store |
|
Members: |
|
Possible 3D APIs that may be used by Graphite. |
|
Members: |
|
Members: |
|
Members: |
|
Members: |
|
Functions
- AlphaTypeIsOpaque(at: skia.AlphaType) bool
Returns true if
AlphaType
equalskOpaque_AlphaType
.kOpaque_AlphaType
is a hint that theColorType
is opaque, or that all alpha values are set to their 1.0 equivalent. IfAlphaType
iskOpaque_AlphaType
, andColorType
is not opaque, then the result of drawing any pixel with a alpha value less than 1.0 is undefined.
- AsWinding(path: skia.Path) skia.Path
Set the result with fill type winding to area equivalent to path.
Returns true if successful. Does not detect if path contains contours which contain self-crossings or cross other contours; in these cases, may return true even though result does not fill same area as path.
Returns if operation was able to produce a result; otherwise, throws a runtime error. The result may be the input.
- Parameters:
path – The path typically with fill type set to even odd.
- Returns:
The equivalent path with fill type set to winding.
- BlendMode_AsCoeff(mode: skia.BlendMode, src: skia.BlendModeCoeff, dst: skia.BlendModeCoeff) bool
Returns true if ‘mode’ is a coefficient-based blend mode (<= kLastCoeffMode).
If true is returned, the mode’s src and dst coefficient functions are set in ‘src’ and ‘dst’.
- BlendMode_Name(blendMode: skia.BlendMode) str
Returns name of blendMode as null-terminated C string.
- Color(r: int, g: int, b: int, a: int = 255) int
Returns color value from 8-bit component values.
In Skia, colors are represented as 32-bit ARGB word, where each component has 8-bit. Colors can be specified by Python literal or constructed from the functions.
Floating point representation is available via
Color4f
.Example:
c = 0xFFFF0000 # ARGB c = skia.Color(255, 0, 0) # RGB c = skia.Color(255, 0, 0, 255) # RGBA c = skia.ColorSetRGB(255, 255, 0, 0) # RGB c = skia.ColorSetARGB(255, 255, 0, 0) # ARGB
Asserts if SK_DEBUG is defined if a, r, g, or b exceed 255. Since color is unpremultiplied, a may be smaller than the largest of r, g, and b.
- Parameters:
r (int) – amount of red, from no red (0) to full red (255)
g (int) – amount of green, from no green (0) to full green (255)
b (int) – amount of blue, from no blue (0) to full blue (255)
a (int) – amount of alpha, from fully transparent (0) to fully opaque (255)
- Returns:
color and alpha, unpremultiplied
- ColorGetA(color: int) int
Returns alpha byte from color value.
- ColorGetB(color: int) int
Returns blue component of color, from zero to 255.
- ColorGetG(color: int) int
Returns green component of color, from zero to 255.
- ColorGetR(color: int) int
Returns red component of color, from zero to 255.
- ColorSetA(c: int, a: int) int
Returns unpremultiplied color with red, blue, and green set from c; and alpha set from a.
Alpha component of c is ignored and is replaced by a in result.
- Parameters:
c (int) – packed RGB, eight bits per component
a (int) – alpha: transparent at zero, fully opaque at 255
- Returns:
color with transparency
- ColorSetARGB(a: int, r: int, g: int, b: int) int
Returns color value from 8-bit component values.
Asserts if SK_DEBUG is defined if a, r, g, or b exceed 255. Since color is unpremultiplied, a may be smaller than the largest of r, g, and b.
- Parameters:
a (int) – amount of alpha, from fully transparent (0) to fully opaque (255)
r (int) – amount of red, from no red (0) to full red (255)
g (int) – amount of green, from no green (0) to full green (255)
b (int) – amount of blue, from no blue (0) to full blue (255)
- Returns:
color and alpha, unpremultiplied
- ColorSetRGB(r: int, g: int, b: int) int
Returns color value from 8-bit component values, with alpha set fully opaque to 255.
- ColorToHSV(color: int) list[float]
Converts ARGB to its HSV components.
Alpha in ARGB is ignored. hsv[0] contains hsv hue, and is assigned a value from zero to less than 360. hsv[1] contains hsv saturation, a value from zero to one. hsv[2] contains hsv value, a value from zero to one.
- Parameters:
color (int) – ARGB color to convert
- Returns:
three element array which holds the resulting HSV components
- ColorTypeBytesPerPixel(ct: skia.ColorType) int
Returns the number of bytes required to store a pixel, including unused padding.
Returns zero if ct is
kUnknown_ColorType
or invalid.- Returns:
bytes per pixel
- ColorTypeIsAlwaysOpaque(ct: skia.ColorType) bool
Returns true if
ColorType
always decodes alpha to 1.0, making the pixel fully opaque.If true,
ColorType
does not reserve bits to encode alpha.- Returns:
true if alpha is always set to 1.0
- ColorTypeValidateAlphaType(colorType: skia.ColorType, alphaType: skia.AlphaType, canonical: skia.AlphaType = None) bool
Returns true if canonical can be set to a valid
AlphaType
for colorType.If there is more than one valid canonical
AlphaType
, set to alphaType, if valid. If true is returned and canonical is not nullptr, store validAlphaType
.Returns false only if alphaType is
kUnknown_AlphaType
, color type is notkUnknown_ColorType
, andColorType
is not always opaque. If false is returned, canonical is ignored.
- ComputeIsOpaque(bm: skia.Bitmap) bool
Returns true if all pixels are opaque.
ColorType
determines how pixels are encoded, and whether pixel describes alpha. Returns true forColorType
without alpha in each pixel; for otherColorType
, returns true if all pixels have alpha values equivalent to 1.0 or greater.For
ColorType
kRGB_565_ColorType
orkGray_8_ColorType
: always returns true. ForColorType
kAlpha_8_ColorType
,kBGRA_8888_ColorType
,kRGBA_8888_ColorType
: returns true if all pixel alpha values are 255. ForColorType
kARGB_4444_ColorType
: returns true if all pixel alpha values are 15. ForkRGBA_F16_ColorType
: returns true if all pixel alpha values are 1.0 or greater.Returns false for
kUnknown_ColorType
.- Parameters:
bm (skia.Bitmap) –
Bitmap
to check- Returns:
true if all pixels have opaque values or
ColorType
is opaque
- EncodedOriginToMatrix(origin: skia.EncodedOrigin, w: int, h: int) skia.Matrix
Given an encoded origin and the width and height of the source data, returns a matrix that transforms the source rectangle with upper left corner at [0, 0] and origin to a correctly oriented destination rectangle of [0, 0, w, h].
- HSVToColor(hsv: list[float], alpha: int = 255) int
Converts HSV components to an ARGB color.
Alpha is passed through unchanged. hsv[0] represents hsv hue, an angle from zero to less than 360. hsv[1] represents hsv saturation, and varies from zero to one. hsv[2] represents hsv value, and varies from zero to one.
Out of range hsv values are pinned.
- Parameters:
hsv – three element array which holds the input HSV components
alpha – alpha component of the returned ARGB color
- Returns:
ARGB equivalent to HSV
- MakeNullCanvas() skia.Canvas
- Op(one: skia.Path, two: skia.Path, op: skia.PathOp) skia.Path
Set this path to the result of applying the Op to this path and the specified path: this = (this op operand).
The resulting path will be constructed from non-overlapping contours. The curve order is reduced where possible so that cubics may be turned into quadratics, and quadratics maybe turned into lines.
Returns if operation was able to produce a result; otherwise, throws a runtime error.
- Parameters:
one – The first operand (for difference, the minuend)
two – The second operand (for difference, the subtrahend)
op – The operator to apply.
- Returns:
The product of the operands. The result may be one of the inputs.
- PathFillType_ConvertToNonInverse(ft: skia.PathFillType) skia.PathFillType
- PathFillType_IsEvenOdd(ft: skia.PathFillType) bool
- PathFillType_IsInverse(ft: skia.PathFillType) bool
- PreMultiplyARGB(a: int, r: int, g: int, b: int) int
Returns a SkPMColor value from unpremultiplied 8-bit component values.
- Parameters:
a – amount of alpha, from fully transparent (0) to fully opaque (255)
r – amount of red, from no red (0) to full red (255)
g – amount of green, from no green (0) to full green (255)
b – amount of blue, from no blue (0) to full blue (255)
- Returns:
premultiplied color
- PreMultiplyColor(c: int) int
Returns pmcolor closest to color c.
Multiplies c RGB components by the c alpha, and arranges the bytes to match the format of kN32_ColorType.
- Parameters:
c – unpremultiplied ARGB color
- Returns:
premultiplied color
- RGBToHSV(red: int, green: int, blue: int) list[float]
Converts RGB to its HSV components.
hsv[0] contains hsv hue, a value from zero to less than 360. hsv[1] contains hsv saturation, a value from zero to one. hsv[2] contains hsv value, a value from zero to one.
- Parameters:
red (int) – red component value from zero to 255
green (int) – green component value from zero to 255
blue (int) – blue component value from zero to 255
- Returns:
three element array which holds the resulting HSV components
- Simplify(path: skia.Path) skia.Path
Set this path to a set of non-overlapping contours that describe the same area as the original path.
The curve order is reduced where possible so that cubics may be turned into quadratics, and quadratics maybe turned into lines.
Returns if operation was able to produce a result; otherwise, throws a runtime error.
- Parameters:
path – The path to simplify.
- Returns:
The simplified path. The result may be the input.