Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
public class StarInterpolator implements Interpolator {
public StarInterpolator() {
}
@SuppressWarnings({"UnusedDeclaration"})
public StarInterpolator(Context context, AttributeSet attrs) {
}
private static float bounce(float t) {
return t * t * 8.0f;
}
@Override
public float getInterpolation(final float v) {
//y = 0.65sin(6.28x - PI/2) + 0.65 (0 <= x < 0.748)
//y = 8 * (1.1226x - 0.8526)^2 + 0.9 (0.748 <= x < 0.9644)
//y = -8 * (1.1226x - 1.0435)^2 + 1.05 (0.9644 <= x <= 1)
float x = v * 1.1226f;
if (x < 0.7408f) {
return (float) (0.65 * Math.sin(6.28 * v - Math.PI / 2) + 0.65);
} else if (x < 0.9644f) {
return bounce(x - 0.8526f) + 0.9f;
} else {
return -1 * bounce(x - 1.0435f) + 1.05f;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment