DrawPathEvenOdd

向量圖形、路徑定義與繪製

描述

以 even-odd 填色規則繪製目前路徑,而不是 DrawPath 使用的 non-zero winding 規則。在 even-odd 規則下,從某點畫出的射線以奇數次數穿越路徑時,該點就視為路徑「內部」— 因此重疊的子路徑會在填色與未填色區帶之間交替,不必考慮子路徑方向。

語法

Delphi

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

ActiveX

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

DLL

int DLDrawPathEvenOdd(int InstanceID, int PathOptions);

參數

PathOptions繪製模式:

0 — 僅外框。
1 — 僅填色(even-odd 規則)。
2 — 填色加外框。

傳回值

0Failed — PathOptions is out of range, no document is open, or no path has been started.
1路徑繪製成功。

備註

甜甜圈、墊圈,或任何要在大外框裡挖洞的圖形,建構時請用奇偶規則。非零環繞規則下,同樣的幾何會整塊填滿,除非內外輪廓的環繞方向相反。

範例

// 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

另見

DrawPath, StartPath, AddArcToPath, ClosePath