ThorVG  v0.11
Animation

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

Public Member Functions

Result frame (uint32_t no) noexcept
 Specifies the current frame in the animation. More...
 
Picturepicture () const noexcept
 Retrieves a picture instance associated with this animation instance. More...
 
uint32_t curFrame () const noexcept
 Retrieves the current frame number of the animation. More...
 
uint32_t totalFrame () const noexcept
 Retrieves the total number of frames in the animation. More...
 
float duration () const noexcept
 Retrieves the duration of the animation in seconds. More...
 

Static Public Member Functions

static std::unique_ptr< Animationgen () noexcept
 Creates a new Animation object. More...
 

Detailed Description

The Animation class enables manipulation of animatable images.

This class supports the display and control of animation frames.

@BETA_API

Member Function Documentation

◆ curFrame()

uint32_t 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(uint32_t no)
Animation::totalFrame()

@BETA_API

◆ 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.

@BETA_API

◆ frame()

Result frame ( uint32_t  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::SuccessSuccessfully set the frame.
Result::InsufficientConditionNo animatable data loaded from the Picture.
Result::NonSupportThe Picture data does not support animations.
See also
totalFrame()

@BETA_API

◆ gen()

static std::unique_ptr<Animation> gen ( )
staticnoexcept

Creates a new Animation object.

Returns
A new Animation object.

@BETA_API

◆ 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 Lottie(json). 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.

@BETA_API

◆ totalFrame()

uint32_t 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.

@BETA_API