rlottie: Supports the Transform Rotation property. accepted/tizen/unified/20200129.022646 submit/tizen/20200122.213749 submit/tizen/20200127.213359
authorJunsuChoi <jsuya.choi@samsung.com>
Mon, 20 Jan 2020 01:22:40 +0000 (10:22 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Tue, 21 Jan 2020 21:59:33 +0000 (06:59 +0900)
Use setValue<rlottie::Property::TrRotation> return float type.
The value is degree. [0 ~ 360]

Example) example/demo

example/demo.cpp
src/binding/c/lottieanimation_capi.cpp
src/lottie/lottieitem.cpp
src/lottie/lottieproxymodel.h

index b5a8a18..c6b4cbc 100644 (file)
@@ -34,6 +34,7 @@ public:
         Demo4(app, filePath);
         Demo5(app, filePath);
         Demo6(app, filePath);
+        Demo7(app, filePath);
     }
     void Demo1(EvasApp *app, std::string &filePath) {
         /* Fill Color */
@@ -157,6 +158,24 @@ public:
         view6->loop(true);
         view6->setRepeatMode(LottieView::RepeatMode::Reverse);
     }
+
+    void Demo7(EvasApp *app, std::string &filePath) {
+        /* Transform rotation */
+        view7.reset(new LottieView(app->evas()));
+        view7->setFilePath(filePath.c_str());
+        if (view7->player()) {
+            view7->player()->setValue<rlottie::Property::TrRotation>("Shape Layer 2.Shape 1",
+                [](const rlottie::FrameInfo& info) {
+                          return info.curFrame() * 20;
+                 });
+        }
+        view7->setPos(1800, 0);
+        view7->setSize(300, 300);
+        view7->show();
+        view7->play();
+        view7->loop(true);
+        view7->setRepeatMode(LottieView::RepeatMode::Reverse);
+    }
 private:
     std::unique_ptr<LottieView>  view1;
     std::unique_ptr<LottieView>  view2;
@@ -164,6 +183,7 @@ private:
     std::unique_ptr<LottieView>  view4;
     std::unique_ptr<LottieView>  view5;
     std::unique_ptr<LottieView>  view6;
+    std::unique_ptr<LottieView>  view7;
 };
 
 static void
@@ -176,7 +196,7 @@ onExitCb(void *data, void */*extra*/)
 int
 main(void)
 {
-   EvasApp *app = new EvasApp(1800, 300);
+   EvasApp *app = new EvasApp(2100, 300);
    app->setup();
 
    std::string filePath = DEMO_DIR;
index 07bfb79..ba19502 100644 (file)
@@ -216,8 +216,12 @@ lottie_animation_property_override(Lottie_Animation_S *animation,
         animation->mAnimation->setValue<rlottie::Property::TrScale>(keypath, rlottie::Size((float)w, (float)h));
         break;
     }
+    case LOTTIE_ANIMATION_PROPERTY_TR_ROTATION: {
+        double r = va_arg(prop, double);
+        animation->mAnimation->setValue<rlottie::Property::TrRotation>(keypath, (float)r);
+        break;
+    }
     case LOTTIE_ANIMATION_PROPERTY_TR_ANCHOR:
-    case LOTTIE_ANIMATION_PROPERTY_TR_ROTATION:
     case LOTTIE_ANIMATION_PROPERTY_TR_OPACITY:
         //@TODO handle propery update.
         break;
index 4ca524e..e7f9303 100644 (file)
@@ -918,10 +918,17 @@ void LOTContentGroupItem::update(int frameNo, const VMatrix &parentMatrix,
         if (mModel.filter().hasFilter(rlottie::Property::TrScale)){
              auto sz = mModel.scale(frameNo);
              m.scale(sz.width() / 100.0, sz.height() / 100.0);
+             newFlag |= DirtyFlagBit::Matrix;
+        }
+        if (mModel.filter().hasFilter(rlottie::Property::TrRotation)){
+             float r = mModel.rotate(frameNo);
+             m.rotate(r);
+             newFlag |= DirtyFlagBit::Matrix;
         }
         if (mModel.filter().hasFilter(rlottie::Property::TrPosition)){
              auto ps = mModel.position(frameNo);
              m.translate(ps.x(), ps.y());
+             newFlag |= DirtyFlagBit::Matrix;
         }
 
         if (!(flag & DirtyFlagBit::Matrix) && !mModel.transform()->isStatic() &&
index 8d41ce1..ab33884 100644 (file)
@@ -370,6 +370,13 @@ public:
         return VSize(_modelData->mTransform->matrix(frame).m_11() * 100.0,
                        _modelData->mTransform->matrix(frame).m_22() * 100.0);
     }
+    float rotate(int frame) const
+    {
+        if (mFilter.hasFilter(rlottie::Property::TrRotation)) {
+            return mFilter.value(rlottie::Property::TrRotation, frame);
+        }
+        return atan2(_modelData->mTransform->matrix(frame).m_21(), _modelData->mTransform->matrix(frame).m_11());
+    }
 private:
     LOTGroupData               *_modelData;
     LOTFilter                  mFilter;