qreal value(qreal t) { qreal a = (_a < 0) ? 1.0f : _a; switch(_t) { case In: return easeInBounce(t, a); case Out: return easeOutBounce(t, a); case InOut: return easeInOutBounce(t, a); case OutIn: return easeOutInBounce(t, a); default: return t; } }
double valueForProgress ( double a_fProgress ) const { double fAmplitude = (m_fAmplitude < 0.0) ? 1.0 : m_fAmplitude; switch ( m_eType ) { case In: return easeInBounce ( a_fProgress, fAmplitude ); case Out: return easeOutBounce ( a_fProgress, fAmplitude ); case InOut: return easeInOutBounce ( a_fProgress, fAmplitude ); case OutIn: return easeOutInBounce ( a_fProgress, fAmplitude ); default: return a_fProgress; } }
static qreal easeInBounce(qreal t) { const qreal a = 1; return easeInBounce(t, a); }
/** * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration. * * @param t Current time (in frames or seconds). * @param a Amplitude. * @return The correct value. */ static qreal easeInOutBounce(qreal t, qreal a) { if (t < 0.5) return easeInBounce (2*t, a)/2; else return (t == 1.0) ? 1.0 : easeOutBounce (2*t - 1, a)/2 + 0.5; }
double easeInOutBounce(double t, double b, double c, double d) { if (t < d/2) return easeInBounce (t*2, 0, c, d) * .5 + b; else return easeOutBounce (t*2-d, 0, c, d) * .5 + c*.5 + b; }