[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Graphics' (#lcl)

# TCanvas.Rectangle

Draws a Rectangle with the specified coordinates.

## Declaration

Source position: graphics.pp line 1154

`public procedure TCanvas.Rectangle(`
`X1: Integer;`
`Y1: Integer;`
`X2: Integer;`
`Y2: Integer`
`); virtual; procedure TCanvas.Rectangle(`
`const ARect: TRect`
`);`

## Arguments

`X1` |  | Left coordinate for the top, left of the rectangle.
`Y1` |  | Top coordinate for the top, left of the rectangle.
`X2` |  | Right coordinate for the bottom, right of the rectangle.
`Y2` |  | Bottom coordinate for the bottom, right of the rectangle.

## Description

Rectangle is an overloaded method reintroduced in TCanvas. It is used to draw a rectangular shape on the drawing area for the canvas. The overloaded variants allow the coordinates to be specified as either:

- Four separate Integer values representing the top, left, bottom, and right vertices for the shape (X1, Y1, X2, Y2).
- A TRect instance where the vertices are represented as either four Integers, two TPoint instances for TopLeft and BottomRight, or a vector using the TArray4IntegerType (Rect).

Rectangle draws an outline (or borders) for the shape using the mode, style and width defined in Pen. The rectangle is also filled using the style, color and/or bitmap defined in Brush.

Use FillRect to fill a rectangular area with the current Brush without drawing its borders. Use FrameRect to draw the borders for the shape using the current Brush without filling the interior. Use Frame to draw borders for the shape using the current Pen and a clear Brush for the interior.

Rectangle calls the routine in the LCL interface used to implement the method for the current widgetset.

## See also

TCanvas.Pen |  | The Pen to be used for writing in this canvas.
TCanvas.Brush |  | The Brush used to paint on the Canvas.
TCanvas.FillRect |  | Fills a rectangular area on the canvas using the current Brush settings.
TCanvas.FloodFill |  | Fills an area at the specified coordinates with the current Brush for the canvas.
TCanvas.Frame |  | Draws a frame or border around the specified rectangle using the Pen for the canvas.
TCanvas.FrameRect |  | Draws a border around the specified rectangle with the Brush for the canvas.
TCanvas.Frame3D |  | Draws a frame for the specified rectangle with a 3-dimensional appearance.
LCLIntf.Rectangle |  |