Simulation of a fan

Download as ".c" file http://www.ziddu.com/download/7938660/fan.zip.html


/*Simulation of a fan */
#include
#include
#include
#include
#include
const int midx=640/2,midy=480/2;
void drawfin(int angle)
{
setcolor(BLUE);
if(angle==0)
{
pieslice(midx,midy,0,30,35);
}
else
{
pieslice(midx,midy,(angle+30),(angle+30),35);
pieslice(midx,midy,(angle+90),(angle+90+60),35);
pieslice(midx,midy,(angle+270-60),(angle+270),35);
pieslice(midx,midy,(angle+360-60),(angle+360),35);
}
}
void drawfan(int angle)
{
int i;
bar(midx-3,midy,midx+3,midy+60);
bar(midx-35,midy+60,midx+35,midy+80);
bar(midx-30,midy+65,midx+30,midy+75);
for(i=5;i<=40;i+=10)
ellipse(midx,midy,0,360,i,i);
drawfin(angle);
fillellipse(midx,midy,5,5);
for(i=10;i<=40;i+=10)
ellipse(midx,midy,0,360,i,i);
ellipse(midx,midy,0,360,41,41);
}

void main()
{
int angle=0,speed=50,choice;
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "");
printf("\nELECTRIC FAN");
drawfan(angle);
while(!kbhit())
{
drawfan(angle);
delay(speed);
if(angle==270)
angle=0;
else
angle=angle+90;
cleardevice();
}
closegraph();
}

Download as ".c" file http://www.ziddu.com/download/7938660/fan.zip.html

0 comments: