---
title: "GdiGraphics..::.FillRectangle Method (Brush, Int32, Int32, Int32, Int32)"
canonical: https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Drawing_GdiGraphics_FillRectangle_5_d0339c56.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# GdiGraphics.FillRectangle Method (Brush, Int32, Int32, Int32, Int32)
 
Fills a rectangle.
 
**Namespace:** [Aurigma.GraphicsMill.Drawing](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Drawing.htm.md)
 **Assembly:** Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
 
## Syntax
  
```
Public Sub FillRectangle ( _brush As Brush, _x As Integer, _y As Integer, _width As Integer, _height As Integer _
)
```
 
```csharp
public void FillRectangle(Brush brush,int x,int y,int width,int height
)
```
 
### Parameters
 
 - brush
     - Type: [Aurigma.GraphicsMill.Drawing.Brush](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Drawing_Brush.htm.md)
 [Brush](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Drawing_Brush.htm.md) object which is used to fill a rectangle.

 - x
     - Type: [System.Int32](http://msdn2.microsoft.com/en-us/td2s409d)
X-coordinate of the top left corner of the rectangle.

 - y
     - Type: [System.Int32](http://msdn2.microsoft.com/en-us/td2s409d)
Y-coordinate of the top left corner of the rectangle.

 - width
     - Type: [System.Int32](http://msdn2.microsoft.com/en-us/td2s409d)
Width of the rectangle.

 - height
     - Type: [System.Int32](http://msdn2.microsoft.com/en-us/td2s409d)
Height of the rectangle.
 
## Remarks
 To outline a rectangle, use [DrawRectangle(Pen, Int32, Int32, Int32, Int32)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Drawing_GdiGraphics_DrawRectangle_5_943d79c1.htm.md) method. 
All the coordinates are measured in units specified with [Unit](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_UnitConverterObject_Unit.htm.md) property.
 
## Examples
  
```
Dim bitmap As New Aurigma.GraphicsMill.Bitmap( _
 Aurigma.GraphicsMill.RgbColor.White, 185, 145, _
 Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)

Dim graphics As Aurigma.GraphicsMill.Drawing.GdiGraphics = bitmap.GetGdiGraphics()

'Draw filled and outlined rectangle
Dim pen As New Aurigma.GraphicsMill.Drawing.Pen(Aurigma.GraphicsMill.RgbColor.Red, 3)
Dim brush As New Aurigma.GraphicsMill.Drawing.SolidBrush( _
 Aurigma.GraphicsMill.RgbColor.FromRgb(&HDD, &HDD, &HFF))
graphics.FillRectangle(brush, 10, 10, 100, 60)
graphics.DrawRectangle(pen, 10, 10, 100, 60)

'Draw filled but non-outlined ellipse
brush.Color = Aurigma.GraphicsMill.RgbColor.Yellow
graphics.FillEllipse(brush, 60, 40, 100, 80)

'Draw outlined but non-filled polygon 
pen.Color = Aurigma.GraphicsMill.RgbColor.Green
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot
pen.Width = 1
Dim points As System.Drawing.Point() = { _
 New System.Drawing.Point(20, 30), New System.Drawing.Point(50, 2), _
 New System.Drawing.Point(180, 30), New System.Drawing.Point(80, 140)}
graphics.DrawPolygon(pen, points)
```
 
```csharp
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(
    Aurigma.GraphicsMill.RgbColor.White, 185, 145, 
    Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);

Aurigma.GraphicsMill.Drawing.GdiGraphics graphics = bitmap.GetGdiGraphics();

//Draw filled and outlined rectangle
Aurigma.GraphicsMill.Drawing.Pen pen = new Aurigma.GraphicsMill.Drawing.Pen(
    Aurigma.GraphicsMill.RgbColor.Red, 3);
Aurigma.GraphicsMill.Drawing.SolidBrush brush = new Aurigma.GraphicsMill.Drawing.SolidBrush( 
    Aurigma.GraphicsMill.RgbColor.FromRgb(0xDD, 0xDD, 0xFF));
graphics.FillRectangle(brush, 10, 10, 100, 60);
graphics.DrawRectangle(pen, 10, 10, 100, 60);

//Draw filled but non-outlined ellipse
brush.Color = Aurigma.GraphicsMill.RgbColor.Yellow;
graphics.FillEllipse(brush, 60, 40, 100, 80);

//Draw outlined but non-filled polygon 
pen.Color = Aurigma.GraphicsMill.RgbColor.Green;
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
pen.Width = 2;
System.Drawing.Point[] points = { 
    new System.Drawing.Point(20, 30), new System.Drawing.Point(50, 2), 
    new System.Drawing.Point(180, 30), new System.Drawing.Point(80, 140)};
graphics.DrawPolygon(pen, points);
```
   
## See Also

### Reference

- [GdiGraphics Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Drawing_GdiGraphics.htm.md)
- [FillRectangle Overload](https://www.graphicsmill.com/docs/gm5/O_T_Aurigma_GraphicsMill_Drawing_GdiGraphics_FillRectangle.htm.md)
- [Aurigma.GraphicsMill.Drawing Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Drawing.htm.md)
