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

namespace Vortex.SceneFramework.Effects {

	/// <summary>
	/// Implements simpe fade switch effect
	/// </summary>
	public class FadeSceneSwitchEffect : BaseSceneSwitchEffect {

		/// <summary>
		/// Draws the domain fade effect on the specified canvas.
		/// </summary>
		/// <param name="canvas">The canvas to use for effect drawing.</param>
		public override void Draw(Canvas2D canvas) {
			float progress = Context.Progress;
			if (progress < 0.5f) {
				progress = (0.5f - progress) * 2;
				//draw fadeout
				canvas.DrawSprite(
					canvas.Region,
					Context.OldSceneSprite,
					new ColorU(ColorU.Blank * progress, 255)
				);
			} else {
				progress = (progress - 0.5f) * 2;
				//draw fade in
				canvas.DrawSprite(
					canvas.Region,
					Context.NewSceneSprite,
					new ColorU(ColorU.Blank * progress, 255)
				);
			}
		}
	}
}
