using System;
using System.Drawing;

namespace nft.framework.drawing
{
	/// <summary>
	/// IDrawable はISurfaceに描画可能なオブジェクト
	/// </summary>
	public interface IDrawable : IDisposable
	{
		/*
        /// <summary>
		/// サーフェスに描画
		/// </summary>
		/// <param name="dest">描画先のサーフェス</param>
		/// <param name="location">描画先の位置（左上）</param>
		/// <param name="frame">フレーム番号（アニメーション用）</param>
		void Draw(ISurface dest, Point location, Scaler scale, int frame );
        void DrawEx(ISurface dest, Point location, Scaler scale, IPixelFilter filter, int frame);
        void DrawEx(ISurface dest, Point location, Scaler scale, ISurfaceDrawer drawer, int frame);
        */
        void Draw(DrawParams param);
        void DrawEx(DrawParams param, IPixelFilter filter);
        void DrawEx(DrawParams param, ISurfaceDrawer drawer);
	}

    public enum ClipUsage : int { Ignore = 0, Source, Destination }

    public class DrawParams {        
        /// <summary>
        /// 描画先のサーフェス
        /// </summary>
        public ISurfaceOld Destination;
        /// <summary>
        /// 描画先の位置（左上）
        /// </summary>
        public Point Location;
        /// <summary>
        /// クリッピング矩形領域
        /// </summary>
        public Rectangle SoruceClip = Rectangle.Empty;
        /// <summary>
        /// クリッピング矩形領域
        /// </summary>
        public Rectangle DestinationClip;
        /// <summary>
        /// 描画倍率
        /// </summary>
        public Scaler Scaler;
        /// <summary>
        /// フレーム数（default=0）
        /// </summary>
        public int FrameNo = 0;

        public DrawParams(ISurfaceOld dest, Point location) {
            this.Destination = dest;
            this.DestinationClip = new Rectangle(new Point(),dest.Size);
            this.Location = location;
            this.Scaler = Scaler.Default;
        }

        public DrawParams(ISurfaceOld dest, Point location, Scaler scaler) {
            this.Destination = dest;
            this.DestinationClip = new Rectangle(new Point(), dest.Size);
            this.Location = location;
            this.Scaler = scaler;
        }

        public DrawParams(ISurfaceOld dest, Point location, Scaler scaler, int frame) {
            this.Destination = dest;
            this.DestinationClip = new Rectangle(new Point(), dest.Size);
            this.Location = location;
            this.Scaler = scaler;
            this.FrameNo = frame;
        }

        public void ClearClip() {
            DestinationClip = new Rectangle(new Point(), Destination.Size);
            SoruceClip = Rectangle.Empty;
        }

        public DrawParams Clone() {
            DrawParams dp = MemberwiseClone() as DrawParams;
            return dp;
        }
    }
}
