[TIDY] Apply autopep8 formatting
This commit is contained in:
parent
909bf79673
commit
b0e83b1134
12 changed files with 405 additions and 329 deletions
287
easing.py
287
easing.py
|
@ -4,208 +4,233 @@
|
|||
|
||||
import math
|
||||
|
||||
|
||||
def easeLinear(t, b, c, d):
|
||||
return c*t/d + b
|
||||
return c*t/d + b
|
||||
|
||||
|
||||
def easeOutCubic(t, b, c, d):
|
||||
t=float(t)/d-1
|
||||
return c*((t)*t*t + 1) + b
|
||||
t = float(t)/d-1
|
||||
return c*((t)*t*t + 1) + b
|
||||
|
||||
|
||||
def easeInCubic(t, b, c, d):
|
||||
t=float(t)/d
|
||||
return c*(t)*t*t + b;
|
||||
t = float(t)/d
|
||||
return c*(t)*t*t + b
|
||||
|
||||
|
||||
def easeInQuad(t, b, c, d):
|
||||
t /= d
|
||||
return c*t*t + b
|
||||
t /= d
|
||||
return c*t*t + b
|
||||
|
||||
|
||||
def easeOutQuad(t, b, c, d):
|
||||
t /= d
|
||||
return -c * t*(t-2) + b
|
||||
t /= d
|
||||
return -c * t*(t-2) + b
|
||||
|
||||
|
||||
def easeInOutQuad(t, b, c, d):
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return c/2*t*t + b
|
||||
t-=1
|
||||
return -c/2 * (t*(t-2) - 1) + b
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return c/2*t*t + b
|
||||
t -= 1
|
||||
return -c/2 * (t*(t-2) - 1) + b
|
||||
|
||||
|
||||
def easeInOutCubic(t, b, c, d):
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return c/2*t*t*t + b
|
||||
t -= 2
|
||||
return c/2*(t*t*t + 2) + b
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return c/2*t*t*t + b
|
||||
t -= 2
|
||||
return c/2*(t*t*t + 2) + b
|
||||
|
||||
|
||||
def easeInQuart(t, b, c, d):
|
||||
t /= d
|
||||
return c*t*t*t*t + b
|
||||
t /= d
|
||||
return c*t*t*t*t + b
|
||||
|
||||
|
||||
def easeOutQuart(t, b, c, d):
|
||||
t /= d
|
||||
t -= 1
|
||||
return -c * (t*t*t*t - 1) + b
|
||||
t /= d
|
||||
t -= 1
|
||||
return -c * (t*t*t*t - 1) + b
|
||||
|
||||
|
||||
def easeInOutQuart(t, b, c, d):
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return c/2*t*t*t*t + b
|
||||
t -= 2
|
||||
return -c/2 * (t*t*t*t - 2) + b
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return c/2*t*t*t*t + b
|
||||
t -= 2
|
||||
return -c/2 * (t*t*t*t - 2) + b
|
||||
|
||||
|
||||
def easeInQuint(t, b, c, d):
|
||||
t /= d
|
||||
return c*t*t*t*t*t + b
|
||||
t /= d
|
||||
return c*t*t*t*t*t + b
|
||||
|
||||
|
||||
def easeOutQuint(t, b, c, d):
|
||||
t /= d
|
||||
t -= 1
|
||||
return c*(t*t*t*t*t + 1) + b
|
||||
t /= d
|
||||
t -= 1
|
||||
return c*(t*t*t*t*t + 1) + b
|
||||
|
||||
|
||||
def easeInOutQuint(t, b, c, d):
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return c/2*t*t*t*t*t + b
|
||||
t -= 2
|
||||
return c/2*(t*t*t*t*t + 2) + b
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return c/2*t*t*t*t*t + b
|
||||
t -= 2
|
||||
return c/2*(t*t*t*t*t + 2) + b
|
||||
|
||||
|
||||
def easeInSine(t, b, c, d):
|
||||
return -c * math.cos(t/d * (math.pi/2)) + c + b
|
||||
return -c * math.cos(t/d * (math.pi/2)) + c + b
|
||||
|
||||
|
||||
def easeOutSine(t, b, c, d):
|
||||
return c * math.sin(t/d * (math.pi/2)) + b
|
||||
return c * math.sin(t/d * (math.pi/2)) + b
|
||||
|
||||
|
||||
def easeInOutSine(t, b, c, d):
|
||||
return -c/2 * (math.cos(math.pi*t/d) - 1) + b
|
||||
return -c/2 * (math.cos(math.pi*t/d) - 1) + b
|
||||
|
||||
|
||||
def easeInExpo(t, b, c, d):
|
||||
return c * math.pow( 2, 10 * (t/d - 1) ) + b
|
||||
return c * math.pow(2, 10 * (t/d - 1)) + b
|
||||
|
||||
|
||||
def easeOutExpo(t, b, c, d):
|
||||
return c * ( -math.pow( 2, -10 * t/d ) + 1 ) + b
|
||||
return c * (-math.pow(2, -10 * t/d) + 1) + b
|
||||
|
||||
|
||||
def easeInOutExpo(t, b, c, d):
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return c/2 * math.pow( 2, 10 * (t - 1) ) + b
|
||||
t -= 1
|
||||
return c/2 * ( -math.pow( 2, -10 * t) + 2 ) + b
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return c/2 * math.pow(2, 10 * (t - 1)) + b
|
||||
t -= 1
|
||||
return c/2 * (-math.pow(2, -10 * t) + 2) + b
|
||||
|
||||
|
||||
def easeInCirc(t, b, c, d):
|
||||
t /= d
|
||||
return -c * (math.sqrt(1 - t*t) - 1) + b
|
||||
t /= d
|
||||
return -c * (math.sqrt(1 - t*t) - 1) + b
|
||||
|
||||
|
||||
def easeOutCirc(t, b, c, d):
|
||||
t /= d;
|
||||
t -= 1
|
||||
return c * math.sqrt(1 - t*t) + b
|
||||
t /= d
|
||||
t -= 1
|
||||
return c * math.sqrt(1 - t*t) + b
|
||||
|
||||
|
||||
def easeInOutCirc(t, b, c, d):
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return -c/2 * (math.sqrt(1 - t*t) - 1) + b
|
||||
t -= 2
|
||||
return c/2 * (math.sqrt(1 - t*t) + 1) + b
|
||||
t /= d/2
|
||||
if t < 1:
|
||||
return -c/2 * (math.sqrt(1 - t*t) - 1) + b
|
||||
t -= 2
|
||||
return c/2 * (math.sqrt(1 - t*t) + 1) + b
|
||||
|
||||
|
||||
def easeInElastic(t, b, c, d, s = 1.70158):
|
||||
a = c
|
||||
def easeInElastic(t, b, c, d, s=1.70158):
|
||||
a = c
|
||||
|
||||
if t == 0:
|
||||
return b
|
||||
t /= d
|
||||
if t == 1:
|
||||
return b + c
|
||||
if t == 0:
|
||||
return b
|
||||
t /= d
|
||||
if t == 1:
|
||||
return b + c
|
||||
|
||||
p = d * 0.3
|
||||
if a < abs(c):
|
||||
a = c
|
||||
s = p / 4
|
||||
else:
|
||||
s = p / (2 * math.pi) * math.asin(c / a)
|
||||
p = d * 0.3
|
||||
if a < abs(c):
|
||||
a = c
|
||||
s = p / 4
|
||||
else:
|
||||
s = p / (2 * math.pi) * math.asin(c / a)
|
||||
|
||||
t -= 1
|
||||
return -(a * pow(2, 10 * t) * math.sin((t * d - s) * (2 * math.pi) / p)) + b
|
||||
t -= 1
|
||||
return -(a * pow(2, 10 * t) * math.sin((t * d - s) * (2 * math.pi) / p)) + b
|
||||
|
||||
def easeOutElastic(t, b, c, d, a = 1.70158):
|
||||
if t == 0:
|
||||
return b
|
||||
t /= d
|
||||
if t == 1:
|
||||
return b + c
|
||||
|
||||
p = d * 0.3
|
||||
if a < abs(c):
|
||||
a, s = c, p / 4
|
||||
else:
|
||||
s = p / (2 * math.pi) * math.asin(c / a)
|
||||
def easeOutElastic(t, b, c, d, a=1.70158):
|
||||
if t == 0:
|
||||
return b
|
||||
t /= d
|
||||
if t == 1:
|
||||
return b + c
|
||||
|
||||
return a * pow(2, -10 * t) * math.sin((t * d - s) * (2 * math.pi) / p) + c + b
|
||||
p = d * 0.3
|
||||
if a < abs(c):
|
||||
a, s = c, p / 4
|
||||
else:
|
||||
s = p / (2 * math.pi) * math.asin(c / a)
|
||||
|
||||
def easeInOutElastic(t, b, c, d, a = 1.70158):
|
||||
if t == 0:
|
||||
return b
|
||||
t /= (d / 2)
|
||||
if t == 2:
|
||||
return b + c
|
||||
return a * pow(2, -10 * t) * math.sin((t * d - s) * (2 * math.pi) / p) + c + b
|
||||
|
||||
p = d * (0.3 * 1.5)
|
||||
if a < abs(c):
|
||||
a, s = c, p / 4
|
||||
else:
|
||||
s = p / (2 * math.pi) * math.asin(c / a)
|
||||
|
||||
if t < 1:
|
||||
t -= 1
|
||||
return -0.5 * (a * pow(2, 10 * t) * math.sin((t * d - s) * (2 * math.pi) / p)) + b
|
||||
def easeInOutElastic(t, b, c, d, a=1.70158):
|
||||
if t == 0:
|
||||
return b
|
||||
t /= (d / 2)
|
||||
if t == 2:
|
||||
return b + c
|
||||
|
||||
t -= 1
|
||||
return a * pow(2, -10 * t) * math.sin((t * d - s) * (2 * math.pi) / p ) * 0.5 + c + b
|
||||
p = d * (0.3 * 1.5)
|
||||
if a < abs(c):
|
||||
a, s = c, p / 4
|
||||
else:
|
||||
s = p / (2 * math.pi) * math.asin(c / a)
|
||||
|
||||
def easeInBack(t, b, c, d, s = 1.70158):
|
||||
t /= d
|
||||
return c * t * t * ((s + 1) * t - s) + b
|
||||
if t < 1:
|
||||
t -= 1
|
||||
return -0.5 * (a * pow(2, 10 * t) * math.sin((t * d - s) * (2 * math.pi) / p)) + b
|
||||
|
||||
def easeOutBack(t, b, c, d, s = 1.70158):
|
||||
t = t / d - 1
|
||||
return c * (t * t * ((s + 1) * t + s) + 1) + b
|
||||
t -= 1
|
||||
return a * pow(2, -10 * t) * math.sin((t * d - s) * (2 * math.pi) / p) * 0.5 + c + b
|
||||
|
||||
def easeInOutBack(t, b, c, d, s = 1.70158):
|
||||
t /= d / 2
|
||||
s *= 1.525
|
||||
if t < 1:
|
||||
return c / 2 * (t * t * ((s + 1) * t - s)) + b;
|
||||
|
||||
t -= 2
|
||||
return c/2 * (t * t * ((s + 1) * t + s) + 2) + b;
|
||||
def easeInBack(t, b, c, d, s=1.70158):
|
||||
t /= d
|
||||
return c * t * t * ((s + 1) * t - s) + b
|
||||
|
||||
|
||||
def easeOutBack(t, b, c, d, s=1.70158):
|
||||
t = t / d - 1
|
||||
return c * (t * t * ((s + 1) * t + s) + 1) + b
|
||||
|
||||
|
||||
def easeInOutBack(t, b, c, d, s=1.70158):
|
||||
t /= d / 2
|
||||
s *= 1.525
|
||||
if t < 1:
|
||||
return c / 2 * (t * t * ((s + 1) * t - s)) + b
|
||||
|
||||
t -= 2
|
||||
return c/2 * (t * t * ((s + 1) * t + s) + 2) + b
|
||||
|
||||
|
||||
def easeInBounce(t, b, c, d):
|
||||
return c - easeOutBounce(d-t, 0, c, d) + b;
|
||||
return c - easeOutBounce(d-t, 0, c, d) + b
|
||||
|
||||
|
||||
def easeOutBounce(t, b, c, d):
|
||||
t /= d
|
||||
if t < (1/2.75):
|
||||
return c*(7.5625*t*t) + b;
|
||||
t /= d
|
||||
if t < (1/2.75):
|
||||
return c*(7.5625*t*t) + b
|
||||
|
||||
elif t < (2/2.75):
|
||||
t -= (1.5/2.75)
|
||||
return c*(7.5625*t*t + 0.75) + b;
|
||||
elif t < (2/2.75):
|
||||
t -= (1.5/2.75)
|
||||
return c*(7.5625*t*t + 0.75) + b
|
||||
|
||||
elif t < (2.5/2.75):
|
||||
t -= (2.25/2.75)
|
||||
return c*(7.5625*t*t + 0.9375) + b;
|
||||
elif t < (2.5/2.75):
|
||||
t -= (2.25/2.75)
|
||||
return c*(7.5625*t*t + 0.9375) + b
|
||||
|
||||
else:
|
||||
t -= (2.625/2.75)
|
||||
return c*(7.5625*t*t + 0.984375) + b
|
||||
|
||||
else:
|
||||
t -= (2.625/2.75)
|
||||
return c*(7.5625*t*t + 0.984375) + b;
|
||||
|
||||
def easeInOutBounce(t, b, c, d):
|
||||
if t < d/2:
|
||||
return easeInBounce(t*2, 0, c, d) * .5 + b;
|
||||
if t < d/2:
|
||||
return easeInBounce(t*2, 0, c, d) * .5 + b
|
||||
|
||||
return easeOutBounce(t*2-d, 0, c, d) * .5 + c*.5 + b;
|
||||
return easeOutBounce(t*2-d, 0, c, d) * .5 + c*.5 + b
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue