Skip to content

Instantly share code, notes, and snippets.

@aybe
Forked from MattRix/RTEase.cs
Created October 16, 2016 16:22

Revisions

  1. @MattRix MattRix renamed this gist May 14, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion RXEase.cs → RTEase.cs
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    public static class RXEase
    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;};
  2. @MattRix MattRix revised this gist May 14, 2016. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions RXEase.cs
    Original file line number Diff line number Diff line change
    @@ -6,18 +6,18 @@ public static class RXEase
    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); }; //needs optimization
    public static Func<float,float> CubeInOut = (t) => { return (t <= 0.5f) ? CubeIn(t * 2f) * 0.5f : CubeOut(t * 2f - 1f) * 0.5f + 0.5f; }; //needs optimization
    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); }; //needs optimization
    public static Func<float,float> BackInOut = (t) => { return (t <= 0.5f) ? BackIn(t * 2f) * 0.5f : BackOut(t * 2f - 1f) * 0.5f + 0.5f; }; //needs optimization
    public static Func<float,float> ExpoIn = (t) => { return Mathf.Pow(2f, 10f * (t-1.0f)); }; //needs optimization
    public static Func<float,float> ExpoOut = (t) => { return 1f - Mathf.Pow(2f, -10f * t); }; //needs optimization
    public static Func<float,float> ExpoInOut = (t) => { return t < .5f ? ExpoIn(t * 2f) * 0.5f : ExpoOut(t * 2f - 1f) * 0.5f + 0.5f; }; //needs optimization
    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); }; //needs optimization
    public static Func<float,float> ElasticOut = (t) => { return Mathf.Pow(2f, -10f * t) * Mathf.Sin((t - 0.075f) * (2f * Mathf.PI) / 0.3f) + 1f; }; //needs optimization
    public static Func<float,float> ElasticInOut = (t) => { return (t <= 0.5f) ? ElasticIn(t * 2f) / 2f : ElasticOut(t * 2f - 1f) * 0.5f + 0.5f; }; //needs optimization
    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; };
    }
  3. @MattRix MattRix created this gist May 14, 2016.
    23 changes: 23 additions & 0 deletions RXEase.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    public static class RXEase
    {
    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); }; //needs optimization
    public static Func<float,float> CubeInOut = (t) => { return (t <= 0.5f) ? CubeIn(t * 2f) * 0.5f : CubeOut(t * 2f - 1f) * 0.5f + 0.5f; }; //needs optimization
    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); }; //needs optimization
    public static Func<float,float> BackInOut = (t) => { return (t <= 0.5f) ? BackIn(t * 2f) * 0.5f : BackOut(t * 2f - 1f) * 0.5f + 0.5f; }; //needs optimization
    public static Func<float,float> ExpoIn = (t) => { return Mathf.Pow(2f, 10f * (t-1.0f)); }; //needs optimization
    public static Func<float,float> ExpoOut = (t) => { return 1f - Mathf.Pow(2f, -10f * t); }; //needs optimization
    public static Func<float,float> ExpoInOut = (t) => { return t < .5f ? ExpoIn(t * 2f) * 0.5f : ExpoOut(t * 2f - 1f) * 0.5f + 0.5f; }; //needs optimization
    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); }; //needs optimization
    public static Func<float,float> ElasticOut = (t) => { return Mathf.Pow(2f, -10f * t) * Mathf.Sin((t - 0.075f) * (2f * Mathf.PI) / 0.3f) + 1f; }; //needs optimization
    public static Func<float,float> ElasticInOut = (t) => { return (t <= 0.5f) ? ElasticIn(t * 2f) / 2f : ElasticOut(t * 2f - 1f) * 0.5f + 0.5f; }; //needs optimization
    }