Pages

Saturday, 10 February 2018

India Gate C Graphics

India Gate using C language graphics programming 


India Gate using C language graphics programming

Code : 


/*==============================
     Girfa Student Help
     Program : India Gate
     More Program : http://girfahelp.blogspot.in/p/graphics-c-language.html
     coder : Maynak Khare
     Email : khare.mayank09@gmail.com
================================*/
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#define x 100
int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int maxx, maxy,i,j;

   /* our polygon array */
   int poly[10];


   /* 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);
   }
   /**argiment total area*/
   poly[0]=20;
   poly[1]=20;
   poly[2]=600;
   poly[3]=20;
   poly[4]=600;
   poly[5]=450;
   poly[6]=20;
   poly[7]=450;
   poly[8]=20;
   poly[9]=20;

   /* draw the polygon */
   drawpoly(5, poly);
   /*in side gate*/
   line(250,445,250,230);
   line(350,445,350,230);
   arc(300,250,20,160,54);
   line(245,445,245,150);
   line(242,450,242,150);
   line(355,445,355,150);
   line(358,450,358,150);
   line(242,450,245,445);
   line(245,445,355,445);
    line(355,445,358,450);
   //* out sid layer*/
   poly[0]=175;
   poly[1]=450;
   poly[2]=175;
   poly[3]=150;
   poly[4]=425;
   poly[5]=150;
   poly[6]=425;
   poly[7]=450;

   /* draw the polygon */
   drawpoly(4, poly);
   //*border1st pole**********//
   poly[0]=172;
   poly[1]=250;
   poly[2]=243;
   poly[3]=250;
   poly[4]=245;
   poly[5]=253;
   poly[6]=245;
   poly[7]=255;
   poly[8]=243;
   poly[9]=253;
   poly[10]=172;
   poly[11]=253;
   poly[12]=175;
   poly[13]=257;
   drawpoly(7,poly);
   line(172,251,243,251);
    //*border2st pole**********//
   poly[0]=427;
   poly[1]=250;
   poly[2]=357;
   poly[3]=250;
   poly[4]=355;
   poly[5]=253;
   poly[6]=355;
   poly[7]=255;
   poly[8]=357;
   poly[9]=253;
   poly[10]=427;
   poly[11]=253;
   poly[12]=425;
   poly[13]=257;
   drawpoly(7,poly);
   line(427,251,357,251);
   /*first layer*/
   poly[0]=175;
   poly[1]=150;
   poly[2]=175;
   poly[3]=100;
   poly[4]=425;
   poly[5]=100;
   poly[6]=425;
   poly[7]=150;

   /* draw the polygon */
   drawpoly(4, poly);
  /* second layer*/
   poly[0]=190;
   poly[1]=100;
   poly[2]=190;
   poly[3]=75;
   poly[4]=410;
   poly[5]=75;
   poly[6]=410;
   poly[7]=100;

   /* draw the polygon */
   drawpoly(4, poly);
   /* third layer*/
   poly[0]=200;
   poly[1]=75;
   poly[2]=200;
   poly[3]=50;
   poly[4]=400;
   poly[5]=50;
   poly[6]=400;
   poly[7]=75;

   /* draw the polygon */
   drawpoly(4, poly);
   /*fourth layer*/
   poly[0]=250;
   poly[1]=50;
   poly[2]=250;
   poly[3]=30;
   poly[4]=350;
   poly[5]=30;
   poly[6]=350;
   poly[7]=50;

   /* draw the polygon */
   drawpoly(4, poly);
     /*bordar*/
   poly[0]=175;
   poly[1]=170;
   poly[2]=155;
   poly[3]=148;
   poly[4]=450;
   poly[5]=148;
   poly[6]=425;
   poly[7]=170;

   drawpoly(4, poly);
   /* 3d view of in side*/

  line(250,445,265,425);
  line(350,445,335,425);
  line(265,425,335,425);
  line(265,425,265,240);
  line(335,425,335,240);
  arc(300,255,20,154,38);
  //***************//
  setfillstyle(6,6);
   //Change RED to WHITE.
   floodfill(255,455,WHITE);
   //********************//
   setfillstyle(9,6);
   //Change RED to WHIT/
   floodfill(255,425,WHITE);
   //***************//
   setfillstyle(9,15);
   //Change RED to WHITE.
   floodfill(280,155,WHITE);
   //****************//
   setfillstyle(4,15);
   //Change RED to WHITE.
   floodfill(275,430,WHITE);
   //*********3d fill**********//
   setfillstyle(6,15);
   //Change RED to WHITE.
   floodfill(160,150,WHITE);
   //**********//
   setfillstyle(6,15);
   //Change RED to WHITE
   floodfill(424,149,WHITE);
   /************/
   setfillstyle(6,15);
   //Change RED to WHITE.
   floodfill(445,150,WHITE);
    /*1st layaer fill*/
   setfillstyle(6,6);
   //Change RED to WHITE.
   floodfill(180,105,WHITE);
   /* window*/
  // rectangle(200,300,230,400);
 //  rectangle(375,300,405,400);
   circle(210,215,20);
   circle(390,215,20);
   /********************/
   setfillstyle(6,15);
   //Change RED to WHITE.
   floodfill(210,215,WHITE);
  //******************//
   setfillstyle(6,15);
   //Change RED to WHITE.
   floodfill(390,215,WHITE);
   /************/
     /*2nd layaer fill*/
   setfillstyle(6,15);
   //Change RED to WHITE.
   floodfill(195,80,WHITE);
   //*************3rd layer fill*/
    setfillstyle(6,6);
   //Change RED to WHITE.
   floodfill(205,70,WHITE);
   //4th layer fill*/
    setfillstyle(9,15);
   //Change RED to WHITE.
   floodfill(255,35,WHITE);
   /********************/
    setfillstyle(10,15);
   //Change RED to WHITE.
   floodfill(180,155,WHITE);
  //******************//
   setfillstyle(10,15);
   //Change RED to WHITE.
   floodfill(365,155,WHITE);
   /********************/
    setfillstyle(10,15);
   //Change RED to WHITE.
   floodfill(180,350,WHITE);
  //******************//
   setfillstyle(10,15);
   //Change RED to WHITE.
   floodfill(365,350,WHITE);
   //*************/
   outtextxy(50,30,"INDIA");
   outtextxy(500,30,"GATE");
   outtextxy(45,400,"MAYANK KHARE ");
   outtextxy(427,400,"khare.mayank09@gmail.com");
   //************//
   //******************//
    for(i=0,j=1;i<100;i++)
   {
     delay(x);
      //  cleardevice();
     outtextxy(20+random(150),20+random(150),".");
     outtextxy(420+random(175),20+random(150),".");
     if(i<50)
     {
          outtextxy(350+random(200),20+random(20),".");
          outtextxy(20+random(200),20+random(20),".");
     }
     setcolor(j++);
     if(j==16)
          j=1;
   }


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



No comments:

Post a Comment