From: JunsuChoi Date: Tue, 30 Jul 2019 11:03:00 +0000 (+0900) Subject: CAPI: Add capi to support the dynamic properties X-Git-Tag: submit/tizen/20190812.090759~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=68edf2880e920c176f5835e63b71807c75423904;p=platform%2Fcore%2Fuifw%2Flottie-player.git CAPI: Add capi to support the dynamic properties This function needs keypath and type of string type. And needs values as variable arguments. The usage of this function is written in docs. --- diff --git a/inc/rlottie_capi.h b/inc/rlottie_capi.h index a5cb70a..323223a 100644 --- a/inc/rlottie_capi.h +++ b/inc/rlottie_capi.h @@ -27,6 +27,19 @@ extern "C" { #endif +typedef enum { + LOTTIE_ANIMATION_PROPERTY_FILLCOLOR, /*!< Color property of Fill object , value type is float [0 ... 1] */ + LOTTIE_ANIMATION_PROPERTY_FILLOPACITY, /*!< Opacity property of Fill object , value type is float [ 0 .. 100] */ + LOTTIE_ANIMATION_PROPERTY_STROKECOLOR, /*!< Color property of Stroke object , value type is float [0 ... 1] */ + LOTTIE_ANIMATION_PROPERTY_STROKEOPACITY, /*!< Opacity property of Stroke object , value type is float [ 0 .. 100] */ + LOTTIE_ANIMATION_PROPERTY_STROKEWIDTH, /*!< stroke with property of Stroke object , value type is float */ + LOTTIE_ANIMATION_PROPERTY_TR_ANCHOR, /*!< Transform Anchor property of Layer and Group object , value type is int */ + LOTTIE_ANIMATION_PROPERTY_TR_POSITION, /*!< Transform Position property of Layer and Group object , value type is int */ + LOTTIE_ANIMATION_PROPERTY_TR_SCALE, /*!< Transform Scale property of Layer and Group object , value type is float range[0 ..100] */ + LOTTIE_ANIMATION_PROPERTY_TR_ROTATION, /*!< Transform Scale property of Layer and Group object , value type is float. range[0 .. 360] in degrees*/ + LOTTIE_ANIMATION_PROPERTY_TR_OPACITY /*!< Transform Opacity property of Layer and Group object , value type is float [ 0 .. 100] */ +}Lottie_Animation_Property; + typedef struct Lottie_Animation_S Lottie_Animation; /** @@ -233,6 +246,34 @@ lottie_animation_render_async(Lottie_Animation *animation, LOT_EXPORT uint32_t * lottie_animation_render_flush(Lottie_Animation *animation); + +/** + * @brief Request to change the properties of this animation object. + * Keypath should conatin object names separated by (.) and can handle globe(**) or wildchar(*) + * + * @usage + * To change fillcolor property of fill1 object in the layer1->group1->fill1 hirarchy to RED color + * + * lottie_animation_property_override(animation, LOTTIE_ANIMATION_PROPERTY_FILLCOLOR, "layer1.group1.fill1", 1.0, 0.0, 0.0); + * + * if all the color property inside group1 needs to be changed to GREEN color + * + * lottie_animation_property_override(animation, LOTTIE_ANIMATION_PROPERTY_FILLCOLOR, "**.group1.**", 1.0, 0.0, 0.0); + * + * @param[in] animation Animation object. + * @param[in] type Property type. (@p Lottie_Animation_Property) + * @param[in] keypath Specific content of target. + * @param[in] ... Property values. + * + * @ingroup Lottie_Animation + * @internal + * */ +LOT_EXPORT void +lottie_animation_property_override(Lottie_Animation *animation, + const Lottie_Animation_Property type, + const char *keypath, + ...); + #ifdef __cplusplus } #endif diff --git a/src/binding/c/lottieanimation_capi.cpp b/src/binding/c/lottieanimation_capi.cpp index d40df28..7793607 100644 --- a/src/binding/c/lottieanimation_capi.cpp +++ b/src/binding/c/lottieanimation_capi.cpp @@ -17,11 +17,14 @@ */ #include "rlottie.h" +#include "rlottie_capi.h" #include "vdebug.h" using namespace rlottie; extern "C" { +#include +#include struct Lottie_Animation_S { @@ -148,4 +151,58 @@ lottie_animation_render_flush(Lottie_Animation_S *animation) return animation->mBufferRef; } +LOT_EXPORT void +lottie_animation_property_override(Lottie_Animation_S *animation, + const Lottie_Animation_Property type, + const char *keypath, + ...) +{ + va_list prop; + va_start(prop, keypath); + + switch(type) { + case LOTTIE_ANIMATION_PROPERTY_FILLCOLOR: { + double r = va_arg(prop, double); + double g = va_arg(prop, double); + double b = va_arg(prop, double); + if (r > 1 || r < 0 || g > 1 || g < 0 || b > 1 || b < 0) break; + animation->mAnimation->setValue(keypath, rlottie::Color(r, g, b)); + break; + } + case LOTTIE_ANIMATION_PROPERTY_FILLOPACITY: { + double opacity = va_arg(prop, double); + if (opacity > 100 || opacity < 0) break; + animation->mAnimation->setValue(keypath, (float)opacity); + break; + } + case LOTTIE_ANIMATION_PROPERTY_STROKECOLOR: { + double r = va_arg(prop, double); + double g = va_arg(prop, double); + double b = va_arg(prop, double); + if (r > 1 || r < 0 || g > 1 || g < 0 || b > 1 || b < 0) break; + animation->mAnimation->setValue(keypath, rlottie::Color(r, g, b)); + break; + } + case LOTTIE_ANIMATION_PROPERTY_STROKEOPACITY: { + double opacity = va_arg(prop, double); + if (opacity > 100 || opacity < 0) break; + animation->mAnimation->setValue(keypath, (float)opacity); + break; + } + case LOTTIE_ANIMATION_PROPERTY_STROKEWIDTH: { + double width = va_arg(prop, double); + if (width < 0) break; + animation->mAnimation->setValue(keypath, (float)width); + break; + } + case LOTTIE_ANIMATION_PROPERTY_TR_ANCHOR: + case LOTTIE_ANIMATION_PROPERTY_TR_POSITION: + case LOTTIE_ANIMATION_PROPERTY_TR_SCALE: + case LOTTIE_ANIMATION_PROPERTY_TR_ROTATION: + case LOTTIE_ANIMATION_PROPERTY_TR_OPACITY: + //@TODO handle propery update. + break; + } + va_end(prop); +} }