extract easings into file, complete the list
This commit is contained in:
parent
ac468adfaa
commit
2e82c4d1a0
2 changed files with 205 additions and 32 deletions
202
easing.py
Normal file
202
easing.py
Normal file
|
@ -0,0 +1,202 @@
|
|||
# ported from http://www.gizma.com/easing/ to https://gist.github.com/th0ma5w/9883420
|
||||
# added some from https://gist.github.com/cleure/e5ba94f94e828a3f5466
|
||||
# added some from http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js
|
||||
|
||||
import math
|
||||
|
||||
def easeLinear(t, b, c, d):
|
||||
return c*t/d + b
|
||||
|
||||
def easeInQuad(t, b, c, d):
|
||||
t /= d
|
||||
return c*t*t + b
|
||||
|
||||
|
||||
def easeOutQuad(t, b, c, d):
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
|
||||
def easeInQuart(t, b, c, d):
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
def easeInQuint(t, b, c, d):
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
def easeInSine(t, b, c, d):
|
||||
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
|
||||
|
||||
|
||||
def easeInOutSine(t, b, c, d):
|
||||
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
|
||||
|
||||
def easeOutExpo(t, b, c, d):
|
||||
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
|
||||
|
||||
def easeInCirc(t, b, c, d):
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
def easeInElastic(t, b, c, d, s = 1.70158):
|
||||
a = 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)
|
||||
|
||||
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)
|
||||
|
||||
return a * pow(2, -10 * t) * math.sin((t * d - s) * (2 * math.pi) / p) + c + b
|
||||
|
||||
def easeInOutElastic(t, b, c, d, a = 1.70158):
|
||||
if t == 0:
|
||||
return b
|
||||
t /= (d / 2)
|
||||
if t == 2:
|
||||
return b + c
|
||||
|
||||
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
|
||||
|
||||
t -= 1
|
||||
return a * pow(2, -10 * t) * math.sin((t * d - s) * (2 * math.pi) / p ) * 0.5 + c + 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;
|
||||
|
||||
def easeOutBounce(t, b, c, d):
|
||||
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.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;
|
||||
|
||||
def easeInOutBounce(t, b, c, d):
|
||||
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;
|
35
renderlib.py
35
renderlib.py
|
@ -24,43 +24,14 @@ def loadProject(projectname):
|
|||
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), projectname))
|
||||
return __import__(projectname)
|
||||
|
||||
# t: current time, b: begInnIng value, c: change In value, d: duration
|
||||
# copied from jqueryui
|
||||
def easeOutCubic(t, b, c, d):
|
||||
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;
|
||||
|
||||
def easeInQuad(t, b, c, d):
|
||||
t=float(t)/d
|
||||
return c*t*t + b;
|
||||
|
||||
def easeOutQuad(t, b, c, d):
|
||||
t=float(t)/d
|
||||
return -c *(t)*(t-2) + b;
|
||||
|
||||
def easeInOutQuad(t, b, c, d):
|
||||
t=float(t)/(d/2)
|
||||
if (t < 1):
|
||||
return c/2*t*t + b;
|
||||
t=t-1
|
||||
return -c/2 * (t*(t-2) - 1) + b;
|
||||
|
||||
def easeLinear(t, b, c, d):
|
||||
t=float(t)/d
|
||||
return t*c+b
|
||||
|
||||
def easeDelay(easer, delay, t, b, c, d):
|
||||
def easeDelay(easer, delay, t, b, c, d, *args):
|
||||
if t < delay:
|
||||
return b
|
||||
|
||||
if t - delay > d:
|
||||
return b+c
|
||||
|
||||
return easer(t - delay, b, c, d)
|
||||
return easer(t - delay, b, c, d, *args)
|
||||
|
||||
class Rendertask:
|
||||
def __init__(self, infile, sequence, parameters={}, outfile=None, workdir='.'):
|
||||
|
@ -175,7 +146,7 @@ def rendertask(task):
|
|||
print("cleanup")
|
||||
|
||||
# remove the .frames-dir with all frames in it
|
||||
shutil.rmtree(os.path.join(task.workdir, '.frames'))
|
||||
#shutil.rmtree(os.path.join(task.workdir, '.frames'))
|
||||
|
||||
# remove the generated svg
|
||||
ensureFilesRemoved(os.path.join(task.workdir, '.gen.svg'))
|
||||
|
|
Loading…
Add table
Reference in a new issue