Ease Bounce in. - CSharp System

CSharp examples for System:Math Easing Function

Description

Ease Bounce in.

Demo Code


using System;/*from  w  w w.ja  v  a  2  s. c  om*/

public class Main{
        const float PI = 3.14159f;
        const float PI2 = PI / 2;
        const float B1 = 1 / 2.75f;
        const float B2 = 2 / 2.75f;
        const float B3 = 1.5f / 2.75f;
        const float B4 = 2.5f / 2.75f;
        const float B5 = 2.25f / 2.75f;
        const float B6 = 2.625f / 2.75f;
        /// <summary>
        /// Bounce in.
        /// </summary>
        /// <param name="t">Time elapsed.</param>
        /// <returns>Eased timescale.</returns>
        public static float BounceIn(float t) {
            t = 1 - t;
            if (t < B1) return (float)(1 - 7.5625 * t * t);
            if (t < B2) return (float)(1 - (7.5625 * (t - B3) * (t - B3) + .75));
            if (t < B4) return (float)(1 - (7.5625 * (t - B5) * (t - B5) + .9375));
            return (float)(1 - (7.5625 * (t - B6) * (t - B6) + .984375));
        }
}

Related Tutorials