-- Funcions de suavitzat — entrada t in [0, 1], sortida ~[0, 1]. -- Algunes (back/bounce) poden sortir de [0,1] temporalment. -- -- Referencia: https://easings.net (versions clausurades algebraicament) local M = {} function M.linear(t) return t end function M.inQuad(t) return t * t end function M.outQuad(t) local u = 1 - t return 1 - u * u end function M.inOutQuad(t) if t < 0.5 then return 2 * t * t else local u = 2 * (1 - t) return 1 - 0.5 * u * u end end function M.inCubic(t) return t * t * t end function M.outCubic(t) local u = 1 - t return 1 - u * u * u end -- Botet: cau, rebota, cau, rebota mes petit, ... fins quedar-se. function M.outBounce(t) local n = 7.5625 local d = 2.75 if t < 1/d then return n * t * t elseif t < 2/d then local u = t - 1.5/d return n * u * u + 0.75 elseif t < 2.5/d then local u = t - 2.25/d return n * u * u + 0.9375 else local u = t - 2.625/d return n * u * u + 0.984375 end end -- Overshoot (es passa del valor i torna). function M.outBack(t) local c1 = 1.70158 local c3 = c1 + 1 local u = t - 1 return 1 + c3 * u * u * u + c1 * u * u end function M.inBack(t) local c1 = 1.70158 local c3 = c1 + 1 return c3 * t * t * t - c1 * t * t end return M