From: subhransu mohanty Date: Wed, 18 Jul 2018 23:33:50 +0000 (+0900) Subject: lottie/model: convert highlightangle and highlightlength of radial from lottie to... X-Git-Tag: submit/tizen/20180917.042405~230 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1442d9c22da95a9988e9276b0c4789e00b83cd2a;p=platform%2Fcore%2Fuifw%2Flottie-player.git lottie/model: convert highlightangle and highlightlength of radial from lottie to vector space. Change-Id: I9874ccb53e3fe85a14c2ecd6394dbdb4d9f42790 --- diff --git a/src/lottie/lottiemodel.cpp b/src/lottie/lottiemodel.cpp index 1a7e3b8..a31f640 100644 --- a/src/lottie/lottiemodel.cpp +++ b/src/lottie/lottiemodel.cpp @@ -336,10 +336,24 @@ void LOTGradient::update(std::unique_ptr &grad, int frameNo) grad->radial.cx = start.x(); grad->radial.cy = start.y(); grad->radial.cradius = vLineLength(start.x(), start.y(), end.x(), end.y()); - - //TODO update focal radius and focal point - grad->radial.fx = grad->radial.cx; - grad->radial.fy = grad->radial.cy; + /* + * Focal point is the point lives in highlight length distance from center along the + * line (start, end) and rotated by highlight angle. + * below calculation first finds the quadrant(angle) on which the point lives by applying + * inverse slope formula then adds the rotation angle to find the final angle. + * then point is retrived using circle equation of center, angle and distance. + */ + 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); + grad->radial.fx = grad->radial.cx + std::cos(angle) * progress * grad->radial.cradius; + grad->radial.fy = grad->radial.cy + std::sin(angle) * progress * grad->radial.cradius; + // Lottie dosen't have any focal radius concept. grad->radial.fradius = 0; } }