Exemplo n.º 1
0
        public IAnimation <T> Create()
        {
            var builder = new AnimationBuilder <T>
            {
                Loop = Loop
            };

            if (!_list.Any())
            {
                builder[0, 0] = (ref T animatable, float advance) => animatable = StartValue;
                return(builder.Create());
            }

            float currentTime  = 0;
            T     currentValue = StartValue;

            foreach (AnimationKeyPoint <T> step in _list)
            {
                T previousValue = currentValue;

                builder[currentTime, step.Time] = (ref T animatable, float advance)
                                                  => animatable = step.Easing(previousValue, step.Value, advance);

                currentTime  = step.Time;
                currentValue = step.Value;
            }

            return(builder.Create());
        }
Exemplo n.º 2
0
        public IAnimation <int> Create()
        {
            var animationBuilder = new AnimationBuilder <int>();

            float time = 0;

            for (int i = 0; i < StepsCount; i++)
            {
                int j = i;
                animationBuilder[time] = (ref int animatable, float advance) => animatable = Frames[j];
                time += Intervals[i];
            }

            animationBuilder[time] = (ref int animatable, float advance) => animatable = Frames[Frames.Length - 1];
            animationBuilder.Loop  = Loop;

            return(animationBuilder.Create());
        }