AddBoxToPath

Vector graphics, Path definition and drawing

Description

Adds an axis-aligned rectangle as a complete closed sub-path to the current path. Unlike AddLineToPath, this function does not require a prior StartPath call — a fresh sub-path is started and closed automatically.

Syntax

Delphi

function TPDFlib.AddBoxToPath(Left, Top, Width, Height: Double): Integer;

ActiveX

Function PDFlib::AddBoxToPath(Left As Double, Top As Double, Width As Double, Height As Double) As Long

DLL

int DLAddBoxToPath(int InstanceID, double Left, double Top, double Width, double Height);

Parameters

LeftThe horizontal co-ordinate of the box's left edge.
TopThe vertical co-ordinate of the box's top edge.
WidthThe width of the box. Negative widths are reflected so the rectangle still has positive extent.
HeightThe height of the box.

Return values

0Failed — no document is open.
1The rectangle was added to the current path.

Remarks

Several boxes can be added to the same path; together with DrawPathEvenOdd this is the simplest way to draw shapes with rectangular holes. After all boxes are added, call DrawPath (winding rule) or DrawPathEvenOdd (even-odd rule) to paint the result.

Example

// A filled rectangle frame: outer box with an inner box punched out
PDF.SetFillColor(0.2, 0.4, 0.8);
PDF.AddBoxToPath(100, 100, 200, 120);  // outer
PDF.AddBoxToPath(120, 120, 160,  80);  // inner cut-out
PDF.DrawPathEvenOdd(1);                // 1 = fill

See also

StartPath, AddLineToPath, AddArcToPath, DrawPath, DrawPathEvenOdd