User Tools

Site Tools


c:graphics.h:fillpoly

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:graphics.h:fillpoly [2024/02/16 01:05] (current)
Line 1: Line 1:
 +===== fillpoly =====
 +
 +
 +====Syntax of fillpoly ==== 
 + <code c>
 +#include <graphics.h>
 +void fillpoly(int numpoints, int *polypoints);
 +  </code>
 +
 +
 +==== Description of fillpoly ==== 
 +<code c>
 +fillpoly draws the outline of a polygon with numpoints points in the
 +current line style and color (just as drawpoly does), then fills the
 +polygon using the current fill pattern and fill 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.
 +</code>
 +
 +
 +==== Example of fillpoly ====
 +<code c>
 +/* fillpoly example */
 +
 +#include <graphics.h>
 +#include <stdlib.h>
 +#include <stdio.h>
 +#include <conio.h>
 +
 +int main(void)
 +{
 +   /* request autodetection */
 +   int gdriver = DETECT, gmode, errorcode;
 +   int i, maxx, maxy;
 +
 +   /* our polygon array */
 +   int poly[8];
 +
 +   /* 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[0] = 20; /* first vertex */
 +   poly[1] = maxy / 2;
 +   poly[2] = maxx - 20;/* second vertex */
 +   poly[3] = 20;
 +   poly[4] = maxx - 50;/* third vertex */
 +   poly[5] = maxy - 20;
 +   poly[6] = maxx / 2; /* fourth, fillpoly automatically */
 +   poly[7] = maxy / 2; /* closes the polygon */
 +
 +
 +   /* loop through the fill patterns */
 +   for (i=EMPTY_FILL; i<USER_FILL; i++) {
 +/* set fill pattern */
 +setfillstyle(i, getmaxcolor());
 +
 +/* draw a filled polygon */
 +fillpoly(4, poly);
 +getch();
 +   }
 +
 +   /* clean up */
 +   closegraph();
 +   return 0;
 +}
 +</code>
 +
 +
 +==== See also ====
 +[[drawpoly]]
 +[[floodfill]]
 +[[graphresult]]
 +[[setfillstyle]]
 +
 +
 +===== output of fillpoly example ===== 
 +
 +    no output of example at the moment
 +    do not hesitate and add it...  
 +
 +
  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/graphics.h/fillpoly.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz