-- a: amplitud
-- p: period

local function outInElastic(t,a,p, b, c, d)
  b,c,d = default(b,c,d)
   b,c,d = default(b,c,d)
  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, s,b, c, d)
  b,c,d = default(b,c,d)

  
	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)
  b,c,d = default(b,c,d)

  
	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,s, b, c, d)
  b,c,d = default(b,c,d)

  
	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,s, b, c, d)
  b,c,d = default(b,c,d)

  
	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)
  b,c,d = default(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)

    b,c,d = default(b,c,d)

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

local function inOutBounce(t, b, c, d)
  b,c,d = default(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)
	
  b,c,d = default(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

module = {
  Linear = linear,
  InQuad = inQuad,
  OutQuad = outQuad,
  InOutQuad = inOutQuad,
  OutInQuad = outInQuad,
  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,
}
return module
