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

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

Syntax

Status AddPolygon(
  [in] const Point *points,
  [in] INT         count
);

Parameters

[in] points

Type: const Point*

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

[in] count

Type: INT

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); 
 
   Point pts[] = {Point(20, 20),
                  Point(120, 20),
                  Point(120, 70)};

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

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

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdipluspath.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

AddPolygon Methods

Clipping with a Region

Constructing and Drawing Paths

Creating a Path Gradient

GraphicsPath

Paths

Point

Polygons