Help Center

GdipAddPathPolygonfunction

Adds a polygon to this path.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipAddPathPolygon (BYVAL path AS GpPath PTR, BYVAL points AS GpPointF PTR, BYVAL count AS INT_) AS GpStatus
Also documented as GdipAddPathPolygonI — one description covers them all.

Parameters

NameDescription
path[in] Pointer to the GraphicsPath object.
points[in] Pointer to an array of points that specifies the vertices of the polygon.
count[in] Long integer value that specifies the number of elements in the points array.

Description

Adds a polygon to this path.

Example

' ======================================================================================== ' This example draws a closed polygon using GdipAddPathPolygon. ' ======================================================================================== SUB Example_DrawPolygon (BYVAL hdc AS HDC)

DIM hStatus AS LONG

' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)

' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)

' // Create GraphicsPath DIM path AS GpPath PTR hStatus = GdipCreatePath(FillModeAlternate, @path)

' // Define polygon points DIM pts(0 TO 4) AS GpPointF pts(0).x = 100 : pts(0).y = 50 pts(1).x = 200 : pts(1).y = 80 pts(2).x = 180 : pts(2).y = 160 pts(3).x = 120 : pts(3).y = 160 pts(4).x = 80 : pts(4).y = 100

' // Add polygon to path hStatus = GdipAddPathPolygon(path, @pts(0), 5)

' // Create pen DIM pen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_FORESTGREEN, 2, UnitWorld, @pen)

' // Draw path hStatus = GdipDrawPath(graphics, pen, path)

' // Cleanup IF pen THEN GdipDeleteBrush(pen) IF path THEN GdipDeletePath(path) IF graphics THEN GdipDeleteGraphics(graphics)

END SUB ' ========================================================================================

Reference

  • Defined in AfxNova/AfxGdiPlus.bi:2022
  • Documented in Graphics/GdiPlus Flat Api/GdiPlusGraphicsPath.md
  • Topic: GraphicsPath Functions