HotPDF Delphi PDF Component Developer Guide loslab Logo

 

THPDFPage.RoundRect

THPDFPage

 

Top  Previous  Next

Draws a rectangle with rounded corners on the canvas.

 

Delphi syntax:

procedure RoundRect ( X1, Y1, X2, Y2, X3, Y3: Integer );

 

C++ syntax:

void __fastcall RoundRect ( int X1, int Y1, int X2, int Y2, int X3, int Y3);

 

Description

 

Use RoundRect to draw a rounded rectangle. 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.

 

Code Example

program RoundRect;
{$APPTYPE CONSOLE}
uses
    SysUtils, Graphics, Classes, HPDFDoc;

var
    HPDF: THotPDF;

const
    DashArray: array[0..3] of Byte = (6, 4, 2, 4);

begin
    HPDF := THotPDF.Create(nil);
    try
        HPDF.AutoLaunch := true;                  // PDF file will be shown automatically
        HPDF.FileName := '\RoundRect.pdf';   // Set PDF filename
        HPDF.BeginDoc;                                // Create PDF file

        HPDF.CurrentPage.SetDash( DashArray, 0 );                    // Set  - . -  dash pattern
        HPDF.CurrentPage.RoundRect( 10, 10, 200, 100, 20, 20 ); // Draw round rect
        HPDF.CurrentPage.Stroke;                                              // and stroke

        HPDF.EndDoc;                         // Close PDF file
    finally
        HPDF.Free;
    end;
end.
Copyright©2007-2025 losLab.com