예제 #1
0
 ///	<summary>画像の描画(2D)</summary>
 /// <remarks>
 ///	bltの転送元矩形と転送先4点の指定できるバージョン。
 ///	srcRectがnullのときはソース全域。
 ///	転送元矩形が、転送先として指定された4点に移動。
 ///
 ///	転送先は、
 ///	point[0]が左上、point[1]が右上、point[2]が右下、point[3]が左下
 ///	の点を指定しているものとする。
 /// </remarks>
 /// <example>
 /// <code>
 ///	Screen screen = new Screen;
 ///	screen.setVideoMode(640,480,0);
 ///	GlTexture tex = new GlTexture;
 ///	tex.load("title.png");
 ///
 ///	while (GameFrame.pollEvent()==0){
 ///
 ///		screen.clear();
 ///
 ///		Point[4] points;
 ///		points[0].setPoint(100,100);
 ///		points[1].setPoint(400,100);
 ///		points[2].setPoint(640,480);
 ///		points[3].setPoint(0,480);
 ///		screen.blt(tex2,0,0,null,points);	//	台形描画
 ///
 ///		screen.Update();
 ///	}
 ///	</code>
 ///	</example>
 public void Blt(ITexture src, Rect srcRect, Point[] point)
 {
     if (src != null)
     {
         src.Blt(DrawContext, srcRect, point);
     }
 }
예제 #2
0
 /// <summary>
 /// 凸四角形→凸四角形への転送。
 /// </summary>
 /// <param name="src"></param>
 /// <param name="srcPoint"></param>
 /// <param name="dstPoint"></param>
 public void Blt(ITexture src, Point[] srcPoint, Point[] dstPoint)
 {
     if (src != null)
     {
         src.Blt(DrawContext, srcPoint, dstPoint);
     }
 }
예제 #3
0
 ///	<summary>画像の描画(2D)。</summary>
 /// <remarks>
 ///	テクスチャーを(x,y)に等倍で描画する。
 ///	テクスチャーの色には、直前のsetColorの値が乗算される。
 ///
 ///	色の変更 → setColor(r,g,b)/setColor(a)/resetColor()
 ///	ブレンド方法変更 → blendなんちゃら関数
 ///
 ///	※ テクスチャーを描画するとき、
 ///	glBindTextureを内部的に呼び出すので、これを設定している人は注意。
 /// 描画を転送先でclipしたいときは、 getDrawContext で
 /// 描画コンテクストを書き換えればok。
 /// </remarks>
 public void Blt(ITexture src, int x, int y)
 {
     if (src != null)
     {
         src.Blt(DrawContext, x, y);
     }
 }
예제 #4
0
 ///	<summary>画像の描画(2D)。</summary>
 /// <remarks>
 ///	bltの転送元矩形と転送先サイズの指定できるバージョン。
 ///	srcRectがnullのときはソース全域。
 ///	dstSizeがnullのときは転送先全域(のサイズ)。
 ///
 ///	転送元矩形として、(Right,Top,Left,Bottom)を指定すれば
 ///	左右反転して表示される。(Left,Bottom,Right,Top)を指定すれば
 ///	上下反転して表示される。
 /// </remarks>
 public void Blt(ITexture src, int x, int y, Rect srcRect, Size dstSize)
 {
     if (src != null)
     {
         src.Blt(DrawContext, x, y, srcRect, dstSize);
     }
 }
