ThorVG v1.0
Loading...
Searching...
No Matches
LottieAnimationfinal

The LottieAnimation class enables control of advanced Lottie features. More...

#include <thorvg_lottie.h>

Inheritance diagram for LottieAnimation:
Collaboration diagram for LottieAnimation:

Public Member Functions

Result segment (const char *marker) noexcept
 Specifies a segment by marker.
 
Result tween (float from, float to, float progress) noexcept
 Interpolates between two frames over a specified duration.
 
uint32_t markersCnt () noexcept
 Gets the marker count of the animation.
 
const char * marker (uint32_t idx) noexcept
 Gets the marker name by a given index.
 
Result assign (const char *layer, uint32_t ix, const char *var, float val)
 Updates the value of an expression variable for a specific layer.
 
uint32_t gen (const char *slot) noexcept
 Creates a new slot based on the given Lottie slot data.
 
Result apply (uint32_t id) noexcept
 Applies a previously generated slot to the animation.
 
Result del (uint32_t id) noexcept
 Deletes a previously generated slot.
 
Result quality (uint8_t value) noexcept
 Sets the quality level for Lottie effects.
 
- Public Member Functions inherited from Animation
Result frame (float no) noexcept
 Specifies the current frame in the animation.
 
Picturepicture () const noexcept
 Retrieves a picture instance associated with this animation instance.
 
float curFrame () const noexcept
 Retrieves the current frame number of the animation.
 
float totalFrame () const noexcept
 Retrieves the total number of frames in the animation.
 
float duration () const noexcept
 Retrieves the duration of the animation in seconds.
 
Result segment (float begin, float end) noexcept
 Specifies the playback segment of the animation.
 
Result segment (float *begin, float *end=nullptr) noexcept
 Gets the current segment range information.
 

Static Public Member Functions

static LottieAnimationgen () noexcept
 Creates a new LottieAnimation object.
 
- Static Public Member Functions inherited from Animation
static Animationgen () noexcept
 Creates a new Animation object.
 

Detailed Description

The LottieAnimation class enables control of advanced Lottie features.

This class extends the Animation and has additional interfaces.

See also
Animation
Since
0.15

Member Function Documentation

◆ apply()

Result apply ( uint32_t  id)
noexcept

Applies a previously generated slot to the animation.

This function applies the animation parameters defined by a slot. If the provided slot ID is 0, all previously applied slots will be reset.

Parameters
[in]idThe ID of the slot to apply. Use 0 to reset all slots.
Return values
Result::InvalidArgumentsIf the animation is not loaded or the slot ID is invalid.
See also
gen(const char* slot)
Since
1.0

◆ assign()

Result assign ( const char *  layer,
uint32_t  ix,
const char *  var,
float  val 
)

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

This function sets the value of a specified expression variable within a particular layer. It is useful for dynamically changing the properties of a layer at runtime.

Parameters
[in]layerThe name of the layer containing the variable to be updated.
[in]ixThe property index of the variable within the layer.
[in]varThe name of the variable to be updated.
[in]valThe new value to assign to the variable.
Return values
Result::InsufficientConditionIf the animation is not loaded.
Result::InvalidArgumentsWhen the given parameter is invalid.
Result::NonSupportWhen neither the layer nor the property is found in the current animation.
Note
Experimental API

◆ del()

Result del ( uint32_t  id)
noexcept

Deletes a previously generated slot.

This function removes a slot by its ID.

Parameters
[in]idThe ID of the slot to delete. Retrieve the ID from gen().
Return values
Result::InvalidArgumentsIf the animation is not loaded or the slot ID is invalid.
Note
This function should be paired with gen.
See also
gen(const char* slot)
Since
1.0

◆ gen() [1/2]

static LottieAnimation * gen ( )
staticnoexcept

Creates a new LottieAnimation object.

Returns
A new LottieAnimation object.
Since
0.15

◆ gen() [2/2]

uint32_t gen ( const char *  slot)
noexcept

Creates a new slot based on the given Lottie slot data.

This function parses the provided JSON-formatted slot data and generates a new slot for animation control. The returned slot ID can be used to apply or delete the slot later.

Parameters
[in]slotA JSON string representing the Lottie slot data.
Returns
A unique, non-zero slot ID on success. Returns 0 if the slot generation fails.
See also
apply(uint32_t id)
del(uint32_t id)
Since
1.0

◆ marker()

const char * marker ( uint32_t  idx)
noexcept

Gets the marker name by a given index.

Parameters
[in]idxThe index of the animation marker, starts from 0.
Return values
Thename of marker when succeed, nullptr otherwise.
See also
LottieAnimation::markersCnt()
Since
1.0

◆ markersCnt()

uint32_t markersCnt ( )
noexcept

Gets the marker count of the animation.

Return values
Thecount of the markers, zero if there is no marker.
See also
LottieAnimation::marker()
Since
1.0

◆ quality()

Result quality ( uint8_t  value)
noexcept

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
[in]valueThe quality level (0-100). 0 represents lowest quality/best performance, 100 represents highest quality/lowest performance, default is 50.
Return values
Result::InsufficientConditionIf the animation is not loaded.
Since
1.0

◆ segment()

Result segment ( const char *  marker)
noexcept

Specifies a segment by marker.

Markers are used to control animation playback by specifying start and end points, eliminating the need to know the exact frame numbers. Generally, markers are designated at the design level, meaning the callers must know the marker name in advance to use it.

Parameters
[in]markerThe name of the segment marker.
Return values
Result::InsufficientConditionIf the animation is not loaded.
Result::NonSupportWhen it's not animatable.
Note
If a marker is specified, the previously set segment will be disregarded.
Set nullptr to reset the specified segment.
See also
Animation::segment(float begin, float end)
Since
1.0

◆ tween()

Result tween ( float  from,
float  to,
float  progress 
)
noexcept

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
[in]fromThe start frame number of the interpolation.
[in]toThe end frame number of the interpolation.
[in]progressThe current progress of the interpolation (range: 0.0 to 1.0).
Return values
Result::InsufficientConditionIn case the animation is not loaded.
Since
1.0