Easing equation function for a t^4 easing inout: acceleration until halfway, then deceleration. - CSharp System

CSharp examples for System:Math Easing Function

Description

Easing equation function for a t^4 easing inout: acceleration until halfway, then deceleration.

Demo Code


using System;/* w w  w  . ja v a 2s. c  o m*/

public class Main{
        /// <summary>
   /// Easing equation function for a quartic (t^4) 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 QuartEaseInOut( double t, double b, double c, double d )
   {
      if ( ( t /= d / 2 ) < 1 )
         return c / 2 * t * t * t * t + b;
      
      return -c / 2 * ( ( t -= 2 ) * t * t * t - 2 ) + b;
   }
}

Related Tutorials