示例#1
0
        public static float GetTerpedPosition(float time, float totalTime, Function function, Direction direction)
        {
            switch (function)
            {
            case Function.Quadratic:
                switch (direction)
                {
                case Direction.In:
                    return(Quadratic.In(time / totalTime));

                case Direction.Out:
                    return(Quadratic.Out(time / totalTime));

                default:
                    return(Quadratic.InOut(time / totalTime));
                }

            case Function.Cubic:
                switch (direction)
                {
                case Direction.In:
                    return(Cubic.In(time / totalTime));

                case Direction.Out:
                    return(Cubic.Out(time / totalTime));

                default:
                    return(Cubic.InOut(time / totalTime));
                }

            case Function.Quartic:
                switch (direction)
                {
                case Direction.In:
                    return(Quartic.In(time / totalTime));

                case Direction.Out:
                    return(Quartic.Out(time / totalTime));

                default:
                    return(Quartic.InOut(time / totalTime));
                }

            case Function.Quintic:
                switch (direction)
                {
                case Direction.In:
                    return(Quintic.In(time / totalTime));

                case Direction.Out:
                    return(Quintic.Out(time / totalTime));

                default:
                    return(Quintic.InOut(time / totalTime));
                }

            case Function.Sinusoidal:
                switch (direction)
                {
                case Direction.In:
                    return(Sinusoidal.In(time / totalTime));

                case Direction.Out:
                    return(Sinusoidal.Out(time / totalTime));

                default:
                    return(Sinusoidal.InOut(time / totalTime));
                }

            case Function.Exponential:
                switch (direction)
                {
                case Direction.In:
                    return(Exponential.In(time / totalTime));

                case Direction.Out:
                    return(Exponential.Out(time / totalTime));

                default:
                    return(Exponential.InOut(time / totalTime));
                }

            case Function.Circular:
                switch (direction)
                {
                case Direction.In:
                    return(Circular.In(time / totalTime));

                case Direction.Out:
                    return(Circular.Out(time / totalTime));

                default:
                    return(Circular.InOut(time / totalTime));
                }

            case Function.Elastic:
                switch (direction)
                {
                case Direction.In:
                    return(Elastic.In(time / totalTime));

                case Direction.Out:
                    return(Elastic.Out(time / totalTime));

                default:
                    return(Elastic.InOut(time / totalTime));
                }

            case Function.Back:
                switch (direction)
                {
                case Direction.In:
                    return(Back.In(time / totalTime));

                case Direction.Out:
                    return(Back.Out(time / totalTime));

                default:
                    return(Back.InOut(time / totalTime));
                }

            default:    //Function.Bounce:
                switch (direction)
                {
                case Direction.In:
                    return(Bounce.In(time / totalTime));

                case Direction.Out:
                    return(Bounce.Out(time / totalTime));

                default:
                    return(Bounce.InOut(time / totalTime));
                }
            }
        }
