Skip to content

Instantly share code, notes, and snippets.

@sromku
Created December 22, 2013 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sromku/9be9513d441f151bf9dd to your computer and use it in GitHub Desktop.
Save sromku/9be9513d441f151bf9dd to your computer and use it in GitHub Desktop.
ReverseDelayInterplorator
/**
* 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