local function z(z,y,H,d,m,X)if z<d/2 then return outElastic(z*2,y,H/2,d,m,X)else return inElastic(z*2-d,y+H/2,H/2,d,m,X)end end local function y(z,y,H,d,m)if not m then m=1.70158 end z=z/d return((H*z)*z)*((m+1)*z-m)+y end local function H(z,y,H,d,m)if not m then m=1.70158 end z=z/d-1 return H*((z*z)*((m+1)*z+m)+1)+y end local function d(z,y,H,d,m)if not m then m=1.70158 end m=m*1.525 z=(z/d)*2 if z<1 then return(H/2)*((z*z)*((m+1)*z-m))+y else z=z-2 return(H/2)*((z*z)*((m+1)*z+m)+2)+y end end local function m(z,d,m,X,b)if z<X/2 then return H(z*2,d,m/2,X,b)else return y(z*2-X,d+m/2,m/2,X,b)end end local function X(z,y,H,d)z=z/d if z<.36363636363636 then return H*((7.5625*z)*z)+y elseif z<.72727272727273 then z=z-.54545454545455 return H*((7.5625*z)*z+.75)+y elseif z<.90909090909091 then z=z-.81818181818182 return H*((7.5625*z)*z+.9375)+y else z=z-.95454545454545 return H*((7.5625*z)*z+.984375)+y end end local function b(z,y,H,d)return(H-X(d-z,0,H,d))+y end local function q(z,y,H,d)if z<d/2 then return b(z*2,0,H,d)*.5+y else return(X(z*2-d,0,H,d)*.5+H*.5)+y end end local function i(z,y,H,d)if z<d/2 then return X(z*2,y,H/2,d)else return b(z*2-d,y+H/2,H/2,d)end end return{linear=linear;inQuad=inQuad,outQuad=outQuad,inOutQuad=inOutQuad,inCubic=inCubic;outCubic=outCubic;inOutCubic=inOutCubic,outInCubic=outInCubic;inQuart=inQuart;outQuart=outQuart;inOutQuart=inOutQuart;outInQuart=outInQuart,inQuint=inQuint,outQuint=outQuint,inOutQuint=inOutQuint,outInQuint=outInQuint,inSine=inSine;outSine=outSine;inOutSine=inOutSine,outInSine=outInSine;inExpo=inExpo,outExpo=outExpo;inOutExpo=inOutExpo;outInExpo=outInExpo;inCirc=inCirc;outCirc=outCirc,inOutCirc=inOutCirc,outInCirc=outInCirc;inElastic=inElastic;outElastic=outElastic;inOutElastic=inOutElastic,outInElastic=z,inBack=y;outBack=H,inOutBack=d;outInBack=m,inBounce=b;outBounce=X;inOutBounce=q,outInBounce=i}

local function outInElastic(t, b, c, d, a, p)
  if t < d / 2 then
    return outElastic(t * 2, b, c / 2, d, a, p)
  else
    return inElastic((t * 2) - d, b + c / 2, c / 2, d, a, p)
  end
end

local function inBack(t, b, c, d, s)
  if not s then s = 1.70158 end
  t = t / d
  return c * t * t * ((s + 1) * t - s) + b
end

local function outBack(t, b, c, d, s)
  if not s then s = 1.70158 end
  t = t / d - 1
  return c * (t * t * ((s + 1) * t + s) + 1) + b
end

local function inOutBack(t, b, c, d, s)
  if not s then s = 1.70158 end
  s = s * 1.525
  t = t / d * 2
  if t < 1 then
    return c / 2 * (t * t * ((s + 1) * t - s)) + b
  else
    t = t - 2
    return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b
  end
end

local function outInBack(t, b, c, d, s)
  if t < d / 2 then
    return outBack(t * 2, b, c / 2, d, s)
  else
    return inBack((t * 2) - d, b + c / 2, c / 2, d, s)
  end
end

local function outBounce(t, b, c, d)
  t = t / d
  if t < 1 / 2.75 then
    return c * (7.5625 * t * t) + b
  elseif t < 2 / 2.75 then
    t = t - (1.5 / 2.75)
    return c * (7.5625 * t * t + 0.75) + b
  elseif t < 2.5 / 2.75 then
    t = t - (2.25 / 2.75)
    return c * (7.5625 * t * t + 0.9375) + b
  else
    t = t - (2.625 / 2.75)
    return c * (7.5625 * t * t + 0.984375) + b
  end
end

local function inBounce(t, b, c, d)
  return c - outBounce(d - t, 0, c, d) + b
end

local function inOutBounce(t, b, c, d)
  if t < d / 2 then
    return inBounce(t * 2, 0, c, d) * 0.5 + b
  else
    return outBounce(t * 2 - d, 0, c, d) * 0.5 + c * .5 + b
  end
end

local function outInBounce(t, b, c, d)
  if t < d / 2 then
    return outBounce(t * 2, b, c / 2, d)
  else
    return inBounce((t * 2) - d, b + c / 2, c / 2, d)
  end
end

return {
  linear = linear,
  inQuad = inQuad,
  outQuad = outQuad,
  inOutQuad = inOutQuad,
  inCubic  = inCubic ,
  outCubic = outCubic,
  inOutCubic = inOutCubic,
  outInCubic = outInCubic,
  inQuart = inQuart,
  outQuart = outQuart,
  inOutQuart = inOutQuart,
  outInQuart = outInQuart,
  inQuint = inQuint,
  outQuint = outQuint,
  inOutQuint = inOutQuint,
  outInQuint = outInQuint,
  inSine = inSine,
  outSine = outSine,
  inOutSine = inOutSine,
  outInSine = outInSine,
  inExpo = inExpo,
  outExpo = outExpo,
  inOutExpo = inOutExpo,
  outInExpo = outInExpo,
  inCirc = inCirc,
  outCirc = outCirc,
  inOutCirc = inOutCirc,
  outInCirc = outInCirc,
  inElastic = inElastic,
  outElastic = outElastic,
  inOutElastic = inOutElastic,
  outInElastic = outInElastic,
  inBack = inBack,
  outBack = outBack,
  inOutBack = inOutBack,
  outInBack = outInBack,
  inBounce = inBounce,
  outBounce = outBounce,
  inOutBounce = inOutBounce,
  outInBounce = outInBounce,
}