예제 #5
0
        /// <summary>
        /// bltの回転機能つき。
        /// </summary>
        /// <param name="src"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="srcRect"></param>
        /// <param name="rad"></param>
        /// <param name="rate"></param>
        /// <param name="bx"></param>
        /// <param name="by"></param>
        /// <remarks>
        /// <para>
        /// 指定のテクスチャを転送先の(x,y)に半径rで描画します。
        /// </para>
        /// <para>
        /// radの単位は、0~512で一周(2π)となる角度。
        ///     回転の方向は、右まわり(時計まわり)。
        /// rateは、拡大率。1.0ならば等倍。
        /// (bx,by)は転送元の画像の、回転中心。
        /// srcRectは転送元矩形。nullならば転送元テクスチャ全体。
        /// </para>
        /// </remarks>
        public void BltRotate(ITexture src, int x, int y, Rect srcRect, int rad, float rate, int bx, int by)
        {
            if (src == null)
            {
                return;
            }

            int sx, sy;                 //	転送元サイズ

            if (srcRect == null)
            {
                srcRect = new Rect(0, 0, src.Width, src.Height);
            }

            {
                sx = (int)(srcRect.Right - srcRect.Left);
                sy = (int)(srcRect.Bottom - srcRect.Top);
            }

            if (sx == 0 || sy == 0)
            {
                return;
            }

            int dx, dy;                 //	転送先サイズ

            dx = (int)(sx * rate);
            dy = (int)(sy * rate);
            if (dx == 0 || dy == 0)
            {
                return;
            }

            // 転送元の回転中心
            bx = (int)(bx * rate);
            by = (int)(by * rate);

            //	転送後の座標を計算する
            int nSin = SinTable.Instance.Sin(rad);
            int nCos = SinTable.Instance.Cos(rad);

            Point[] dstPoints = new Point[4];

            //	0.5での丸めのための修正項 → 0x8000
            int px = x + bx;
            int py = y + by;

            int ax0 = -bx;
            int ay0 = -by;

            dstPoints[0].X = Round.RShift((int)(ax0 * nCos - ay0 * nSin), 16) + px;
            dstPoints[0].Y = Round.RShift((int)(ax0 * nSin + ay0 * nCos), 16) + py;
            int ax1 = dx - bx;
            int ay1 = -by;

            dstPoints[1].X = Round.RShift((int)(ax1 * nCos - ay1 * nSin), 16) + px;
            dstPoints[1].Y = Round.RShift((int)(ax1 * nSin + ay1 * nCos), 16) + py;
            int ax2 = dx - bx;
            int ay2 = dy - by;

            dstPoints[2].X = Round.RShift((int)(ax2 * nCos - ay2 * nSin), 16) + px;
            dstPoints[2].Y = Round.RShift((int)(ax2 * nSin + ay2 * nCos), 16) + py;
            int ax3 = -bx;
            int ay3 = dy - by;

            dstPoints[3].X = Round.RShift((int)(ax3 * nCos - ay3 * nSin), 16) + px;
            dstPoints[3].Y = Round.RShift((int)(ax3 * nSin + ay3 * nCos), 16) + py;
            //	変数無駄な代入が多いが、最適化されるかなぁ(´Д`)

            src.Blt(DrawContext, srcRect, dstPoints);
        }
예제 #6
0
파일: Screen2DGl.cs 프로젝트: sinshu/dtf
        /// <summary>
        /// bltの回転機能つき。
        /// </summary>
        /// <param name="src"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="srcRect"></param>
        /// <param name="rad"></param>
        /// <param name="rate"></param>
        /// <param name="bx"></param>
        /// <param name="by"></param>
        /// <remarks>
        /// <para>
        /// 指定のテクスチャを転送先の(x,y)に半径rで描画します。
        /// </para>
        /// <para>
        /// radの単位は、0~512で一周(2π)となる角度。
        /// 	回転の方向は、右まわり(時計まわり)。
        /// rateは、拡大率。1.0ならば等倍。
        /// (bx,by)は転送元の画像の、回転中心。
        /// srcRectは転送元矩形。nullならば転送元テクスチャ全体。
        /// </para>
        /// </remarks>
        public void BltRotate(ITexture src, int x, int y, Rect srcRect, int rad, float rate, int bx, int by)
        {
            if (src == null) return;

            int sx, sy;	//	転送元サイズ

            if (srcRect == null)
            {
                srcRect = new Rect(0, 0, src.Width, src.Height);
            }

            {
                sx = (int)(srcRect.Right - srcRect.Left);
                sy = (int)(srcRect.Bottom - srcRect.Top);
            }

            if (sx == 0 || sy == 0) return;

            int dx, dy;	//	転送先サイズ
            dx = (int)(sx * rate);
            dy = (int)(sy * rate);
            if (dx == 0 || dy == 0) return;

            // 転送元の回転中心
            bx = (int)(bx * rate);
            by = (int)(by * rate);

            //	転送後の座標を計算する
            int nSin = SinTable.Instance.Sin(rad);
            int nCos = SinTable.Instance.Cos(rad);

            Point[] dstPoints = new Point[4];

            //	0.5での丸めのための修正項 → 0x8000
            int px = x + bx;
            int py = y + by;

            int ax0 = -bx;
            int ay0 = -by;
            dstPoints[0].X = Round.RShift((int)(ax0 * nCos - ay0 * nSin), 16) + px;
            dstPoints[0].Y = Round.RShift((int)(ax0 * nSin + ay0 * nCos), 16) + py;
            int ax1 = dx - bx;
            int ay1 = -by;
            dstPoints[1].X = Round.RShift((int)(ax1 * nCos - ay1 * nSin), 16) + px;
            dstPoints[1].Y = Round.RShift((int)(ax1 * nSin + ay1 * nCos), 16) + py;
            int ax2 = dx - bx;
            int ay2 = dy - by;
            dstPoints[2].X = Round.RShift((int)(ax2 * nCos - ay2 * nSin), 16) + px;
            dstPoints[2].Y = Round.RShift((int)(ax2 * nSin + ay2 * nCos), 16) + py;
            int ax3 = -bx;
            int ay3 = dy - by;
            dstPoints[3].X = Round.RShift((int)(ax3 * nCos - ay3 * nSin), 16) + px;
            dstPoints[3].Y = Round.RShift((int)(ax3 * nSin + ay3 * nCos), 16) + py;
            //	変数無駄な代入が多いが、最適化されるかなぁ(´Д`)

            src.Blt(DrawContext, srcRect, dstPoints);
        }
