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 — 仅填充(采用当前填充颜色和非零环绕规则)。 2 — 填充并描边 |
|---|
返回值
| 0 | 失败 — PathOptions 超出范围、未打开文档,或尚未开始路径 |
|---|---|
| 1 | 路径已成功绘制 |
备注
设置描边和填充颜色及线条属性(SetLineWidth、SetLineCap、SetLineDash)后,再调用 DrawPath。调用位置会采样当前图形状态
对于重叠或自相交路径,非零环绕规则将每个子路径视为同一区域的一部分:要从较大形状中挖出孔洞,内层子路径的环绕方向必须与外层相反 如此不便,请改用 DrawPathEvenOdd — 奇偶规则会在每次交叉时简单地在内部与外部之间交替,使挖孔变得轻而易举
示例
// 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