Search code examples
c#c++animationeasing

Ease-in and ease-out animation formula


Say, if I'm doing the Ease-Out and then Ease-In animation of an object's movement from X1 coordinate to X2 coordinate over S steps at equal time intervals. Can some suggest the formula to calculate this movement's X coordinates?


Solution

  • Quadratic ease out where:

    t = current time
    b = start value
    c = change in value
    d = duration

     function (float time, float startValue, float change, float duration) {
         time /= duration / 2;
         if (time < 1)  {
              return change / 2 * time * time + startValue;
         }
    
         time--;
         return -change / 2 * (time * (time - 2) - 1) + startValue;
     };
    

    source: http://gizma.com/easing/