For precision programmatic animation!
Translated from the JavaScript in Sean Yen’s Easing equations
Illustrations adapted from Andrey Sitnik and Ivan Solovev’s Easings.net
Example usage:
duration = 30
for frame in range(duration):
return ease_in_out_quad(frame/duration)def linear(t):
return tdef ease_in_sine(t):
import math
return -math.cos(t * math.pi / 2) + 1def ease_out_sine(t):
import math
return math.sin(t * math.pi / 2)def ease_in_out_sine(t):
import math
return -(math.cos(math.pi * t) - 1) / 2def ease_in_quad(t):
return t * tdef ease_out_quad(t):
return -t * (t - 2)def ease_in_out_quad(t):
t *= 2
if t < 1:
return t * t / 2
else:
t -= 1
return -(t * (t - 2) - 1) / 2def ease_in_cubic(t):
return t * t * tdef ease_out_cubic(t):
t -= 1
return t * t * t + 1def ease_in_out_cubic(t):
t *= 2
if t < 1:
return t * t * t / 2
else:
t -= 2
return (t * t * t + 2) / 2def ease_in_quart(t):
return t * t * t * tdef ease_out_quart(t):
t -= 1
return -(t * t * t * t - 1)def ease_in_out_quart(t):
t *= 2
if t < 1:
return t * t * t * t / 2
else:
t -= 2
return -(t * t * t * t - 2) / 2def ease_in_quint(t):
return t * t * t * t * tdef ease_out_quint(t):
t -= 1
return t * t * t * t * t + 1def ease_in_out_quint(t):
t *= 2
if t < 1:
return t * t * t * t * t / 2
else:
t -= 2
return (t * t * t * t * t + 2) / 2def ease_in_expo(t):
import math
return math.pow(2, 10 * (t - 1))def ease_out_expo(t):
import math
return -math.pow(2, -10 * t) + 1def ease_in_out_expo(t):
import math
t *= 2
if t < 1:
return math.pow(2, 10 * (t - 1)) / 2
else:
t -= 1
return -math.pow(2, -10 * t) - 1def ease_in_circ(t):
import math
return 1 - math.sqrt(1 - t * t)def ease_out_circ(t):
import math
t -= 1
return math.sqrt(1 - t * t)def ease_in_out_circ(t):
import math
t *= 2
if t < 1:
return -(math.sqrt(1 - t * t) - 1) / 2
else:
t -= 2
return (math.sqrt(1 - t * t) + 1) / 2





















@Enyium Done! I’m a bit of a Python dilettante, so I wasn’t aware that was a naming convention.