• Have Any Question?
• contact@eitworld.com # Fillpoly() Function

fillpoly() function is used to draw and fill the polygon with the default color scheme. This can be changed by the function setfillstyle() function.

void fillpoly( int num, int *polypoints );
• Like drawpoly() function fillpoly() function also contains two parameters num and polypoints.
• First parameter num specifies the number of points ‘n+1’ whereas there are ‘n’ vertices. Number of points are n+1 because first point coordinates should be equal to (n+1)th to draw a complete figure .
• polypoints tells the sequence of (n*2) integers . Each pair of integers gives x and y coordinates of a point on the polygon.
• For better understanding go through the program:

## Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT, gm,array[]={320,240,340,220,360,240,360,280,320,280,320,240);

initgraph(&gd,&gm,” “);

fillpoly(6,array);

getch();

closegraph();

}

Above program will draw a polygon of five sides or we can say a pantogone by using fillpoly() function, array[] contains the coordinates of the pantagone (320,240), (340,220), (360,240), (360,280) and (320,280) and also fill it with the current color scheme and with the default color that is white. The last coordinates (320,240) is as same as the first one in order to maintain the cyclic behavior of the pantagone. In the above program fillpoly() function contains two arguments 6 and array. First argument shows the six coordinates of the pantagone which is one more than the number of sides. Second argument shows the array which is the collection of the coordinates.

## Output  