## drawpoly

Syntax
```#include <graphics.h>
void drawpoly(int numpoints, int *polypoints);
```
Description
drawpoly draws a polygon with numpoints points, using the current line style and color.

*polypoints points to a sequence of (numpoints * 2) integers. Each pair of integers gives the x- and y-coordinates of a point on the polygon.

In order to draw a closed figure with n vertices, you must pass n + 1 coordinates to drawpoly where the nth coordinate is equal to the 0th.

Return Value
None.

fillpoly
floodfill
graphresult
setwritemode

Example
```/* drawpoly example */

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/* request autodetection */
int gdriver = DETECT, gmode, errorcode;
int maxx, maxy;

int poly;   /* our polygon array */

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk){ /* an error occurred */
printf("Graphics error: %s\n", grapherrormsg(errorcode));

printf("Press any key to halt:");
getch();
exit(1);             /* terminate with an error code */
}

maxx = getmaxx();
maxy = getmaxy();
poly = 20;           /* first vertex */
poly = maxy / 2;
poly = maxx - 20;    /* second vertex */
poly = 20;
poly = maxx - 50;    /* third vertex */
poly = maxy - 20;
poly = maxx / 2;     /* fourth vertex */
poly = maxy / 2;
poly = poly;      /* drawpoly doesn't automatically close */

poly = poly;      /* the polygon, so we close it */

drawpoly(5, poly);   /* draw the polygon */

/* clean up */
getch();
closegraph();
return 0;
}
```

Back to index