GraphicsPath::AddPolygon (constPointF*,INT) 方法 (gdipluspath.h)

GraphicsPath::AddPolygon 方法将多边形添加到此路径。

语法

Status AddPolygon(
  const PointF *points,
  INT          count
);

参数

points

指向指定多边形顶点的点数组的指针。

count

指定点数组中的元素数的整数。

返回值

Type:Status

如果方法成功,则返回 Ok,这是 Status 枚举的元素。

如果 方法失败,它将返回 Status 枚举的其他元素之一。

注解

GraphicsPath::AddPolygon 方法类似于 AddLines 方法。 区别在于多边形是固有封闭图,但线条序列不是闭合图,除非调用 GraphicsPath::CloseFigure。 当 Windows GDI+ 呈现路径时,该路径中的每个多边形都会关闭;也就是说,多边形的最后一个顶点通过直线连接到第一个顶点。

示例

以下示例创建 GraphicsPath 对象路径,将多边形添加到 path,然后绘制路径。

VOID Example_AddPolygon(HDC hdc)
{
   Graphics graphics(hdc);

   PointF pts[] = {PointF(20.0f, 20.0f),
                   PointF(120.0f, 20.0f),
                   PointF(120.0f, 70.0f)};

   GraphicsPath path;
   path.AddPolygon(pts, 3);

   // Draw the path.
   Pen pen(Color(255, 255, 0, 0));
   graphics.DrawPath(&pen, &path);
}

要求

要求
Header gdipluspath.h

另请参阅

AddPolygon 方法

使用区域进行剪裁

构造并绘制轨迹

创建路径渐变

GraphicsPath

路径

PointF

Polygon(多边形)