thorvg_python.base

Attributes

PictureAssetResolverType

Classes

CanvasPointer

A structure responsible for managing and drawing graphical elements.

PaintPointer

A structure representing a graphical element.

GradientPointer

A structure representing a gradient fill of a PaintPointer object.

SaverPointer

A structure representing an object that enables to save a PaintPointer object into a file.

AnimationPointer

A structure representing an animation controller object.

AccessorPointer

A structure representing an object that enables iterating through a scene's descendents.

Result

Enumeration specifying the result from the APIs.

Colorspace

Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.

EngineOption

Enumeration to specify rendering engine behavior.

MaskMethod

Enumeration indicating the method used in the masking of two objects - the target and the source.

BlendMethod

Enumeration indicates the method used for blending paint.

TvgType

Enumeration indicating the ThorVG object type value.

PathCommand

Enumeration specifying the values of the path commands accepted by ThorVG.

StrokeCap

Enumeration determining the ending type of a stroke in the open sub-paths.

StrokeJoin

Enumeration specifying how to fill the area outside the gradient bounds.

StrokeFill

Enumeration specifying how to fill the area outside the gradient bounds.

FillRule

Enumeration specifying the algorithm used to establish which parts of the shape

ColorStop

A data structure storing the information about the color and its relative position inside the gradient bounds.

TextWrap

A data structure storing the information about the color and its relative position inside the gradient bounds.

PointStruct

A data structure representing a point in two-dimensional space.

Matrix

A data structure representing a three-dimensional matrix.

TextMetrics

Describes the font metrics of a text object.

Module Contents

class thorvg_python.base.CanvasPointer

Bases: ctypes.c_void_p

A structure responsible for managing and drawing graphical elements.

It sets up the target buffer, which can be drawn on the screen. It stores the PaintPointer objects (Shape, Scene, Picture).

Note

You should use Canvas class instead.

class thorvg_python.base.PaintPointer

Bases: ctypes.c_void_p

A structure representing a graphical element.

Warning

The PaintPointer objects cannot be shared between Canvases.

Note

You should use Paint class instead.

class thorvg_python.base.GradientPointer

Bases: ctypes.c_void_p

A structure representing a gradient fill of a PaintPointer object.

Note

You should use LinearGradient or RadialGradient class instead.

class thorvg_python.base.SaverPointer

Bases: ctypes.c_void_p

A structure representing an object that enables to save a PaintPointer object into a file.

Note

You should use Saver class instead.

class thorvg_python.base.AnimationPointer

Bases: ctypes.c_void_p

A structure representing an animation controller object.

Note

You should use Animation class instead.

class thorvg_python.base.AccessorPointer

Bases: ctypes.c_void_p

A structure representing an object that enables iterating through a scene’s descendents.

Note

You should use Accessor class instead

class thorvg_python.base.Result

Bases: enum.IntEnum

Enumeration specifying the result from the APIs.

All ThorVG APIs could potentially return one of the values in the list. Please note that some APIs may additionally specify the reasons that trigger their return values.

SUCCESS = 0
INVALID_ARGUMENT = 1
INSUFFICIENT_CONDITION = 2
FAILED_ALLOCATION = 3
MEMORY_CORRUPTION = 4
NOT_SUPPORTED = 5
UNKNOWN = 255
classmethod from_param(obj: int) int
class thorvg_python.base.Colorspace

Bases: enum.IntEnum

Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.

Changed in version 0.13: Added ABGR8888S and ARGB8888S

Changed in version 1.0: Added UNKNOWN

ABGR8888 = 0
ARGB8888 = 1
ABGR8888S = 2
ARGB8888S = 3
UNKNOWN = 255
classmethod from_param(obj: int) int
class thorvg_python.base.EngineOption

Bases: enum.IntEnum

Enumeration to specify rendering engine behavior.

Note

The availability or behavior of EngineMethod.SMART_RENDER may vary depending on platform or backend support. It attempts to optimize rendering performance by updating only the regions of the canvas that have changed between frames (partial redraw). This can be highly effective in scenarios where most of the canvas remains static and only small portions are updated—such as simple animations or GUI interactions. However, in complex scenes where a large portion of the canvas changes frequently (e.g., full-screen animations or heavy object movements), the overhead of tracking changes and managing update regions may outweigh the benefits, resulting in decreased performance compared to the default rendering mode. Thus, it is recommended to benchmark both modes in your specific use case to determine the optimal setting.

