local function U(U,c,I,G,j,Q)if U<G/2 then return outElastic(U*2,c,I/2,G,j,Q)else return inElastic(U*2-G,c+I/2,I/2,G,j,Q)end end local function c(U,c,I,G,j)if not j then j=1.70158 end U=U/G return((I*U)*U)*((j+1)*U-j)+c end local function I(U,c,I,G,j)if not j then j=1.70158 end U=U/G-1 return I*((U*U)*((j+1)*U+j)+1)+c end local function G(U,c,I,G,j)if not j then j=1.70158 end j=j*1.525 U=(U/G)*2 if U<1 then return(I/2)*((U*U)*((j+1)*U-j))+c else U=U-2 return(I/2)*((U*U)*((j+1)*U+j)+2)+c end end local function j(U,G,j,Q,N)if U<Q/2 then return I(U*2,G,j/2,Q,N)else return c(U*2-Q,G+j/2,j/2,Q,N)end end local function Q(U,c,I,G)U=U/G if U<.36363636363636 then return I*((7.5625*U)*U)+c elseif U<.72727272727273 then U=U-.54545454545455 return I*((7.5625*U)*U+.75)+c elseif U<.90909090909091 then U=U-.81818181818182 return I*((7.5625*U)*U+.9375)+c else U=U-.95454545454545 return I*((7.5625*U)*U+.984375)+c end end local function N(U,c,I,G)return(I-Q(G-U,0,I,G))+c end local function L(U,c,I,G)if U<G/2 then return N(U*2,0,I,G)*.5+c else return(Q(U*2-G,0,I,G)*.5+I*.5)+c end end local function e(U,c,I,G)if U<G/2 then return Q(U*2,c,I/2,G)else return N(U*2-G,c+I/2,I/2,G)end end return{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=U;inBack=c;outBack=I;inOutBack=G,outInBack=j;inBounce=N,outBounce=Q;inOutBounce=L;outInBounce=e}

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,
	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,
}
