Drawing Rounded Rectangles

From RAD Studio
Jump to: navigation, search

Go Up to Drawing Shapes

To draw a rounded rectangle on a canvas, call the canvas's RoundRect method.

The first four parameters passed to RoundRect are a bounding rectangle, just as for the Rectangle method or the Ellipse method. RoundRect takes two more parameters that indicate how to draw the rounded corners.

The following method, for example, draws a rounded rectangle in a form's upper left quadrant, rounding the corners as sections of a circle with a diameter of 10 pixels:

void __fastcall TForm1::FormPaint(TObject *Sender)
    Canvas->RoundRect(0, 0, ClientWidth/2, ClientHeight/2, 10, 10);

See Also