solidpolygon
This function is used to draw a filled polygon without a border.
void solidpolygon(
const POINT *points,
int num
);
Parameters
points
The coordinates of each point, the number of array elements is num.
The function automatically connects the polygon to the end.
num
The number of polygon vertices.
Return Value
None
Remarks
The function draws a filled polygon without a border using the current fill style.
Examples
The following snippet draws a closed fill triangle (two methods):
// method 1
POINT pts[] = { {50, 200}, {200, 200}, {200, 50} };
solidpolygon(pts, 3);
// method 2
int pts[] = {50, 200, 200, 200, 200, 50};
solidpolygon((POINT*)pts, 3);
The following full code draws a five-pointed star
#include <graphics.h>
#include <conio.h>
#include <math.h>
#define PI 3.14159265359
int main()
{
// Create a graphics window.
initgraph(640, 480);
// Define an array to hold five vertex coordinates for a pentastar
POINT pts[5];
// Calculate the five vertex coordinates of a pentastar
double a = PI / 2;
for (int i = 0; i < 5; i++)
{
pts[i].x = int(320 + cos(a) * 100);
pts[i].y = int(240 - sin(a) * 100);
a += PI * 4 / 5;
}
// Set fill mood to WINDING.
setpolyfillmode(WINDING);
// Set the fill color to red
setfillcolor(RED);
// Draw a five-pointed star (no border)
solidpolygon(pts, 5);
// Press any key to exit.
_getch();
closegraph();
}