Created
June 24, 2014 08:19
-
-
Save TreyCai/858479bf50a3b3bbe305 to your computer and use it in GitHub Desktop.
A better AccelerateDecelerateInterpolator
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
package com.trey.sample; | |
import android.view.animation.Interpolator; | |
/** | |
* Created on 14-6-24. | |
* | |
* @author Trey Walker | |
*/ | |
public class BetterAccelerateDecelerateInterpolator implements Interpolator { | |
public BetterAccelerateDecelerateInterpolator() { | |
} | |
@Override | |
public float getInterpolation(float input) { | |
float x = 2 * input; | |
if (input < 0.5f) { | |
return (float) (0.5f * Math.pow(x, 5)); | |
} | |
x = (input - 0.5f) * 2 - 1; | |
return (float) (0.5f * Math.pow(x, 5) + 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment