Last active
October 16, 2016 16:22
-
-
Save MattRix/feea68fd3dae16c760d6c665fd530d46 to your computer and use it in GitHub Desktop.
RTEase - simple easing equations
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 static class RTEase | |
{ | |
public static Func<float,float> Linear = (t) => { return t; }; | |
public static Func<float,float> Instant = (t) => { return t < 1f ? 0f : 1f;}; | |
public static Func<float,float> QuadIn = (t) => { return t * t; }; | |
public static Func<float,float> QuadOut = (t) => { return 2f*t - t*t;}; | |
public static Func<float,float> QuadInOut = (t) => { return (t <= 0.5f) ? (t*t*2f) : (-1.0f + 4f*t + -2f*t*t);}; | |
public static Func<float,float> CubeIn = (t) => { return t * t * t; }; | |
public static Func<float,float> CubeOut = (t) => { return 1f - CubeIn(1f - t); }; | |
public static Func<float,float> CubeInOut = (t) => { return (t <= 0.5f) ? CubeIn(t * 2f) * 0.5f : CubeOut(t * 2f - 1f) * 0.5f + 0.5f; }; | |
public static Func<float,float> BackIn = (t) => { return t * t * (2.70158f * t - 1.70158f); }; | |
public static Func<float,float> BackOut = (t) => { return 1f - BackIn(1f - t); }; | |
public static Func<float,float> BackInOut = (t) => { return (t <= 0.5f) ? BackIn(t * 2f) * 0.5f : BackOut(t * 2f - 1f) * 0.5f + 0.5f; }; | |
public static Func<float,float> ExpoIn = (t) => { return Mathf.Pow(2f, 10f * (t-1.0f)); }; | |
public static Func<float,float> ExpoOut = (t) => { return 1f - Mathf.Pow(2f, -10f * t); }; | |
public static Func<float,float> ExpoInOut = (t) => { return t < .5f ? ExpoIn(t * 2f) * 0.5f : ExpoOut(t * 2f - 1f) * 0.5f + 0.5f; }; | |
public static Func<float,float> SineIn = (t) => { return -Mathf.Cos(Mathf.PI * 0.5f * t) + 1f; }; | |
public static Func<float,float> SineOut = (t) => { return Mathf.Sin(Mathf.PI * 0.5f * t); }; | |
public static Func<float,float> SineInOut = (t) => { return -Mathf.Cos(Mathf.PI * t) * 0.5f + .5f; }; | |
public static Func<float,float> ElasticIn = (t) => { return 1f - ElasticOut(1f - t); }; | |
public static Func<float,float> ElasticOut = (t) => { return Mathf.Pow(2f, -10f * t) * Mathf.Sin((t - 0.075f) * (2f * Mathf.PI) / 0.3f) + 1f; }; | |
public static Func<float,float> ElasticInOut = (t) => { return (t <= 0.5f) ? ElasticIn(t * 2f) / 2f : ElasticOut(t * 2f - 1f) * 0.5f + 0.5f; }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment