Last active
November 1, 2019 13:11
-
-
Save amalChandran/6abc2f7cbd2643492e3fc45e9c3f4819 to your computer and use it in GitHub Desktop.
Easy custom interpolators for android.
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 BezInterpolator { | |
private static BezInterpolator bezInterpolator; | |
//Control points to create the cubic bezier curve. | |
private float[] PRINCIPLE_DEFAULT_EASE = {(float)0.25, (float)0.1, (float)0.25, (float)1.0}; | |
private float[] EASE_OUT = {(float)0, (float)0, (float)0.58, (float)1.0}; | |
private float[] EASE_IN = {(float)0.42, (float)0, (float)1.0, (float)1.0}; | |
public static BezInterpolator getInstance(){ | |
if(bezInterpolator == null){ | |
bezInterpolator = new BezInterpolator(); | |
} | |
return bezInterpolator; | |
} | |
public Interpolator getDefaultInterpolator(){ | |
return PathInterpolatorCompat.create(PRINCIPLE_DEFAULT_EASE[0], | |
PRINCIPLE_DEFAULT_EASE[1], | |
PRINCIPLE_DEFAULT_EASE[2], | |
PRINCIPLE_DEFAULT_EASE[3]); | |
} | |
public Interpolator getEaseOutInterpolator(){ | |
return PathInterpolatorCompat.create(EASE_OUT[0], | |
EASE_OUT[1], | |
EASE_OUT[2], | |
EASE_OUT[3]); | |
} | |
public Interpolator getEaseInInterpolator(){ | |
return PathInterpolatorCompat.create(EASE_IN[0], | |
EASE_IN[1], | |
EASE_IN[2], | |
EASE_IN[3]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment