Tuesday, October 4, 2011

Draw Hut using graphics in C

#include<conio.h>

#include<graphics.h>

#include<dos.h>

#include<stdlib.h>

void main()

{

                int a=0,b,x,y,h,c,midx,midy;

                int poly[25];

                initgraph(&a,&b,"");

                {

                for(int i=0;i<=40;i++)

                {

                x=random(640);

                y=random(200);

                if(x>200&&x<=405&&(y>=90&&y<200))

                continue;

                putpixel(x,y,15);

                }

                midx=getmaxx();

                midy=getmaxy();

                setfillstyle(1,3);

                rectangle(0,0,midx,midy);

                rectangle(10,10,midx-10,midy-10);

                floodfill(5,5,getmaxcolor());

                setfillstyle(1,8);

                rectangle(260,220,405,140);

                floodfill(360,180,getmaxcolor());

                setfillstyle(1,6);

      //      rectangle(260,220,160,140);

                floodfill(380,180,getmaxcolor());

                setfillstyle(1,6);

                rectangle(200,220,260,140);

                rectangle(225,200,235,140);

                floodfill(205,160,getmaxcolor());

                floodfill(245,160,getmaxcolor());

                setfillstyle(1,11);

                line(200,140,230,90);

                line(260,140,230,90);

                floodfill(225,130,getmaxcolor());

                setfillstyle(1,7);

                line(230,90,375,90);

                line(375,90,405,140);

                floodfill(10,300,getmaxcolor());

                setfillstyle(1,8);

                line(200,220,10,300);

                line(260,220,10,330);

                floodfill(11,310,getmaxcolor());

                setfillstyle(1,2);

                line(405,220,680,240);

                floodfill(11,410,getmaxcolor());

                setfillstyle(1,15);

                pieslice(150,70,50,220,15);

                setfillstyle(2,BROWN);

                floodfill(320,110,getmaxcolor());

                setfillstyle(1,2);

                putpixel(320,240,20);

                line(430,220,450,100);

                line(460,220,450,100);

                outtextxy(450,100,"m");

                circle(450,100,50);

                poly[0]=450;                       poly[1]=100;

                poly[2]=400;                       poly[3]=110;

                poly[4]=400;                       poly[5]=100;

                poly[6]=450;                       poly[7]=99;

                poly[8]=420;                       poly[9]=60;

                poly[10]=435;                    poly[11]=53;

                poly[12]=450;                    poly[13]=100;

                poly[13]=101;

                poly[14]=480;

                poly[15]=60;

                poly[16]=490;

                poly[17]=70;

                poly[18]=450;

                poly[19]=102;

                poly[20]=500;

                poly[21]=100;//poly[6]poly[6]

 

                drawpoly(17,poly);

                }

                getch();

                closegraph();

                }

No comments :

Post a Comment