diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index c92b61fc..e0150733 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -2323,6 +2323,36 @@ TVG_API Tvg_Result tvg_animation_get_total_frame(Tvg_Animation* animation, float TVG_API Tvg_Result tvg_animation_get_duration(Tvg_Animation* animation, float* duration); +/*! +* \brief Specifies the playback segment of the animation. (Experimental API) +* +* \param[in] animation The Tvg_Animation pointer to the animation object. +* \param[in] begin segment begin. +* \param[in] end segment end. +* +* \return Tvg_Result enumeration. +* \retval TVG_RESULT_SUCCESS Succeed. +* \retval TVG_RESULT_INSUFFICIENT_CONDITION In case the animation is not loaded. +* \retval TVG_RESULT_INVALID_ARGUMENT When the given parameters are out of range. +*/ +TVG_API Tvg_Result tvg_animation_set_segment(Tvg_Animation* animation, float begin, float end); + + +/*! +* \brief Gets the current segment. (Experimental API) +* +* \param[in] animation The Tvg_Animation pointer to the animation object. +* \param[out] begin segment begin. +* \param[out] end segment end. +* +* \return Tvg_Result enumeration. +* \retval TVG_RESULT_SUCCESS Succeed. +* \retval TVG_RESULT_INSUFFICIENT_CONDITION In case the animation is not loaded. +* \retval TVG_RESULT_INVALID_ARGUMENT When the given parameters are @c nullptr. +*/ +TVG_API Tvg_Result tvg_animation_get_segment(Tvg_Animation* animation, float* begin, float* end = nullptr); + + /*! * \brief Deletes the given Tvg_Animation object. * @@ -2373,6 +2403,48 @@ TVG_API Tvg_Animation* tvg_lottie_animation_new(); TVG_API Tvg_Result tvg_lottie_animation_override(Tvg_Animation* animation, const char* slot); +/*! +* \brief Specifies a segment by marker. (Experimental API) +* +* \param[in] animation The Tvg_Animation pointer to the Lottie animation object. +* \param[in] marker The name of the segment marker. +* +* \return Tvg_Result enumeration. +* \retval TVG_RESULT_SUCCESS Succeed. +* \retval TVG_RESULT_INSUFFICIENT_CONDITION In case the animation is not loaded. +* \retval TVG_RESULT_INVALID_ARGUMENT When the given @p marker is invalid. +* \retval TVG_RESULT_NOT_SUPPORTED The Lottie Animation is not supported. +*/ +TVG_API Tvg_Result tvg_lottie_animation_set_marker(Tvg_Animation* animation, const char* marker); + + +/*! +* \brief Gets the marker count of the animation. (Experimental API) +* +* \param[in] animation The Tvg_Animation pointer to the Lottie animation object. +* \param[out] cnt The count value of the merkers. +* +* \return Tvg_Result enumeration. +* \retval TVG_RESULT_SUCCESS Succeed. +* \retval TVG_RESULT_INVALID_ARGUMENT In case a @c nullptr is passed as the argument. +*/ +TVG_API Tvg_Result tvg_lottie_animation_get_markers_cnt(Tvg_Animation* animation, uint32_t* cnt); + + +/*! +* \brief Gets the marker name by a given index. (Experimental API) +* +* \param[in] animation The Tvg_Animation pointer to the Lottie animation object. +* \param[in] idx The index of the animation marker, starts from 0. +* \param[out] name The name of marker when succeed. +* +* \return Tvg_Result enumeration. +* \retval TVG_RESULT_SUCCESS Succeed. +* \retval TVG_RESULT_INVALID_ARGUMENT In case @c nullptr is passed as the argument or @c idx is out of range. +*/ +TVG_API Tvg_Result tvg_lottie_animation_get_marker(Tvg_Animation* animation, uint32_t idx, const char** name); + + /** \} */ // end addtogroup ThorVGCapi_LottieAnimation diff --git a/src/bindings/capi/tvgCapi.cpp b/src/bindings/capi/tvgCapi.cpp index 75b32a96..9818b2ca 100644 --- a/src/bindings/capi/tvgCapi.cpp +++ b/src/bindings/capi/tvgCapi.cpp @@ -768,6 +768,20 @@ TVG_API Tvg_Result tvg_animation_get_duration(Tvg_Animation* animation, float* d } +TVG_API Tvg_Result tvg_animation_set_segment(Tvg_Animation* animation, float start, float end) +{ + if (!animation) return TVG_RESULT_INVALID_ARGUMENT; + return (Tvg_Result) reinterpret_cast(animation)->segment(start, end); +} + + +TVG_API Tvg_Result tvg_animation_get_segment(Tvg_Animation* animation, float* start, float* end) +{ + if (!animation) return TVG_RESULT_INVALID_ARGUMENT; + return (Tvg_Result) reinterpret_cast(animation)->segment(start, end); +} + + TVG_API Tvg_Result tvg_animation_del(Tvg_Animation* animation) { if (!animation) return TVG_RESULT_INVALID_ARGUMENT; @@ -798,6 +812,39 @@ TVG_API Tvg_Result tvg_lottie_animation_override(Tvg_Animation* animation, const return TVG_RESULT_NOT_SUPPORTED; } + +TVG_API Tvg_Result tvg_lottie_animation_set_marker(Tvg_Animation* animation, const char* marker) +{ +#ifdef THORVG_LOTTIE_LOADER_SUPPORT + if (!animation) return TVG_RESULT_INVALID_ARGUMENT; + return (Tvg_Result) reinterpret_cast(animation)->segment(marker); +#endif + return TVG_RESULT_NOT_SUPPORTED; +} + + +TVG_API Tvg_Result tvg_lottie_animation_get_markers_cnt(Tvg_Animation* animation, uint32_t* cnt) +{ +#ifdef THORVG_LOTTIE_LOADER_SUPPORT + if (!animation || !cnt) return TVG_RESULT_INVALID_ARGUMENT; + *cnt = reinterpret_cast(animation)->markersCnt(); + return TVG_RESULT_SUCCESS; +#endif + return TVG_RESULT_NOT_SUPPORTED; +} + + +TVG_API Tvg_Result tvg_lottie_animation_get_marker(Tvg_Animation* animation, uint32_t idx, const char** name) +{ +#ifdef THORVG_LOTTIE_LOADER_SUPPORT + if (!animation || !name) return TVG_RESULT_INVALID_ARGUMENT; + *name = reinterpret_cast(animation)->marker(idx); + if (!(*name)) return TVG_RESULT_INVALID_ARGUMENT; + return TVG_RESULT_SUCCESS; +#endif + return TVG_RESULT_NOT_SUPPORTED; +} + #ifdef __cplusplus } #endif