Exemplo n.º 1
0
        /// <summary>
        /// Adds a delay animation to the pipeline.
        /// </summary>
        /// <typeparam name="TOwner">The type of the owner.</typeparam>
        /// <param name="pipeline">The animation pipeline.</param>
        /// <param name="seconds">The duration seconds.</param>
        /// <param name="callback">The callback.</param>
        /// <returns>The animation pipeline.</returns>
        public static IAnimationPipeline <TOwner> Delay <TOwner>(this IAnimationPipeline <TOwner> pipeline, float seconds, Action callback = null)
            where TOwner : IComponent
        {
            var delayAnimation = new DelayAnimation <TOwner>(pipeline.Owner, seconds, callback);

            pipeline.Add(delayAnimation);

            return(pipeline);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a callback to the pipeline.
        /// </summary>
        /// <typeparam name="TOwner">The type of the owner.</typeparam>
        /// <param name="pipeline">The animation pipeline.</param>
        /// <param name="callback">The callback.</param>
        /// <returns>The animation pipeline controller.</returns>
        public static IAnimationPipeline <TOwner> Do <TOwner>(this IAnimationPipeline <TOwner> pipeline, Action callback)
            where TOwner : IComponent
        {
            var animation = new DelayAnimation <TOwner>(pipeline.Owner, 0, callback);

            pipeline.Add(animation);

            return(pipeline);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Animates the floot value between the values defined in to and from arguments.
        /// </summary>
        /// <returns>The animation pipeline.</returns>
        /// <param name="pipeline">The animation pipeline.</param>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="easing">Easing.</param>
        /// <param name="callback">Callback.</param>
        public static IAnimationPipeline <TOwner> To <TOwner>(this IAnimationPipeline <TOwner> pipeline, float from, float to, float duration, IEasing easing, Action <float> callback)
            where TOwner : IComponent
        {
            var animation = new FloatAnimation <TOwner>(pipeline.Owner, from, to, duration, callback);

            animation.Easing = easing;
            pipeline.Add(animation);

            return(pipeline);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a rectangle iteration animation.
        /// </summary>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="rectangle">The rectangle.</param>
        /// <param name="filled">If rectangle should be filled.</param>
        /// <param name="duration">The duration seconds.</param>
        /// <param name="easing">The easing.</param>
        /// <param name="callback">The callback.</param>
        /// <returns>The animation pipeline.</returns>
        public static IAnimationPipeline <TOwner> Iterate <TOwner>(this IAnimationPipeline <TOwner> pipeline, Rectangle rectangle, bool filled, float duration, IEasing easing, Action <float, float> callback)
            where TOwner : IComponent
        {
            var animation = new RectangleIterateAnimation <TOwner>(pipeline.Owner, rectangle, filled, duration, callback)
            {
                Easing = easing
            };

            pipeline.Add(animation);

            return(pipeline);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds a rectangle iteration animation.
        /// </summary>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="duration">The duration seconds.</param>
        /// <param name="easing">The easing.</param>
        /// <param name="callback">The callback.</param>
        /// <returns>The animation pipeline.</returns>
        public static IAnimationPipeline <RectangleComponent> Iterate(this IAnimationPipeline <RectangleComponent> pipeline, float duration, IEasing easing, Action <float, float> callback)
        {
            var owner     = pipeline.Owner;
            var animation = new RectangleIterateAnimation <RectangleComponent>(owner, owner.Transform.BoundingBox, owner.Filled, duration, callback)
            {
                Easing = easing
            };

            pipeline.Add(animation);

            return(pipeline);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Scale the transfom between current scale to x and y scale using the duration and easing specified.
        /// </summary>
        /// <returns>The animation pipeline.</returns>
        /// <param name="pipeline">The transform.</param>
        /// <param name="to">The target scale.</param>
        /// <param name="duration">the duration.</param>
        /// <param name="easing">The easing.</param>
        public static IAnimationPipeline <Transform> ScaleTo(this IAnimationPipeline <Transform> pipeline, Point to, float duration, IEasing easing = null)
        {
            var owner     = pipeline.Owner;
            var animation = new PointAnimation <Transform>(owner, t => t.Scale, to, duration, (v) =>
            {
                owner.Scale = v;
            });

            animation.Easing = easing;
            pipeline.Add(animation);

            return(pipeline);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Rotate the transfom between current rotation to specified rotation using the duration and easing specified.
        /// </summary>
        /// <returns>The animation pipeline.</returns>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="rotation">The target rotation.</param>
        /// <param name="duration">the duration.</param>
        /// <param name="easing">The easing.</param>
        public static IAnimationPipeline <Transform> RotateTo(this IAnimationPipeline <Transform> pipeline, float rotation, float duration, IEasing easing = null)
        {
            var owner = pipeline.Owner;

            var animation = new FloatAnimation <Transform>(owner, owner.Rotation, rotation, duration, (v) =>
            {
                owner.Rotation = v;
            });

            animation.Easing = easing;

            pipeline.Add(animation);

            return(pipeline);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Move the transfom between the current position to point using the duration and easing specified.
        /// </summary>
        /// <returns>The animation pipeline.</returns>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="point">The point.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="easing">Easing.</param>
        public static IAnimationPipeline <Transform> MoveTo(this IAnimationPipeline <Transform> pipeline, Point point, float duration, IEasing easing = null)
        {
            pipeline.Add(CreateMoveToAnimation(pipeline.Owner, point.X, point.Y, duration, easing));

            return(pipeline);
        }