-
Notifications
You must be signed in to change notification settings - Fork 7
/
easing.lua
40 lines (36 loc) · 1.11 KB
/
easing.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--- Linear easing (in quotes).
local linear = {
F = 0.5,
easing = function(t) return t end
}
--- Sublinear (?) easing.
local zero = {
F = 1,
easing = function() return 1 end
}
--- Quadratic easing.
local quadratic = {
F = 1/3,
easing = function(t) return t * t end
}
-- Okay look. It works. It's not terribly slow because computers can do math
-- quick. The other one decidedly does not work (thanks sagemath, I trusted
-- you...) so this will have to do. I may try to fix it up at some point, I may
-- just leave it be and laugh to myself whenever I see this. As they say, if
-- As they say, if you want something fixed that badly, make a pull request lol
local bouncy = {
F = (20*math.sqrt(3)*math.pi-30*math.log(2)-6147) /
(10*(2*math.sqrt(3)*math.pi-6147*math.log(2))),
easing = function(t) return
(4096*math.pi*math.pow(2, 10*t-10)*math.cos(20/3*math.pi*t-43/6*math.pi)
+6144*math.pow(2, 10*t-10)*math.log(2)*math.sin(20/3*math.pi*t-43/6*math.pi)
+2*math.sqrt(3)*math.pi-3*math.log(2)) /
(2*math.pi*math.sqrt(3)-6147*math.log(2))
end
}
return {
linear = linear,
zero = zero,
quadratic = quadratic,
bouncy = bouncy
}