void ofxPenner::update() { float t = ofGetElapsedTimef(); for (map<int,parameter>::iterator iter=params.begin(); iter!=params.end(); iter++) { parameter &p = iter->second; if (p.bEasing) { float delta = t-p.time; if (delta<p.duration) { switch (p.ease_function) { case EASE_OUT_BACK: p.v = easeOutBack(delta, p.b, p.c, p.duration); break; case EASE_OUT_QUAD: p.v = easeOutQuad(delta, p.b, p.c, p.duration); default: break; } } else { p.v = p.e; p.bEasing = false; } } } }
/** * Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration. * * @param t Current time (in frames or seconds). * @return The correct value. */ static qreal easeOutInQuad(qreal t) { if (t < 0.5) return easeOutQuad (t*2)/2; return easeInQuad((2*t)-1)/2 + 0.5; }