CSharp examples for System:Math Easing Function
Easing equation function for a sinusoidal (sin(t)) easing inout: acceleration until halfway, then deceleration.
using System;/*from w ww . j a v a 2 s . co m*/ public class Main{ /// <summary> /// Easing equation function for a sinusoidal (sin(t)) easing in/out: /// acceleration until halfway, then deceleration. /// </summary> /// <param name="t">Current time in seconds.</param> /// <param name="b">Starting value.</param> /// <param name="c">Change in value.</param> /// <param name="d">Duration of animation.</param> /// <returns>The correct value.</returns> public static double SineEaseInOut( double t, double b, double c, double d ) { if ( ( t /= d / 2 ) < 1 ) return c / 2 * ( Math.Sin( Math.PI * t / 2 ) ) + b; return -c / 2 * ( Math.Cos( Math.PI * --t / 2 ) - 2 ) + b; } }