mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-25 09:21:55 +00:00

A single animation might have a desinated markers with naming: 0 ~ 0.5 (sector A), 0.5 ~ 1.0 (sector B). Selecting one of them using a marker name(sector A) and could play only that part with animation controllers. usage: - `animation->segment("sectionA") // Named segment(Marker)` - `auto cnt = animation->markerCnt()` - `auto name = animation->markers(index)` - `animation->segment(0, 0.5) // Segment` - `animation->segment(&begin, &end)` Co-authored-by: Jinny You <jinny@lottiefiles.com>
94 lines
2.7 KiB
C++
94 lines
2.7 KiB
C++
#ifndef _THORVG_LOTTIE_H_
|
|
#define _THORVG_LOTTIE_H_
|
|
|
|
#include <thorvg.h>
|
|
|
|
namespace tvg
|
|
{
|
|
|
|
/**
|
|
* @class LottieAnimation
|
|
*
|
|
* @brief The LottieAnimation class enables control of advanced Lottie features.
|
|
*
|
|
* This class extends the Animation and has additional interfaces.
|
|
*
|
|
* @see Animation
|
|
*
|
|
* @note Experimental API
|
|
*/
|
|
class TVG_API LottieAnimation final : public Animation
|
|
{
|
|
public:
|
|
~LottieAnimation();
|
|
|
|
/**
|
|
* @brief Override Lottie properties using slot data.
|
|
*
|
|
* @param[in] slot The Lottie slot data in JSON format to override, or @c nullptr to reset.
|
|
*
|
|
* @retval Result::Success When succeed.
|
|
* @retval Result::InsufficientCondition In case the animation is not loaded.
|
|
* @retval Result::InvalidArguments When the given parameter is invalid.
|
|
*
|
|
* @note Experimental API
|
|
*/
|
|
Result override(const char* slot) noexcept;
|
|
|
|
/**
|
|
* @brief 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.
|
|
*
|
|
* @param[in] marker The name of the segment marker.
|
|
*
|
|
* @retval Result::Success When successful.
|
|
* @retval Result::InsufficientCondition If the animation is not loaded.
|
|
* @retval Result::InvalidArguments When the given parameter is invalid.
|
|
* @retval Result::NonSupport When it's not animatable.
|
|
*
|
|
* @note If a @c marker is specified, the previously set segment will be disregarded.
|
|
* @note Set @c nullptr to reset the specified segment.
|
|
* @see Animation::segment(float begin, float end)
|
|
* @note Experimental API
|
|
*/
|
|
Result segment(const char* marker) noexcept;
|
|
|
|
/**
|
|
* @brief Gets the marker count of the animation.
|
|
*
|
|
* @retval The count of the markers, zero if there is no marker.
|
|
*
|
|
* @see LottieAnimation::marker()
|
|
* @note Experimental API
|
|
*/
|
|
uint32_t markersCnt() noexcept;
|
|
|
|
/**
|
|
* @brief Gets the marker name by a given index.
|
|
*
|
|
* @param[in] idx The index of the animation marker, starts from 0.
|
|
*
|
|
* @retval The name of marker when succeed, @c nullptr otherwise.
|
|
*
|
|
* @see LottieAnimation::markersCnt()
|
|
* @note Experimental API
|
|
*/
|
|
const char* marker(uint32_t idx) noexcept;
|
|
|
|
/**
|
|
* @brief Creates a new LottieAnimation object.
|
|
*
|
|
* @return A new LottieAnimation object.
|
|
*
|
|
* @note Experimental API
|
|
*/
|
|
static std::unique_ptr<LottieAnimation> gen() noexcept;
|
|
};
|
|
|
|
} //namespace
|
|
|
|
#endif //_THORVG_LOTTIE_H_
|