DrawPath

Vector graphics, Path definition and drawing

Description

Paints the current path — assembled by StartPath, AddLineToPath, AddCurveToPath, AddArcToPath, and ClosePath — using the non-zero winding fill rule. After the path is painted the path state is reset, so the next StartPath begins a fresh shape.

Syntax

Delphi

function TPDFlib.DrawPath(PathOptions: Integer): Integer;

ActiveX

Function PDFlib::DrawPath(PathOptions As Long) As Long

DLL

int DLDrawPath(int InstanceID, int PathOptions);

Parameters

PathOptionsPainting mode:

0 — Outline only (stroke with the current line settings).
1 — Fill only (with the current fill color and the non-zero winding rule).
2 — Fill and outline.

Return values

0Failed — PathOptions is out of range, no document is open, or no path has been started.
1The path was painted successfully.

Remarks

Set the stroke and fill colors and the line attributes (SetLineWidth, SetLineCap, SetLineDash) before calling DrawPath. The current graphics state is sampled at the call site.

For overlapping or self-intersecting paths the non-zero winding rule treats every sub-path as part of the same region: a hole cut from a larger shape requires the inner sub-path to wind in the opposite direction to the outer. When that is inconvenient, call DrawPathEvenOdd instead — the even-odd rule simply alternates between inside and outside on each crossing, which makes punch-out holes trivial.

Example

// Filled outlined diamond
PDF.SetStrokeColor(0, 0, 0);
PDF.SetFillColor(0.6, 0.8, 1);
PDF.SetLineWidth(1.5);

PDF.StartPath(150, 100);
PDF.AddLineToPath(200, 150);
PDF.AddLineToPath(150, 200);
PDF.AddLineToPath(100, 150);
PDF.ClosePath;
PDF.DrawPath(2);                       // 2 = fill and outline

See also

DrawPathEvenOdd, StartPath, AddLineToPath, AddCurveToPath, AddArcToPath, ClosePath, SetLineWidth