thorvg_python.animation.lottie

Classes

LottieAnimation

LottieAnimation Extension API

Module Contents

class thorvg_python.animation.lottie.LottieAnimation(engine: thorvg_python.engine.Engine, animation: thorvg_python.base.AnimationPointer | None = None)

Bases: thorvg_python.animation.Animation

LottieAnimation Extension API

A module for manipulation of the scene tree

This module helps to control the scene tree.

engine
thorvg_lib
new() thorvg_python.base.AnimationPointer

Creates a new LottieAnimation object.

Returns:

AnimationPointer A new Lottie AnimationPointer object.

Return type:

thorvg_python.base.AnimationPointer

Added in version 0.15.

gen_slot(slot: str) int

Generates a new slot from the given slot data.

Parameters:
slot : str

The Lottie slot data in JSON format.

Returns:

The generated slot ID when successful, 0 otherwise.

Return type:

int

Added in version 1.0.

apply_slot(_id: int) thorvg_python.base.Result

Applies a previously generated slot to the animation.

Parameters:
_id : int

The ID of the slot to apply, or 0 to reset all slots.

Returns:

  • Result.INSUFFICIENT_CONDITION In case the animation is not loaded.

  • Result.INVALID_ARGUMENT When the given _id is invalid

  • Result.NOT_SUPPORTED The Lottie Animation is not supported.

Return type:

thorvg_python.base.Result

Added in version 1.0.

del_slot(_id: int) thorvg_python.base.Result

Deletes a previously generated slot.

Parameters:
_id: int

The ID of the slot to delete.

Returns:

  • Result.INSUFFICIENT_CONDITION In case the animation is not loaded or the slot ID is invalid.

  • Result.NOT_SUPPORTED The Lottie Animation is not supported.

Return type:

thorvg_python.base.Result

Note

This function should be paired with gen.

See also

LottieAnimation.gen_slot()

Added in version 1.0.

set_marker(marker: str) thorvg_python.base.Result

Specifies a segment by marker.

Parameters:
marker : str

The name of the segment marker.

Returns:

  • Result.INSUFFICIENT_CONDITION In case the animation is not loaded.

  • Result.INVALID_ARGUMENT When the given marker is invalid.

  • Result.NOT_SUPPORTED The Lottie Animation is not supported.

Return type:

thorvg_python.base.Result

Note

Experimental API

get_markers_cnt() tuple[thorvg_python.base.Result, int]

Gets the marker count of the animation.

Returns:

Result.INVALID_ARGUMENT In case a None is passed as the argument.

Return type:

thorvg_python.base.Result

Returns:

The count value of the markers.

Return type:

int

Note

Experimental API

get_marker(idx: int) tuple[thorvg_python.base.Result, str | None]

Gets the marker name by a given index.

Parameters:
idx : int

The index of the animation marker, starts from 0.

Returns:

Result.INVALID_ARGUMENT In case None is passed as the argument or idx is out of range.

Rtyle:

Result

Returns:

The name of marker when succeed.

Return type:

Optional[str]

Note

Experimental API

tween(_from: float, to: float, progress: float) thorvg_python.base.Result

Interpolates between two frames over a specified duration.

This method performs tweening, a process of generating intermediate frame between _from and to based on the given progress.

Parameters:
_from: float

The start frame number of the interpolation.

to: float

The end frame number of the interpolation.

progress: float

The current progress of the interpolation (range: 0.0 to 1.0).

Returns:

TVG_RESULT_INSUFFICIENT_CONDITION In case the animation is not loaded.

Return type:

thorvg_python.base.Result

Added in version 1.0.

assign(layer: str, ix: int, var: str, val: float) thorvg_python.base.Result

Updates the value of an expression variable for a specific layer.

Parameters:
layer : str

The name of the layer containing the variable to be updated.

ix : int

The property index of the variable within the layer.

var : str

The name of the variable to be updated.

val : float

The new value to assign to the variable.

Returns:

  • Result.INSUFFICIENT_CONDITION If the animation is not loaded.

  • Result.INVALID_ARGUMENT When the given parameter is invalid.

  • Result.NOT_SUPPORTED When neither the layer nor the property is found in the current animation.

Return type:

thorvg_python.base.Result

Note

Experimental API

set_quality(value: int) thorvg_python.base.Result

Sets the quality level for Lottie effects.

This function controls the rendering quality of effects like blur, shadows, etc. Lower values prioritize performance while higher values prioritize quality.

Parameters:
value : int

The quality level (0-100). 0 represents lowest quality/best performance, 100 represents highest quality/lowest performance, default is 50.

Returns:

  • Result.INSUFFICIENT_CONDITION If the animation is not loaded.

  • Result.INVALID_ARGUMENT An invalid AnimationPointer.

Return type:

thorvg_python.base.Result

Note

This option is used as a hint; its behavior heavily depends on the render backend.

Added in version 1.0.