summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2014-12-09 16:27:29 +0900
committerChunEon Park <hermet@hermet.pe.kr>2014-12-09 16:45:37 +0900
commit3670316e1572eee3dccf5be29e839d3a8cb7322e (patch)
tree6ec28b5f439ba5034edffe1c24d01b56ef9ab67f
parent4a5f8d6ac9746ef0c237242619e95aa233af2373 (diff)
ecore/animator: fix the wrong computation of bezier cubic.
Previous beizer cubic finds t value approximately. In this sequence, there were 2 problems. 1. Previous guess_t value should be passed to differential equation to get the more accurate t value. 2. Guessing time count is not enough. I found 6 is enough time to get the t value experimentally. Previously it just tried 4 times on the other hand. @fix
-rw-r--r--src/lib/ecore/ecore_anim.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/lib/ecore/ecore_anim.c b/src/lib/ecore/ecore_anim.c
index e248f05..a59320a 100644
--- a/src/lib/ecore/ecore_anim.c
+++ b/src/lib/ecore/ecore_anim.c
@@ -350,15 +350,24 @@ _cubic_bezier_t_get(double a,
350 double x1, 350 double x1,
351 double x2) 351 double x2)
352{ 352{
353#define APPROXIMATE_RANGE(val) \
354 ((((val) < 0.01) && ((val) > -0.01)) ? EINA_TRUE : EINA_FALSE)
355
356 const int LIMIT = 100;
357 double current_slope;
358 double tmp;
359 double current_x;
353 double guess_t = a; 360 double guess_t = a;
354 for (int i = 0; i < 4; ++i) 361
355 { 362 for (int i = 0; i < LIMIT; i++)
356 double current_slope = _cubic_bezier_slope_get(a, x1, x2); 363 {
357 if (current_slope == 0.0) 364 current_slope = _cubic_bezier_slope_get(guess_t, x1, x2);
358 return guess_t; 365 if (current_slope == 0.0) return guess_t;
359 double current_x = _cubic_bezier_calc(guess_t, x1, x2) - a; 366 current_x = _cubic_bezier_calc(guess_t, x1, x2) - a;
360 guess_t -= current_x / current_slope; 367 tmp = current_x / current_slope;
361 } 368 guess_t -= current_x / current_slope;
369 if (APPROXIMATE_RANGE(tmp)) break;
370 }
362 return guess_t; 371 return guess_t;
363} 372}
364 373