lottie: refactor to use line api to calculate angle. 23/193123/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Thu, 15 Nov 2018 02:40:04 +0000 (11:40 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Thu, 15 Nov 2018 02:40:04 +0000 (11:40 +0900)
Change-Id: If9440f5fbf1b926a969226aad524db74881ba12f

src/lottie/lottiemodel.cpp

index 38179a9..d6f50ce 100644 (file)
@@ -245,12 +245,9 @@ void LOTGradient::update(std::unique_ptr<VGradient> &grad, int frameNo)
          */
         float progress = mHighlightLength.value(frameNo) / 100.0f;
         if (vCompare(progress, 1.0f)) progress = 0.99f;
-        float dy = end.y() - start.y();
-        float dx = end.x() - start.x();
-        float slope = (dx == 0) ? dy * INFINITY : dy / dx;
-        float startAngleRad = std::atan(slope);
-        int   highlightAngle = mHighlightAngle.value(frameNo);
-        float angle = startAngleRad + (highlightAngle * M_PI / 180.0f);
+        float startAngle = VLine(start, end).angle();
+        float highlightAngle = mHighlightAngle.value(frameNo);
+        float angle = ((startAngle + highlightAngle) * M_PI) / 180.0f;
         grad->radial.fx =
             grad->radial.cx + std::cos(angle) * progress * grad->radial.cradius;
         grad->radial.fy =