示例#2
0
    //------------------------------------------------------------------------------------------------------------

    public static float GetEasingFunction(Type easingFunction, float t)
    {
        // Quad
        if (easingFunction == Type.EaseInQuad)
        {
            return(Quadratic.In(t));
        }

        if (easingFunction == Type.EaseOutQuad)
        {
            return(Quadratic.Out(t));
        }

        if (easingFunction == Type.EaseInOutQuad)
        {
            return(Quadratic.InOut(t));
        }

        // Cubic
        if (easingFunction == Type.EaseInCubic)
        {
            return(Cubic.In(t));
        }

        if (easingFunction == Type.EaseOutCubic)
        {
            return(Cubic.Out(t));
        }

        if (easingFunction == Type.EaseInOutCubic)
        {
            return(Cubic.InOut(t));
        }

        // Quart
        if (easingFunction == Type.EaseInQuart)
        {
            return(Quartic.In(t));
        }

        if (easingFunction == Type.EaseOutQuart)
        {
            return(Quartic.Out(t));;
        }

        if (easingFunction == Type.EaseInOutQuart)
        {
            return(Quartic.InOut(t));;
        }

        // Quint
        if (easingFunction == Type.EaseInQuint)
        {
            return(Quintic.In(t));
        }

        if (easingFunction == Type.EaseOutQuint)
        {
            return(Quintic.Out(t));
        }

        if (easingFunction == Type.EaseInOutQuint)
        {
            return(Quintic.InOut(t));
        }

        // Sine
        if (easingFunction == Type.EaseInSine)
        {
            return(Sinusoidal.In(t));
        }

        if (easingFunction == Type.EaseOutSine)
        {
            return(Sinusoidal.Out(t));
        }

        if (easingFunction == Type.EaseInOutSine)
        {
            return(Sinusoidal.InOut(t));
        }

        // Expo
        if (easingFunction == Type.EaseInExpo)
        {
            return(Exponential.In(t));
        }

        if (easingFunction == Type.EaseOutExpo)
        {
            return(Exponential.Out(t));
        }

        if (easingFunction == Type.EaseInOutExpo)
        {
            return(Exponential.InOut(t));
        }

        // CirC
        if (easingFunction == Type.EaseInCirc)
        {
            return(Circular.In(t));
        }

        if (easingFunction == Type.EaseOutCirc)
        {
            return(Circular.Out(t));
        }

        if (easingFunction == Type.EaseInOutCirc)
        {
            return(Circular.InOut(t));
        }

        // Linear
        if (easingFunction == Type.Linear)
        {
            return(Linear(t));
        }

        //  Bounce
        if (easingFunction == Type.EaseInBounce)
        {
            return(Bounce.In(t));
        }

        if (easingFunction == Type.EaseOutBounce)
        {
            return(Bounce.Out(t));
        }

        if (easingFunction == Type.EaseInOutBounce)
        {
            return(Bounce.InOut(t));
        }

        // Back
        if (easingFunction == Type.EaseInBack)
        {
            return(Back.In(t));
        }

        if (easingFunction == Type.EaseOutBack)
        {
            return(Back.Out(t));
        }

        if (easingFunction == Type.EaseInOutBack)
        {
            return(Back.InOut(t));
        }

        // Elastic
        if (easingFunction == Type.EaseInElastic)
        {
            return(Elastic.In(t));
        }

        if (easingFunction == Type.EaseOutElastic)
        {
            return(Elastic.Out(t));
        }

        if (easingFunction == Type.EaseInOutElastic)
        {
            return(Elastic.InOut(t));
        }

        return(0);
    }
示例#3
0
        public static float Ease(EasingType easingFunction, float k)
        {
            switch (easingFunction)
            {
            case EasingType.Linear:
                return(Linear(k));

            case EasingType.QuadraticIn:
                return(Quadratic.In(k));

            case EasingType.QuadraticOut:
                return(Quadratic.Out(k));

            case EasingType.QuadraticInOut:
                return(Quadratic.InOut(k));

            case EasingType.CubicIn:
                return(Cubic.In(k));

            case EasingType.CubicOut:
                return(Cubic.Out(k));

            case EasingType.CubicInOut:
                return(Cubic.InOut(k));

            case EasingType.QuarticIn:
                return(Quartic.In(k));

            case EasingType.QuarticOut:
                return(Quartic.Out(k));

            case EasingType.QuarticInOut:
                return(Quartic.InOut(k));

            case EasingType.QuinticIn:
                return(Quintic.In(k));

            case EasingType.QuinticOut:
                return(Quintic.Out(k));

            case EasingType.QuinticInOut:
                return(Quintic.InOut(k));

            case EasingType.SinusoidalIn:
                return(Sinusoidal.In(k));

            case EasingType.SinusoidalOut:
                return(Sinusoidal.Out(k));

            case EasingType.SinusoidalInOut:
                return(Sinusoidal.InOut(k));

            case EasingType.ExponentialIn:
                return(Exponential.In(k));

            case EasingType.ExponentialOut:
                return(Exponential.Out(k));

            case EasingType.ExponentialInOut:
                return(Exponential.InOut(k));

            case EasingType.CircularIn:
                return(Circular.In(k));

            case EasingType.CircularOut:
                return(Circular.Out(k));

            case EasingType.CircularInOut:
                return(Circular.InOut(k));

            case EasingType.ElasticIn:
                return(Elastic.In(k));

            case EasingType.ElasticOut:
                return(Elastic.Out(k));

            case EasingType.ElasticInOut:
                return(Elastic.InOut(k));

            case EasingType.BackIn:
                return(Back.In(k));

            case EasingType.BackOut:
                return(Back.Out(k));

            case EasingType.BackInOut:
                return(Back.InOut(k));

            case EasingType.BounceIn:
                return(Bounce.In(k));

            case EasingType.BounceOut:
                return(Bounce.Out(k));

            case EasingType.BounceInOut:
                return(Bounce.InOut(k));

            default:
                return(Linear(k));
            }
        }