Created
December 22, 2013 12:58
-
-
Save sromku/9be9513d441f151bf9dd to your computer and use it in GitHub Desktop.
ReverseDelayInterplorator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The graph: | |
* | |
* ---- | |
* / | |
* / | |
* / | |
* ---- | |
* | |
* @author sromku | |
*/ | |
public class ReverseDelayInterpolator implements TimeInterpolator { | |
private final float mDelayFraction; | |
private final float mAngle; | |
public ReverseDelayInterpolator(float delayFraction) { | |
mDelayFraction = delayFraction; | |
mAngle = 1 / (1 - mDelayFraction); | |
} | |
@Override | |
public float getInterpolation(float input) { | |
// check if we on the left side of the graph | |
if (input <= mDelayFraction / 2) { | |
return 0; | |
} | |
// check if we on the right side of the graph | |
if (input >= 1 - mDelayFraction / 2) { | |
return 1; | |
} | |
/* | |
* We make indentation of the graph to left (zero axis) and make the | |
* angle based on the fraction | |
*/ | |
return (input - mDelayFraction / 2) * mAngle; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment