DrawPath

Vector graphics, Path definition and drawing

Description

使用非零环绕填充规则绘制当前路径 — 该路径由 StartPathAddLineToPathAddCurveToPathAddArcToPathClosePath 组合而成;路径绘制完成后,路径状态会被重置,因此下一个 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 之前,设置描边和填充颜色以及线条属性(SetLineWidthSetLineCapSetLineDash);当前图形状态将在调用处进行采样

对于重叠或自相交的路径,非零环绕数规则将每个子路径视为同一区域的一部分:从较大形状中切出的孔要求内层子路径的环绕方向与外层相反;如果这样不方便,请改用调用 DrawPathEvenOdd —— 奇偶规则在每次交叉时仅在内部和外部之间交替,这使得打孔操作变得非常简单

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