DrawPath

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

描述

以 non-zero winding 填色規則繪製目前路徑 — 路徑由 StartPath、AddLineToPath、AddCurveToPath、AddArcToPath 與 ClosePath 組成。路徑繪製完成後,路徑狀態會重設,下一次 StartPath 便從全新形狀開始。

語法

Delphi

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

ActiveX

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

DLL

int DLDrawPath(int InstanceID, int PathOptions);

參數

PathOptions繪製模式:

0 — 僅外框(以目前的線段設定進行框線繪製)。
1 — 僅填色(使用目前填色與 non-zero winding 規則)。
2 — 填色加外框。

傳回值

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

備註

筆劃與填色顏色以及線條屬性(SetLineWidth、SetLineCap、SetLineDash)要在呼叫 DrawPath 之前設定。目前的圖形狀態是在呼叫點取樣的。

路徑重疊或自我相交時,non-zero winding 規則把每個子路徑視為同一區域的一部分:從較大形狀挖出的洞,內圈子路徑必須與外圈反向繞行。這樣不方便時,改呼叫 DrawPathEvenOdd — even-odd 規則在每次穿越時就在內外之間交替,挖洞變得非常簡單。

範例

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

另見

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