ClosePath
Vector graphics, Path definition and drawing
Description
Closes the current sub-path of the path that was started by StartPath. A straight line is drawn from the current point back to the path's starting point, ensuring the figure is a single closed shape rather than two end points connected only by a stroke join. Calling ClosePath does not paint the path — call DrawPath or DrawPathEvenOdd afterwards to stroke and/or fill it.
Syntax
Delphi
function TPDFlib.ClosePath: Integer;ActiveX
Function PDFlib::ClosePath As LongDLL
int DLClosePath(int InstanceID);Return values
| 0 | Failed — no document is open or no path has been started. |
|---|---|
| 1 | The current sub-path has been closed. |
Remarks
Closing the path is important whenever the shape will be stroked: an open path leaves a visible gap between the last point and the first point, and the stroke join at that vertex is rendered as a butt cap rather than a proper line join. For filled paths the closing line is implied by the fill rule, but closing explicitly still produces cleaner output and is required before starting a new sub-path with another StartPath.
Example
// Draw a closed triangle, stroked
PDF.SetStrokeColor(0, 0, 0);
PDF.SetLineWidth(1);
PDF.StartPath(100, 100);
PDF.AddLineToPath(200, 100);
PDF.AddLineToPath(150, 180);
PDF.ClosePath; // line back to (100, 100)
PDF.DrawPath(0); // 0 = outline onlySee also
StartPath, AddLineToPath, AddCurveToPath, DrawPath, DrawPathEvenOdd