Friday, 9 February 2018

Polygon fill C Graphics



/*==============================
     Girfa Student Help
     Program : Polygon fill demo
     More Program : http://girfahelp.blogspot.in/p/graphics-c-language.html
     Coder Name : Mayank Khare , BCA
================================*/
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

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

   /* our polygon array */

   int poly[100];
   int i;
   /* 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();
   /* terminate with an error code */
      exit(1);
   }
   poly[0]=100;
   poly[1]=300;
   poly[2]=100;
   poly[3]=200;
   poly[4]=150;
   poly[5]=150;
   poly[6]=200;
   poly[7]=200;
   poly[8]=200;
   poly[9]=300;
   poly[10]=100;
   poly[11]=300;
   /* draw the polygon */
   drawpoly(6, poly);
   for(i=0;i<13;i++)
   {
     getch();
     setfillstyle(i,i);
     fillpoly(6,poly);
   }
   /* clean up */
   getch();
   closegraph();
   return 0;
}



No comments:

Post a Comment