From: subhransu sekhar mohanty Date: Sat, 14 Jul 2018 06:48:14 +0000 (+0900) Subject: vector: convert radial gradient parameter from lottie space to vector space. X-Git-Tag: submit/tizen/20180917.042405~253 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F46%2F184146%2F3;p=platform%2Fcore%2Fuifw%2Flottie-player.git vector: convert radial gradient parameter from lottie space to vector space. Change-Id: I1894dd03eb0ccd0266fa098eaaae4aa4bf1e1d57 --- diff --git a/src/lottie/lottiemodel.cpp b/src/lottie/lottiemodel.cpp index 29156e6..1a7e3b8 100644 --- a/src/lottie/lottiemodel.cpp +++ b/src/lottie/lottiemodel.cpp @@ -335,8 +335,12 @@ void LOTGradient::update(std::unique_ptr &grad, int frameNo) VPointF end = mEndPoint.value(frameNo); grad->radial.cx = start.x(); grad->radial.cy = start.y(); - grad->radial.fx = end.x(); - grad->radial.fy = end.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; + grad->radial.fradius = 0; } } diff --git a/src/vector/vglobal.h b/src/vector/vglobal.h index b531344..fb96f30 100644 --- a/src/vector/vglobal.h +++ b/src/vector/vglobal.h @@ -96,6 +96,21 @@ static inline bool vIsNull(float f) return std::abs(f) <= 0.00001f; } +// Approximate sqrt(x*x + y*y) using the alpha max plus beta min algorithm. +// This uses alpha = 1, beta = 3/8, which results in a maximum error of less +// than 7% compared to the correct value. +static inline float +vLineLength(float x1, float y1, float x2, float y2) +{ + float x = x2 - x1; + float y = y2 - y1; + + x = x < 0 ? -x : x; + y = y < 0 ? -y : y; + + return (x > y ? x + 0.375 * y : y + 0.375 * x); +} + class vFlagHelper { int i;