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

The Animation class enables manipulation of animatable images. More...

#include <thorvg.h>

Inheritance diagram for Animation:

Public Member Functions

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 Animationgen () noexcept
 Creates a new Animation object.
 

Detailed Description

The Animation class enables manipulation of animatable images.

This class supports the display and control of animation frames.

Since
0.13

Member Function Documentation

◆ curFrame()

float curFrame ( ) const
noexcept

Retrieves the current frame number of the animation.

Returns
The current frame number of the animation, between 0 and totalFrame() - 1.
Note
If the Picture is not properly configured, this function will return 0.
See also
Animation::frame()
Animation::totalFrame()

◆ duration()

float duration ( ) const
noexcept

Retrieves the duration of the animation in seconds.

Returns
The duration of the animation in seconds.
Note
If the Picture is not properly configured, this function will return 0.

◆ frame()

Result frame ( float  no)
noexcept

Specifies the current frame in the animation.

Parameters
[in]noThe index of the animation frame to be displayed. The index should be less than the totalFrame().
Return values
Result::InsufficientConditionif the given no is the same as the current frame value.
Result::NonSupportThe current Picture data does not support animations.
Note
For efficiency, ThorVG ignores updates to the new frame value if the difference from the current frame value is less than 0.001. In such cases, it returns Result::InsufficientCondition. Values less than 0.001 may be disregarded and may not be accurately retained by the Animation.
See also
totalFrame()

◆ gen()

static Animation * gen ( )
staticnoexcept

Creates a new Animation object.

Returns
A new Animation object.

◆ picture()

Picture * picture ( ) const
noexcept

Retrieves a picture instance associated with this animation instance.

This function provides access to the picture instance that can be used to load animation formats, such as lot. After setting up the picture, it can be pushed to the designated canvas, enabling control over animation frames with this Animation instance.

Returns
A picture instance that is tied to this animation.
Warning
The picture instance is owned by Animation. It should not be deleted manually.

◆ segment() [1/2]

Result segment ( float *  begin,
float *  end = nullptr 
)
noexcept

Gets the current segment range information.

Parameters
[out]beginsegment begin frame.
[out]endsegment end frame.
Return values
Result::InsufficientConditionIn case the animation is not loaded.
Result::NonSupportWhen it's not animatable.
Since
1.0

◆ segment() [2/2]

Result segment ( float  begin,
float  end 
)
noexcept

Specifies the playback segment of the animation.

The set segment is designated as the play area of the animation. This is useful for playing a specific segment within the entire animation. After setting, the number of animation frames and the playback time are calculated by mapping the playback segment as the entire range.

Parameters
[in]beginsegment begin frame.
[in]endsegment end frame.
Return values
Result::InsufficientConditionIn case the animation is not loaded.
Result::InvalidArgumentsIf the begin is higher than end.
Result::NonSupportWhen it's not animatable.
Note
Animation allows a range from 0.0 to the total frame. end should not be higher than begin.
If a marker has been specified, its range will be disregarded.
See also
LottieAnimation::segment(const char* marker)
Animation::totalFrame()
Since
1.0

◆ totalFrame()

float totalFrame ( ) const
noexcept

Retrieves the total number of frames in the animation.

Returns
The total number of frames in the animation.
Note
Frame numbering starts from 0.
If the Picture is not properly configured, this function will return 0.