RAD Studio VCL Reference
|
Draws a rectangle with rounded corners on the canvas.
procedure RoundRect(X1: Integer; Y1: Integer; X2: Integer; Y2: Integer; X3: Integer; Y3: Integer); overload; procedure RoundRect(const Rect: TRect; CX: Integer; CY: Integer); overload;
__fastcall RoundRect(int X1, int Y1, int X2, int Y2, int X3, int Y3); __fastcall RoundRect(const TRect Rect, int CX, int CY);
Use RoundRect to draw a rounded rectangle using Pen and fill it with Brush. The rectangle will have edges defined by the points (X1,Y1), (X2,Y1), (X2,Y2), (X1,Y2), but the corners will be shaved to create a rounded appearance. The curve of the rounded corners matches the curvature of an ellipse with width X3 and height Y3.
To draw an ellipse instead, use Ellipse. To draw a true rectangle, use Rectangle.
C++ Examples:
/* This example draws many rounded rectangles of various sizes and colors on a form maximized to fill the entire screen: */ int x, y; void __fastcall TForm1::FormActivate(TObject *Sender) { WindowState = wsMaximized; Timer1->Interval = 50; randomize(); } void __fastcall TForm1::Timer1Timer(TObject *Sender) { x = random(Screen->Width - 10); y = random(Screen->Height - 10); Canvas->Pen->Color = (Graphics::TColor) random(65535); Canvas->Pen->Width = random(7); int Dx = random(400); int Dy = random(400); Canvas->RoundRect(x, y, x + Dx, y + Dy, Dx/2, Dy/2); }
Delphi Examples:
{ This example draws many rounded rectangles of various sizes and colors on a form maximized to fill the entire screen: } var X, Y, DX, DY: Integer; procedure TForm1.FormActivate(Sender: TObject); begin WindowState := wsMaximized; Timer1.Interval := 50; Randomize; end; procedure TForm1.Timer1Timer(Sender: TObject); begin X := Random(Screen.Width - 10); Y := Random(Screen.Height - 10); Canvas.Pen.Color := Random(65535); Canvas.Pen.Width := Random(7); DX := Random(400); DY := Random(400); Canvas.RoundRect(X, Y, X + DX, Y + DY, DX div 2, DY div 2); end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|