Created
May 26, 2015 09:41
-
-
Save amyu/ebd5fec600c398fcdb88 to your computer and use it in GitHub Desktop.
This file contains 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
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