예제 #7
0
파일: Screen2DGl.cs 프로젝트: sinshu/dtf
 /// <summary>
 /// 凸四角形→凸四角形への転送。
 /// </summary>
 /// <param name="src"></param>
 /// <param name="srcPoint"></param>
 /// <param name="dstPoint"></param>
 public void Blt(ITexture src, Point[] srcPoint, Point[] dstPoint)
 {
     if (src != null)
         src.Blt(DrawContext, srcPoint, dstPoint);
 }
예제 #8
0
파일: Screen2DGl.cs 프로젝트: sinshu/dtf
 ///	<summary>画像の描画(2D)</summary>
 /// <remarks>
 ///	bltの転送元矩形と転送先4点の指定できるバージョン。
 ///	srcRectがnullのときはソース全域。
 ///	転送元矩形が、転送先として指定された4点に移動。
 ///
 ///	転送先は、
 ///	point[0]が左上、point[1]が右上、point[2]が右下、point[3]が左下
 ///	の点を指定しているものとする。
 /// </remarks>
 /// <example>
 /// <code>
 ///	Screen screen = new Screen;
 ///	screen.setVideoMode(640,480,0);
 ///	GlTexture tex = new GlTexture;
 ///	tex.load("title.png");
 ///
 ///	while (GameFrame.pollEvent()==0){
 ///
 ///		screen.clear();
 ///
 ///		Point[4] points;
 ///		points[0].setPoint(100,100);
 ///		points[1].setPoint(400,100);
 ///		points[2].setPoint(640,480);
 ///		points[3].setPoint(0,480);
 ///		screen.blt(tex2,0,0,null,points);	//	台形描画
 ///
 ///		screen.Update();
 ///	}
 ///	</code>
 ///	</example>
 public void Blt(ITexture src, Rect srcRect, Point[] point)
 {
     if (src != null)
         src.Blt(DrawContext, srcRect, point);
 }
예제 #9
0
파일: Screen2DGl.cs 프로젝트: sinshu/dtf
 ///	<summary>画像の描画(2D)。</summary>
 /// <remarks>
 ///	bltの転送元矩形と転送先サイズの指定できるバージョン。
 ///	srcRectがnullのときはソース全域。
 ///	dstSizeがnullのときは転送先全域(のサイズ)。
 ///
 ///	転送元矩形として、(Right,Top,Left,Bottom)を指定すれば
 ///	左右反転して表示される。(Left,Bottom,Right,Top)を指定すれば
 ///	上下反転して表示される。
 /// </remarks>
 public void Blt(ITexture src, int x, int y, Rect srcRect, Size dstSize)
 {
     if (src != null)
         src.Blt(DrawContext, x, y, srcRect, dstSize);
 }
예제 #10
0
파일: Screen2DGl.cs 프로젝트: sinshu/dtf
 ///	<summary>画像の描画(2D)。</summary>
 /// <remarks>
 ///	テクスチャーを(x,y)に等倍で描画する。
 ///	テクスチャーの色には、直前のsetColorの値が乗算される。
 ///
 ///	色の変更 → setColor(r,g,b)/setColor(a)/resetColor()
 ///	ブレンド方法変更 → blendなんちゃら関数 
 ///
 ///	※ テクスチャーを描画するとき、
 ///	glBindTextureを内部的に呼び出すので、これを設定している人は注意。
 /// 描画を転送先でclipしたいときは、 getDrawContext で
 /// 描画コンテクストを書き換えればok。
 /// </remarks>
 public void Blt(ITexture src, int x, int y)
 {
     if (src != null)
         src.Blt(DrawContext, x, y);
 }