I'm wanting an easing function equivalent to UIViewAnimationCurveEaseInOut, but don't see that Apple exposes that as a function.
I've tried the easeInOutQuad function posted here with no success. My Objective-C version of that function is:
-(float) getEaseInOutValueWithElapsedMillis: (float) t startValue: (float) b endValue: (float) c andTotalMillis: (float) d {
float value =0.0f;
if ((t/=d/2.0f) <1.0f)
value =c/2.0f*t*t + b;
else
value =-c/2.0f * ((--t)*(t-2.0f) - 1.0f) + b;
debug(@"t=%f b=%f c=%f d=%f value=%f", t, b, c, d, value);
return value;
}
And the logged results are:
When the start value is less than the end value:
t=0.066467 b=110.000000 c=225.000000 d=500.000000 value=110.497017
t=0.133133 b=110.000000 c=225.000000 d=500.000000 value=111.993996
t=0.199799 b=110.000000 c=225.000000 d=500.000000 value=114.490944
...
t=0.999786 b=110.000000 c=225.000000 d=500.000000 value=222.451935
t=0.066452 b=110.000000 c=225.000000 d=500.000000 value=236.954926
t=0.133118 b=110.000000 c=225.000000 d=500.000000 value=250.457932
... (note that value shot right past c)
t=0.866440 b=110.000000 c=225.000000 d=500.000000 value=332.993195
t=0.933105 b=110.000000 c=225.000000 d=500.000000 value=334.496582
t=0.999771 b=110.000000 c=225.000000 d=500.000000 value=335.000000
And the 100% value ends up as b +c, rather than c.
When the start value is greater than the end value:
t=0.047389 b=225.000000 c=110.000000 d=700.000000 value=225.123520
t=0.095008 b=225.000000 c=110.000000 d=700.000000 value=225.496460
...
t=0.904504 b=225.000000 c=110.000000 d=700.000000 value=334.498413
t=0.952122 b=225.000000 c=110.000000 d=700.000000 value=334.873932
t=0.999740 b=225.000000 c=110.000000 d=700.000000 value=335.000000
Again, the 100% value ends up as b +c, rather than c.
Perhaps I've mangled the code. How can I achieve a proper ease-in ease-out?