Created
October 9, 2012 12:03
-
-
Save AdamSwinden/3858370 to your computer and use it in GitHub Desktop.
Animation Curves
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
// Quadratic | |
GLfloat QuadraticEaseOut(float t, float start, float end) { | |
if (t < 0.0f) t = 0.0f; | |
if (t > 1.0f) t = 1.0f; | |
return -end * t*(t-2) + start; | |
} | |
GLfloat QuadraticEaseIn(float t, float start, float end) { | |
if (t < 0.0f) t = 0.0f; | |
if (t > 1.0f) t = 1.0f; | |
return end * t * t + start; | |
} | |
GLfloat QuadraticEaseInOut(float t, float start, float end) { | |
if (t < 0.0f) t = 0.0f; | |
if (t > 1.0f) t = 1.0f; | |
t *= 2; | |
if (t < 1) return end/2*t*t + start; | |
t --; | |
return -end/2 * (t*(t-2) - 1) + start; | |
} | |
// Cubic | |
GLfloat CubicEaseOut(float t, float start, float end) { | |
if (t < 0.0f) t = 0.0f; | |
if (t > 1.0f) t = 1.0f; | |
t--; | |
return end*(t*t*t + 1) + start; | |
} | |
// Quintic | |
GLfloat QuinticEaseIn(float t, float start, float end) { | |
if (t < 0.0f) t = 0.0f; | |
if (t > 1.0f) t = 1.0f; | |
return end*t*t*t*t*t + start; | |
}; | |
GLfloat QuinticEaseOut(float t, float start, float end) { | |
if (t < 0.0f) t = 0.0f; | |
if (t > 1.0f) t = 1.0f; | |
t--; | |
return end*(t*t*t*t*t + 1) + start; | |
} | |
GLfloat QuinticEaseInOut(float t, float start, float end) { | |
if (t < 0.0f) t = 0.0f; | |
if (t > 1.0f) t = 1.0f; | |
t *= 2; | |
if (t < 1) return end/2*t*t*t*t*t + start; | |
t -= 2; | |
return end/2*(t*t*t*t*t + 2) + start; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment