public static double ElasticEaseInOut(double t, double b, double c, double d) { if ((t /= d / 2) == 2) { return b + c; } var p = d * (.3 * 1.5); var s = p / 4; if (t < 1) { return -.5 * (c * Math.Pow(2, 10 * (t -= 1)) * Math.Sin((t * d - s) * (2 * Math.PI) / p)) + b; } return c * Math.Pow(2, -10 * (t -= 1)) * Math.Sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b; }