DrawPath
向量圖形、路徑定義與繪製
描述
繪製目前的路徑 — 由 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 — 填色加外框。 |
|---|
傳回值
| 0 | 失敗 — PathOptions 超出範圍、未開啟任何文件,或尚未起始路徑。 |
|---|---|
| 1 | 路徑繪製成功。 |
備註
設定描邊與填色色彩及線條屬性(SetLineWidth、SetLineCap、SetLineDash),然後才呼叫 DrawPath;目前的圖形狀態會在呼叫當下取樣
路徑重疊或自我相交時,non-zero winding 規則把每個子路徑視為同一區域的一部分:從較大形狀挖出的洞,內圈子路徑必須與外圈反向繞行。這樣不方便時,改呼叫 DrawPathEvenOdd — even-odd 規則在每次穿越時就在內外之間交替,挖洞變得非常簡單。
範例
// Filled outlined diamond
PDF.SetLineColor(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