Ejemplo n.º 1
0
        /// <summary>
        /// Given the easing functions output, find the approximate input that would generate it.
        /// </summary>
        /// <param name="easeType">The easing type</param>
        /// <param name="easeOption">The easing option</param>
        /// <param name="k">The output value to find the input for</param>
        /// <returns></returns>
        public static double CalculateInverse(EaseType easeType, EaseOption easeOption, double k, double errorTolerance = .000000001)
        {
            if (easeType == EaseType.Linear)
            {
                return(k);
            }

            return(CalculateInverse(GetEasingFunction(easeType, easeOption), k, errorTolerance));
        }
Ejemplo n.º 2
0
        public static Func <double, double> GetEasingFunction(EaseType easeType, EaseOption easeOption)
        {
            switch (easeType)
            {
            case EaseType.Quadratic:
                switch (easeOption)
                {
                case EaseOption.In:
                    return(Quadratic.In);

                case EaseOption.Out:
                    return(Quadratic.Out);

                case EaseOption.InOut:
                    return(Quadratic.InOut);
                }

                break;

            case EaseType.Cubic:
                switch (easeOption)
                {
                case EaseOption.In:
                    return(Cubic.In);

                case EaseOption.Out:
                    return(Cubic.Out);

                case EaseOption.InOut:
                    return(Cubic.InOut);
                }

                break;

            case EaseType.Quartic:
                switch (easeOption)
                {
                case EaseOption.In:
                    return(Quartic.In);

                case EaseOption.Out:
                    return(Quartic.Out);

                case EaseOption.InOut:
                    return(Quartic.InOut);
                }

                break;

            case EaseType.Quintic:
                switch (easeOption)
                {
                case EaseOption.In:
                    return(Quintic.In);

                case EaseOption.Out:
                    return(Quintic.Out);

                case EaseOption.InOut:
                    return(Quintic.InOut);
                }

                break;

            case EaseType.Sinusoidal:
                switch (easeOption)
                {
                case EaseOption.In:
                    return(Sinusoidal.In);

                case EaseOption.Out:
                    return(Sinusoidal.Out);

                case EaseOption.InOut:
                    return(Sinusoidal.InOut);
                }

                break;
            }

            return(Linear);
        }
Ejemplo n.º 3
0
 public static double Calculate(EaseType easeType, EaseOption easeOption, double k)
 {
     return(GetEasingFunction(easeType, easeOption)(k));
 }
Ejemplo n.º 4
0
        public static double Specify(EaseType easeType, EaseOption easeOption, double k)
        {
            switch (easeType)
            {
            case EaseType.Quadratic:
                switch (easeOption)
                {
                case EaseOption.In:
                    return(Quadratic.In(k));

                case EaseOption.Out:
                    return(Quadratic.Out(k));

                case EaseOption.InOut:
                    return(Quadratic.InOut(k));
                }

                break;

            case EaseType.Cubic:
                switch (easeOption)
                {
                case EaseOption.In:
                    return(Cubic.In(k));

                case EaseOption.Out:
                    return(Cubic.Out(k));

                case EaseOption.InOut:
                    return(Cubic.InOut(k));
                }

                break;

            case EaseType.Quartic:
                switch (easeOption)
                {
                case EaseOption.In:
                    return(Quartic.In(k));

                case EaseOption.Out:
                    return(Quartic.Out(k));

                case EaseOption.InOut:
                    return(Quartic.InOut(k));
                }

                break;

            case EaseType.Quintic:
                switch (easeOption)
                {
                case EaseOption.In:
                    return(Quintic.In(k));

                case EaseOption.Out:
                    return(Quintic.Out(k));

                case EaseOption.InOut:
                    return(Quintic.InOut(k));
                }

                break;

            case EaseType.Sinusoidal:
                switch (easeOption)
                {
                case EaseOption.In:
                    return(Sinusoidal.In(k));

                case EaseOption.Out:
                    return(Sinusoidal.Out(k));

                case EaseOption.InOut:
                    return(Sinusoidal.InOut(k));
                }

                break;
            }

            return(Linear(k));
        }