GraphicsPath.AddPolygon(const PointF*, INT) method

Applies to: desktop apps only

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

Syntax

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

Parameters

  • points [in]
    Type: const PointF*

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

  • count [in]
    Type: INT

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

Return value

Type:

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

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdipluspath.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

GraphicsPath

AddPolygon Methods

PointF

Clipping with a Region

Constructing and Drawing Paths

Creating a Path Gradient

Paths

Polygons

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012