Sunday, November 25, 2012

DRAW A HOUSE USING GRAPHIC FUNCTIONS


DRAW A HOUSE USING GRAPHIC FUNCTIONS


#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

void main()
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int xmax, ymax;
   int midx, midy;
   int radius = 10;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");
   /* read result of initialization */
   errorcode = graphresult();
   /* an error occurred */
   if (errorcode != grOk)
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);
   }

   setcolor(getmaxcolor());
   xmax = getmaxx();
   ymax = getmaxy();

   /* draw a diagonal line */

   line(150,150,400,150);
   line(150,300,400,300);
   line(150,150,150,300);
   line(400,150,400,300);
   line(150,150,275,50);

   line(400,150,275,50);
   line(275,50,500,50);

   line(400,150,625,150);
   line(500,50,625,150);
   line(625,150,625,300);
   line(400,300,625,300);

   //door
   line(250,300,250,250);
   line(300,300,300,250);
   line(250,250,300,250);
   line(250,300,275,290);
   line(250,250,275,260);
   line(275,290,275,260);

   //window
   line(450,200,550,200);
   line(450,250,550,250);
   line(450,200,450,250);
   line(550,200,550,250);
   line(450,225,550,225);
   line(500,200,500,250);
   circle(275,100,15);
   /* clean up */
   getch();
   closegraph();
}



























OUTPUT:-






























0 comments:

Post a Comment