local function w(w,j,A,H,G,x)if w==0 then return j end w=(w/H)*2 if w==2 then return j+A end if not x then x=H*.45 end if not G then G=0 end if not G or G<abs(A)then G=A s=x/4 else s=(x/(2*pi))*asin(A/G)end if w<1 then w=w-1 return-0.5*((G*pow(2,10*w))*sin(((w*H-s)*(2*pi))/x))+j else w=w-1 return(((G*pow(2,-10*w))*sin(((w*H-s)*(2*pi))/x))*.5+A)+j end end

local function inOutElastic(t, b, c, d, a, p)
  if t == 0 then return b end

  t = t / d * 2

  if t == 2 then return b + c end

  if not p then p = d * (0.3 * 1.5) end
  if not a then a = 0 end

  if not a or a < abs(c) then
    a = c
    s = p / 4
  else
    s = p / (2 * pi) * asin(c / a)
  end

  if t < 1 then
    t = t - 1
    return -0.5 * (a * pow(2, 10 * t) * sin((t * d - s) * (2 * pi) / p)) + b
  else
    t = t - 1
    return a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p ) * 0.5 + c + b
  end
end
