Files
Roblox-Elevator-Game/src/shared/AlgebraEasings.lua

30 lines
645 B
Lua

--My versions
type EaseFunction = (n: number) -> number
export type EasingStyles = {
Linear: EaseFunction,
InOutBack: EaseFunction,
OutBounce: EaseFunction
}
local Ease: EasingStyles = {}
--Google straight up gives wrong/bad math
function Ease.Linear(a,b,t)
return a-a*t+b*t
end
local c = 2.59491
function Ease.InOutBack(n)
return n<.5 and 2*n*n*(-c+2*n+2*c*n) or 3*(-1+n)*(-1+n)*(-2-c+2*n+2*c*n)
end
local n1, d1 = 7.5625, 2.75
function Ease.OutBounce(n)
return (n<0.363636 and n*n*n1 or
n<0.727273 and (.75*(1.*d1-2.*n*n1)) or
n<0.909091 and (.9375*(1.*d1-2.4*n*n1)/d1)) or (.984375*(1.*d1-2.66667*n*n1))/d1
end
return Ease