Monday, October 25, 2010

computer graphics lab

//PROGRAM FOR FAN


#include

#include

#include


#define pi 3.142857

#define ROUND(a) ((int)(a+0.5))

void pie(int sa,int ea,int xc,int yc,int r)

{

double a1,a2;
int x,y;

a1=(pi*sa)/180;

x=xc+r*cos(a1);

y=yc+r*sin(a1);

line(xc,yc,x,y);

a2=-(pi*ea)/180;

x=xc+r*cos(a2);

y=yc+r*sin(a2);

line(xc,yc,x,y);

}


///////////////////////////////////////////////////


void runfan(int d)

{
int i=0,sa=0,ea=1;


while(!kbhit())

{
delay(d);

cleardevice();

circle(100,100,50);

line(90,150,90,250);

line(110,150,110,250);

line(40,250,40,300);

line(160,250,160,300);

line(40,300,160,300);

line(40,250,160,250);

outtextxy(45,275,"0");

outtextxy(75,275,"1");

outtextxy(105,275,"2");

outtextxy(135,275,"3");


pie(sa,ea,100,100,50);

pie(sa+150,ea+150,100,100,50);

pie(sa+300,ea+300,100,100,50);

i++;

sa=sa-10;
ea=ea+10;

}

}

/////////////////////////////////////////////////


int main()

{

int d=0,cho;

int gd=DETECT,gm;

initgraph(&gd,&gm," ");

runfan(0);

do
{

//runfan(0);

printf("\n enter the speed of regulator");

scanf("%d",&d);

switch(d)

{

case 0:

runfan(d);

break;

case 1:

runfan(70);
break;

case 2:

runfan(50);
break;

case 3:

runfan(20);
break;

}

printf("\n press 1 to continue");

scanf("%d",&cho);

}
while(cho==1);

getch();

return (0);

}

No comments: