DrawPathEvenOdd

Vector graphics, Path definition and drawing

Description

Paints the current path using the even-odd fill rule instead of the non-zero winding rule used by DrawPath. With the even-odd rule, a point is considered "inside" the path when a ray drawn from it crosses the path an odd number of times — overlapping sub-paths therefore alternate between filled and unfilled bands without needing to consider sub-path direction.

Syntax

Delphi

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

ActiveX

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

DLL

int DLDrawPathEvenOdd(int InstanceID, int PathOptions);

Parameters

PathOptionsPainting mode:

0 — Outline only.
1 — Fill only (even-odd 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

Use the even-odd rule when constructing shapes such as donuts, washers, or any figure that punches a hole through a larger outline. With the non-zero winding rule used by DrawPath the same construction works only if the inner sub-path is drawn in the opposite direction; with the even-odd rule the direction does not matter.

Example

// A filled square with a circular hole cut through it (donut)
PDF.SetFillColor(0, 0.4, 0.7);

PDF.StartPath(100, 100);
PDF.AddLineToPath(200, 100);
PDF.AddLineToPath(200, 200);
PDF.AddLineToPath(100, 200);
PDF.ClosePath;

// Inner circle — direction does not matter under even-odd
PDF.StartPath(170, 150);            // start on the right side of the circle
PDF.AddArcToPath(150, 150, 360);    // centre (150, 150), full revolution
PDF.ClosePath;

PDF.DrawPathEvenOdd(1);                // 1 = fill

See also

DrawPath, StartPath, AddArcToPath, ClosePath