Example #1
0
        public virtual IInterpolable CreateInterpolator()
        {
            this.isDirty = false;

            switch (this.algorithm)
            {
            case AlgorithmType.Linear:
                return(Linear.Instance);

            case AlgorithmType.Acceleration:
                return(new Acceleration(this.floatValues[0]));

            case AlgorithmType.Bezier3:
                return(new Bezier3(this.floatValues[0]));

            case AlgorithmType.Bezier4:
                return(new Bezier4(this.floatValues[0], this.floatValues[1]));

            case AlgorithmType.Spline:
                return(new Spline(Interpolator.ToSplintPoint(this.floatValues)));

            case AlgorithmType.Ease:
                return(new Ease((Ease.Equations) this.intValue));

            case AlgorithmType.Constant:
                return(Constant.Instance);
            }

            return(null);
        }
Example #2
0
        public static Interpolator Create(AlgorithmType algorithm, float[] floatValues, int intValue)
        {
            Interpolator.Verify(algorithm, floatValues, intValue);

            var interpolator = new Interpolator();

            interpolator.algorithm   = algorithm;
            interpolator.floatValues = floatValues;
            interpolator.intValue    = intValue;
            interpolator.Apply();
            return(interpolator);
        }
Example #3
0
        public virtual bool UpdateInterpolator(IInterpolable internalInterpolator)
        {
            this.isDirty = false;

            switch (this.algorithm)
            {
            case AlgorithmType.Linear:
            case AlgorithmType.Constant:
                return(true);

            case AlgorithmType.Acceleration:
            {
                var inst = (Acceleration)internalInterpolator;
                inst.Factor = this.floatValues[0];
                return(true);
            }

            case AlgorithmType.Bezier3:
            {
                var inst = (Bezier3)internalInterpolator;
                inst.P1 = this.floatValues[0];
                return(true);
            }

            case AlgorithmType.Bezier4:
            {
                var inst = (Bezier4)internalInterpolator;
                inst.P1 = this.floatValues[0];
                inst.P2 = this.floatValues[1];
                return(true);
            }

            case AlgorithmType.Spline:
            {
                var inst = (Spline)internalInterpolator;
                inst.Update(Interpolator.ToSplintPoint(this.floatValues));
                return(true);
            }

            case AlgorithmType.Ease:
            {
                var inst = (Ease)internalInterpolator;
                inst.Equation = (Ease.Equations) this.IntValue;
                return(true);
            }
            }

            return(false);
        }
Example #4
0
        public void Change(AlgorithmType algorithm, float[] floatValues, int intValue)
        {
            Interpolator.Verify(algorithm, floatValues, intValue);

            if (this.algorithm != algorithm)
            {
                this.Invalidate();
                this.algorithm = algorithm;
            }
            else
            {
                this.isDirty = true;
            }

            this.floatValues = floatValues;
            this.intValue    = intValue;
            this.Apply();
        }