using System;
using System.Collections.Generic;
using System.Text;
using Vortex.Drawing;

namespace Vortex.SceneFramework.Effects {

	/// <summary>
	/// Implements flexible sliding domain switching effect
	/// </summary>
	public class SlideSceneSwitchEffect : BaseSceneSwitchEffect {
		private Vector2 _direction;

		/// <summary>
		/// Initializes a new instance of the <see cref="SlideSceneSwitchEffect"/> class.
		/// </summary>
		/// <param name="direction">The direction of sliding.</param>
		public SlideSceneSwitchEffect(Vector2 direction) {
			_direction = direction;
		}

		/// <summary>
		/// Draws the domain switching effect on the specified canvas.
		/// </summary>
		/// <param name="canvas">The canvas to use for effect drawing.</param>
		public override void Draw(Vortex.Drawing.Canvas2D canvas) {
			float progress = Context.Progress * Context.Progress;
			//drawing old domain
			canvas.DrawSprite(canvas.Region + canvas.Size * _direction * progress, Context.OldSceneSprite, ColorU.Blank);
			//drawing new domain
			canvas.DrawSprite(canvas.Region - canvas.Size * _direction * (1 - progress), Context.NewSceneSprite, ColorU.Blank);
		}
	}
}
