ARCed.XnaExtensions.DrawRectangle C# (CSharp) Method

DrawRectangle() public static method

Draws a rectangle with given location, size, color, and border width.
public static DrawRectangle ( this batch, Rectangle rect, Microsoft.Xna.Framework.Color color, int border = 1 ) : void
batch this SpriteBatch to draw the rectangle.
rect Microsoft.Xna.Framework.Rectangle Rectangle to draw.
color Microsoft.Xna.Framework.Color Color to draw rectangle.
border int Width of the border in pixels
return void
        public static void DrawRectangle(this SpriteBatch batch, Rectangle rect, Color color, int border = 1)
        {
            var texture = new Texture2D(batch.GraphicsDevice, 1, 1);
            texture.SetData(new[] { Color.White });
            batch.Draw(texture, new Rectangle(rect.Left, rect.Top, rect.Width, border), color);
            batch.Draw(texture, new Rectangle(rect.Left, rect.Bottom - border, rect.Width, border), color);
            batch.Draw(texture, new Rectangle(rect.Left, rect.Top, border, rect.Height), color);
            batch.Draw(texture, new Rectangle(rect.Right - border, rect.Top, border, rect.Height - border), color);
        }

Same methods

XnaExtensions::DrawRectangle ( this batch, int x, int y, int width, int height, Microsoft.Xna.Framework.Color color, int border = 1 ) : void