Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TreyCai/858479bf50a3b3bbe305 to your computer and use it in GitHub Desktop.
Save TreyCai/858479bf50a3b3bbe305 to your computer and use it in GitHub Desktop.
A better AccelerateDecelerateInterpolator
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