Added in version 1.0.

NONE = 0
DEFAULT = 1
SMART_RENDER = 2
class thorvg_python.base.MaskMethod

Bases: enum.IntEnum

Enumeration indicating the method used in the masking of two objects - the target and the source.

NONE = 0
ALPHA = 1
INVERSE_ALPHA = 2
LUMA = 3
INVERSE_LUMA = 4
ADD = 5
SUBTRACT = 6
INTERSECT = 7
DIFFERENCE = 8
LIGHTEN = 9
DARKEN = 10
classmethod from_param(obj: int) int
class thorvg_python.base.BlendMethod

Bases: enum.IntEnum

Enumeration indicates the method used for blending paint. Please refer to the respective formulas for each method.

NORMAL = 0
MULTIPLY = 1
SCREEN = 2
OVERLAY = 3
DARKEN = 4
LIGHTEN = 5
COLORDODGE = 6
COLORBURN = 7
HARDLIGHT = 8
SOFTLIGHT = 9
DIFFERENCE = 10
EXCLUSION = 11
HUE = 12
SATURATION = 13
COLOR = 14
LUMINOSITY = 15
ADD = 16
COMPOSITION = 255
classmethod from_param(obj: int) int
class thorvg_python.base.TvgType

Bases: enum.IntEnum

Enumeration indicating the ThorVG object type value.

ThorVG’s drawing objects can return object type values, allowing you to identify the specific type of each object.

UNDEF = 0
SHAPE = 1
SCENE = 2
PICTURE = 3
TEXT = 4
LINEAR_GRAD = 10
RADIAL_GRAD = 11
classmethod from_param(obj: int) int
class thorvg_python.base.PathCommand

Bases: enum.IntEnum

Enumeration specifying the values of the path commands accepted by ThorVG.

CLOSE = 0
MOVE_TO = 1
LINE_TO = 2
CUBIC_TO = 3
classmethod from_param(obj: int) int
class thorvg_python.base.StrokeCap

Bases: enum.IntEnum

Enumeration determining the ending type of a stroke in the open sub-paths.

BUTT = 0
ROUND = 1
SQUARE = 2
classmethod from_param(obj: int) int
class thorvg_python.base.StrokeJoin

Bases: enum.IntEnum

Enumeration specifying how to fill the area outside the gradient bounds.

MITER = 0
ROUND = 1
BEVEL = 2
classmethod from_param(obj: int) int
class thorvg_python.base.StrokeFill

Bases: enum.IntEnum

Enumeration specifying how to fill the area outside the gradient bounds.

PAD = 0
REFLECT = 1
REPEAT = 2
classmethod from_param(obj: int) int
class thorvg_python.base.FillRule

Bases: enum.IntEnum

Enumeration specifying the algorithm used to establish which parts of the shape are treated as the inside of the shape.

NON_ZERO = 0
EVEN_ODD = 1
classmethod from_param(obj: int) int
class thorvg_python.base.ColorStop

Bases: ctypes.Structure

A data structure storing the information about the color and its relative position inside the gradient bounds.

_fields_
class thorvg_python.base.TextWrap

Bases: enum.IntEnum

A data structure storing the information about the color and its relative position inside the gradient bounds.

NONE = 0
CHARACTER = 1
WORD = 2
SMART = 3
ELLIPSIS = 4
HYPHENATION = 5
classmethod from_param(obj: int) int
class thorvg_python.base.PointStruct

Bases: ctypes.Structure

A data structure representing a point in two-dimensional space.

_fields_
class thorvg_python.base.Matrix

Bases: ctypes.Structure

A data structure representing a three-dimensional matrix.

The elements e11, e12, e21 and e22 represent the rotation matrix, including the scaling factor.

The elements e13 and e23 determine the translation of the object along the x and y-axis, respectively.

The elements e31 and e32 are set to 0, e33 is set to 1.

_fields_
class thorvg_python.base.TextMetrics

Bases: ctypes.Structure

Describes the font metrics of a text object.

Provides the basic vertical layout metrics used for text rendering, such as ascent, descent, and line spacing (linegap).

See also

Text.get_metrics()

Note

Experimental API

_fields_
ascent : float
descent : float
linegap : float
advance : float
thorvg_python.base.PictureAssetResolverType