ConvertRectangle() public static method

Converts a Rectangle into DxRectangle.
public static ConvertRectangle ( Sharpex2D.Math.Rectangle rectangle ) : RectangleF
rectangle Sharpex2D.Math.Rectangle The Rectangle.
return RectangleF
Beispiel #1
0
        /// <summary>
        /// Draws a Rectangle.
        /// </summary>
        /// <param name="pen">The Pen.</param>
        /// <param name="rectangle">The Rectangle.</param>
        public void DrawRectangle(Pen pen, Rectangle rectangle)
        {
            var dxPen = pen.Instance as DirectXPen;

            if (dxPen == null)
            {
                throw new ArgumentException("DirectX11 expects a DirectXPen as resource.");
            }

            DirectXHelper.RenderTarget.DrawRectangle(
                DirectXHelper.ConvertRectangle(rectangle), dxPen.GetPen(), dxPen.Width);
        }
Beispiel #2
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="texture">The Texture.</param>
        /// <param name="source">The SourceRectangle.</param>
        /// <param name="destination">The DestinationRectangle.</param>
        /// <param name="color">The Color.</param>
        /// <param name="opacity">The Opacity.</param>
        public void DrawTexture(Texture2D texture, Rectangle source, Rectangle destination, Color color,
                                float opacity = 1)
        {
            var dxTexture = texture as DirectXTexture;

            if (dxTexture == null)
            {
                throw new ArgumentException("DirectX11 expects a DirectXTexture as resource.");
            }
            Bitmap dxBmp = dxTexture.GetBitmap();

            DirectXHelper.RenderTarget.DrawBitmap(dxBmp, DirectXHelper.ConvertRectangle(destination), opacity,
                                                  InterpolationMode == InterpolationMode.Linear
                    ? BitmapInterpolationMode.Linear
                    : BitmapInterpolationMode.NearestNeighbor, DirectXHelper.ConvertRectangle(source));
        }
Beispiel #3
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="spriteSheet">The SpriteSheet.</param>
        /// <param name="rectangle">The Rectangle.</param>
        /// <param name="color">The Color.</param>
        /// <param name="opacity">The Opacity.</param>
        public void DrawTexture(SpriteSheet spriteSheet, Rectangle rectangle, Color color, float opacity = 1)
        {
            var dxTexture = spriteSheet.Texture2D as DirectXTexture;

            if (dxTexture == null)
            {
                throw new ArgumentException("DirectX11 expects a DirectXTexture as resource.");
            }
            Bitmap dxBmp = dxTexture.GetBitmap();

            DirectXHelper.RenderTarget.DrawBitmap(dxBmp,
                                                  new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height), opacity,
                                                  InterpolationMode == InterpolationMode.Linear
                    ? BitmapInterpolationMode.Linear
                    : BitmapInterpolationMode.NearestNeighbor, DirectXHelper.ConvertRectangle(spriteSheet.Rectangle));
        }
Beispiel #4
0
 /// <summary>
 /// Fills a Rectangle.
 /// </summary>
 /// <param name="color">The Color.</param>
 /// <param name="rectangle">The Rectangle.</param>
 public void FillRectangle(Color color, Rectangle rectangle)
 {
     DirectXHelper.RenderTarget.FillRectangle(DirectXHelper.ConvertRectangle(rectangle),
                                              new SolidColorBrush(DirectXHelper.RenderTarget, DirectXHelper.ConvertColor(color)));
 }