How to apply easing animation function on view in android -
i want apply translate animation
on android view
(button).. using custom interpolator
..where easing function is:
public static float easeout(float t,float b , float c, float d) { if ((t/=d) < (1/2.75f)) { return c*(7.5625f*t*t) + b; } else if (t < (2/2.75f)) { return c*(7.5625f*(t-=(1.5f/2.75f))*t + .75f) + b; } else if (t < (2.5/2.75)) { return c*(7.5625f*(t-=(2.25f/2.75f))*t + .9375f) + b; } else { return c*(7.5625f*(t-=(2.625f/2.75f))*t + .984375f) + b; } }
i have example uses custom interpolator this:
the intreplator :
public class hesitateinterpolator implements interpolator { public hesitateinterpolator() { } public float getinterpolation(float t) { float x = 2.0f * t - 1.0f; return 0.5f * (x * x * x + 1.0f); } }
and used :
scaleanimation anim = new scaleanimation(0.0f, 1.0f, 0.0f, 1.0f); anim.setinterpolator(new hesitateinterpolator());
my question is: these values b,c,d ??
according robert penner's easing functions, stated here:
t: current time, b: beginning value, c: change in value, d: duration
if want implement custom interpolator, have make this:
(this implementation easeinoutquint
)
public class mvacceleratedecelerateinterpolator implements interpolator { // easeinoutquint public float getinterpolation(float t) { float x; if (t<0.5f) { x = t*2.0f; return 0.5f*x*x*x*x*x; } x = (t-0.5f)*2-1; return 0.5f*x*x*x*x*x+1; } }
edit: implement easing function need math knowledge, considering getinterpolation
method gets t parameter, 0.0 1.0.
so need develop y(t) function, t 0 1, , y values 0 1, shown below:
what change curve 0 1 (in image green line linear one, example). need 'normalize' easing functions remain in (0, 1) x (0, 1) square, can see in easeinoutquint
implementation.
Comments
Post a Comment