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

The GraphicsPath::AddPolygon method adds a polygon to this path.

Syntax

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

Parameters

points

Pointer to an array of points that specifies the vertices of the polygon.

count

Integer that specifies the number of elements in the points array.

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

The GraphicsPath::AddPolygon method is similar to the AddLines method. The difference is that a polygon is an intrinsically closed figure, but a sequence of lines is not a closed figure unless you call GraphicsPath::CloseFigure. When Windows GDI+ renders a path, each polygon in that path is closed; that is, the last vertex of the polygon is connected to the first vertex by a straight line.

Examples

The following example creates a GraphicsPath object path, adds a polygon to path, and then draws 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);
}

Requirements

Requirement Value
Header gdipluspath.h

See also

AddPolygon Methods

Clipping with a Region

Constructing and Drawing Paths

Creating a Path Gradient

GraphicsPath

Paths

PointF

Polygons