thorvg_python.engine

Attributes

THORVG_LIB

Classes

Engine

Engine API

Functions

_load_lib_with_prefix_suffix(→ Optional[ctypes.CDLL])

_load_lib(→ Optional[ctypes.CDLL])

Module Contents

thorvg_python.engine._load_lib_with_prefix_suffix(lib_prefix: str, lib_suffix: str) ctypes.CDLL | None
thorvg_python.engine._load_lib(thorvg_lib_path: str | None = None) ctypes.CDLL | None
thorvg_python.engine.THORVG_LIB
class thorvg_python.engine.Engine(thorvg_lib_path: str | None = None, threads: int = 0)

Engine API

A module enabling initialization and termination of the TVG engines.

threads = 0
init_result
_load_lib(thorvg_lib_path: str | None = None) None
__del__() None
__enter__() Engine
__exit__(exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None) None
init(threads: int) thorvg_python.base.Result

Initializes TVG engines.

ThorVG requires an active runtime environment to operate. Internally, it utilizes a task scheduler to efficiently parallelize rendering operations. You can specify the number of worker threads using the threads parameter. During initialization, ThorVG will spawn the specified number of threads.

Parameters:
threads : int

The number of additional threads used to perform rendering. Zero indicates only the main thread is to be used.

Return type:

thorvg_python.base.Result

Note

The initializer uses internal reference counting to track multiple calls. The number of threads is fixed on the first call to Engine.init() and cannot be changed in subsequent calls.

See also

Engine.term()

term() thorvg_python.base.Result

Terminates TVG engines.

Cleans up resources and stops any internal threads initialized by Engine.init().

Returns:

Result.INSUFFICIENT_CONDITION Returned if there is nothing to terminate (e.g., Engine.init() was not called).

Return type:

thorvg_python.base.Result

See also

Engine.init()

version() tuple[thorvg_python.base.Result, int, int, int, str | None]

Retrieves the version of the TVG engine.

Returns:

Result.SUCCESS

Return type:

thorvg_python.base.Result

Returns:

A major version number.

Return type:

int

Returns:

A minor version number.

Return type:

int

Returns:

A micro version number.

Return type:

int

Returns:

The version of the engine in the format major.minor.micro, or a None in case of an internal error.

Return type:

Optional[str]

Added in version 0.15.