DrawPath

Vector graphics, Path definition and drawing

Description

使用非零環繞填滿規則繪製目前路徑(由 StartPath, AddLineToPath, AddCurveToPath, AddArcToPathClosePath 組合而成);繪製路徑後,路徑狀態會重設,因此下一次 StartPath 會開始一個新的形狀

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

PathOptions繪製模式:

0 —— 僅大綱(使用目前的線條設定進行筆劃);
1 —— 僅填滿(使用目前的填滿顏色和非零環繞規則);
2 —— 填滿與大綱

Return values

0失敗 — PathOptions 超出範圍、未開啟任何文件,或未開始任何路徑
1路徑繪製成功

Remarks

請在呼叫 DrawPath 之前設定筆劃和填滿顏色以及線條屬性(SetLineWidth, SetLineCap, SetLineDash);目前的繪圖狀態將在呼叫點進行取樣

對於重疊或自我相交的路徑,非零環繞規則會將每個子路徑視為相同區域的一部分:從較大形狀中切出的孔洞需要內部子路徑的旋繞方向與外部相反;當此方式不方便時,請改為呼叫 DrawPathEvenOdd —— 奇偶規則僅在每次交叉時簡單地在內部 and 外部之間切換,這使得製作挖空孔洞變得非常簡單

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