fork/m-overlay

git clone https://git.julia.blue/fork/m-overlay

BkacjiosAdded fancy dolphin animation when waiting to hook0b5708d

v2.1.1b
2.0 KiB88 linesraw
1local ease = {}
2
3local abs = math.abs
4local cos = math.cos
5local exp = math.exp
6local sqtr = math.sqrt
7local PI = math.pi
8
9function ease.cerp(a,b,t)
10	local f=(1-cos(t*PI))*.5
11	return a*(1-f)+b*f
12end
13
14function ease.lerp(from, to, t)
15	return t < 0.5 and from + (to-from)*t or to + (from-to)*(1-t)
16end
17
18local lerp = ease.lerp
19
20function ease.elastic(t, times)
21 	return (1 - (exp(-12*t) + exp(-6*t) * cos(((times or 6) + 0.5) * PI * t))/2)/0.99999692789382332858
22end
23
24function ease.outback(t, param)
25	t = 1-t
26	return 1-t*t*(t+(t-1)*(param or 1.701540198866824))
27end
28
29function ease.inback(t, param)
30	return 1-(1-t)^2*(1+t*(param or 3.48050701420725))
31end
32
33function ease.calcOutbackParam(h)
34	local P = (91.125 * h + 410.0625 * h ^ 2 + 307.546875 * h ^ 3 + 0.5 * sqrt(33215.0625 * h ^ 2 * (h + 1))) ^ (1/3)
35	return 2.25 * h + (13.5 * h + 15.1875 * h ^ 2) / P + P / 3
36end
37
38-- Slope at centre: 1.5
39function ease.sigmoid(t)
40	return t*t*(3-t*2)
41end
42
43local sigmoid = ease.sigmoid
44
45-- Slope at centre: 1.5708
46function ease.sigmoidSinusoidal(t)
47  return (1-cos(t*math.pi))/2
48end
49
50-- Slope at centre: 2
51function ease.sigmoidExp(t)
52	local partial = exp((-1)/t)
53	return partial/(exp((-1)/(1 - t)) + partial)
54end
55
56function ease.sigmoidParam(t, param)
57	param = param or 6
58	return lerp(t^param, (1-(1-t)^param), t)
59end
60
61function ease.sigmoidFast(t)
62	-- Slope at the middle: 1.875
63	return t^3*(10+t*(-15+t*6))
64end
65
66-- Slope at the middle: 2.1875
67function ease.sigmoidFaster(t)
68	return t^4*(35+t*(-84+t*(70+t*-20)))
69end
70
71-- Slope at the middle: m=3.142
72function ease.sigmoidFastest(t)
73	return t^8*(6435+t*(-40040+t*(108108+t*(-163800+t*(150150+t*(-83160+t*(25740+t*-3432)))))))
74end
75
76-- Slope at centre: 2.25 (=1.5^2)
77function ease.sigmoidDouble(t)
78  return sigmoid(sigmoid(t))
79end
80
81function ease.bounce(t)
82  -- Adjust the window to grab a better range. Plenty of magic numbers here,
83  -- sorry. These were obtained by doing the math for the adjustment.
84  t = (1-t*0.999999999)*0.5271666475893665
85  return 1-abs(cos(PI/t))*t^2*3.79559296602621
86end
87
88return ease