summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2014-12-09 12:19:03 +0900
committerChunEon Park <hermet@hermet.pe.kr>2014-12-09 16:36:53 +0900
commit4e1c0c54eca84d6cca43e44a6c1dc85cc8ebe404 (patch)
tree3307c98af59c455a66fee101cb2862a8d96b5302
parent7642c3357b56a4d46f7ee276d3ba2645760dff05 (diff)
Revert "ecore/animator: fix the bezier cubic compuation."
This reverts commit 2e1032e28f0cd704ffaf28cea0b5ad533ae2b6c1. This patch is wrong. On reviewing the origin implementation.
-rw-r--r--src/lib/ecore/ecore_anim.c65
1 files changed, 58 insertions, 7 deletions
diff --git a/src/lib/ecore/ecore_anim.c b/src/lib/ecore/ecore_anim.c
index 3b8f987..e248f05 100644
--- a/src/lib/ecore/ecore_anim.c
+++ b/src/lib/ecore/ecore_anim.c
@@ -308,18 +308,69 @@ _pos_map_spring(double pos,
308} 308}
309 309
310static double 310static double
311_cubic_bezier_a (double a1, double a2)
312{
313 return 1.0 - 3.0 * a2 + 3.0 * a1;
314}
315
316static double
317_cubic_bezier_b (double a1, double a2)
318{
319 return 3.0 * a2 - 6.0 * a1;
320}
321
322static double
323_cubic_bezier_c(double a1)
324{
325 return 3.0 * a1;
326}
327
328static double
329_cubic_bezier_calc(double t,
330 double a1,
331 double a2)
332{
333 return ((_cubic_bezier_a(a1, a2) * t +
334 _cubic_bezier_b(a1, a2)) * t +
335 _cubic_bezier_c(a1)) * t;
336}
337
338static double
339_cubic_bezier_slope_get(double t,
340 double a1,
341 double a2)
342{
343 return 3.0 * _cubic_bezier_a(a1, a2) * t * t +
344 2.0 * _cubic_bezier_b(a1, a2) * t +
345 _cubic_bezier_c(a1);
346}
347
348static double
349_cubic_bezier_t_get(double a,
350 double x1,
351 double x2)
352{
353 double guess_t = a;
354 for (int i = 0; i < 4; ++i)
355 {
356 double current_slope = _cubic_bezier_slope_get(a, x1, x2);
357 if (current_slope == 0.0)
358 return guess_t;
359 double current_x = _cubic_bezier_calc(guess_t, x1, x2) - a;
360 guess_t -= current_x / current_slope;
361 }
362 return guess_t;
363}
364
365static double
311_pos_map_cubic_bezier(double pos, 366_pos_map_cubic_bezier(double pos,
312 double x1 EINA_UNUSED, 367 double x1,
313 double y1, 368 double y1,
314 double x2 EINA_UNUSED, 369 double x2,
315 double y2) 370 double y2)
316{ 371{
317 if (x1 == y1 && x2 == y2) return pos; 372 if (x1 == y1 && x2 == y2) return pos;
318 373 return _cubic_bezier_calc(_cubic_bezier_t_get(pos, x1, x2), y1, y2);
319 /* Bezier Cubic formula:
320 y(t) = (1 - t)^3 + 3t(1 - t)^2 + 3t^2(1 - t) + t^3 */
321 return (pow((1 - pos), 3) * 0) + (3 * pos * pow((1 - pos), 2) * y1) +
322 (3 * pow(pos, 2) * (1 - pos) * y2) + (pow(pos, 3) * 1);
323} 374}
324 375
325#define DBL_TO(Fp) eina_f32p32_double_to(Fp) 376#define DBL_TO(Fp) eina_f32p32_double_to(Fp)