#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
void draw_clock()
{
int x=320,y=240,r=200,i,h,m,s,thetamin,thetasec;
char n[12][3]={"3","2","1","12","11","10","9","8","7","6","5","4"};
circle(x,y,210);
setcolor(4);
settextstyle(3,0,5);
for(i=0;i<12;i++)
outtextxy(x+(r-14)*cos(M_PI/6*i)-10,y-(r-14)*sin(M_PI/6*i)-20,n[i]);
}
void draw_time(int h,int m,int s,int theta,int thetamin,int thetasec)
{
int x=320,y=240,r=200,i;
int x1,y1;
int m1,s1,h1;
setcolor(RED);
setfillstyle(1,RED);
if(m>=15)
m1=m-15;
else
m1=m+45;
for(i=0;i<m1;i++)
thetamin+=6;
x1=x+(r-20)*cos(thetamin*M_PI/180);
y1=y+(r-20)*sin(thetamin*M_PI/180);
line(x,y,x1,y1);
setcolor(WHITE);
setfillstyle(1,WHITE);
if(s>=15)
s1=s-15;
else
s1=s+45;
for(i=0;i<s1;i++)
thetasec+=6;
x1=x+(r-10)*cos(thetasec*M_PI/180);
y1=y+(r-10)*sin(thetasec*M_PI/180);
line(x,y,x1,y1);
setcolor(CYAN);
setfillstyle(1,CYAN);
if(h>=3)
h1=h-3;
else
h1=h+9;
for(i=0;i<h1;i++)
theta+=30;
x1=x+(r-80)*cos(theta*M_PI/180);
y1=y+(r-80)*sin(theta*M_PI/180);
line(x,y,x1,y1);
if(!kbhit())
{
int x=320,y=240,r=200,i,j,k;
int t=60-s,n=60-m,flag=0,mflag=0;
for(i=0;i<12;i++)
{
if(mflag==1)
{
n=60;
thetamin=-90;
}
for(j=0;j<=n;j++)
{
if(flag==1)
{
t=60;
thetasec=-90;
}
for(k=0;k<=t;k++)
{
if((thetasec+(6*k))==270)
{
flag=1;
}
setcolor(BLACK);
line(x,y,x+(r-20)*cos((thetamin+(6*j)-6)*M_PI/180),y+(r-20)*sin((thetamin+(6*j)-6)*M_PI/180));
setcolor(RED);
line(x,y,x+(r-20)*cos((thetamin+(6*j))*M_PI/180),y+(r-20)*sin((thetamin+(6*j))*M_PI/180));
delay(100);
if((thetamin+(6*j))==270)
{
mflag=1;
setcolor(BLACK);
line(x,y,x+(r-80)*cos((theta+(6*i))*M_PI/180),y+(r-80)*sin((theta+(6*i))*M_PI/180));
setcolor(CYAN);
line(x,y,x+(r-80)*cos((theta+(6*i)+30)*M_PI/180),y+(r-80)*sin((theta+(6*i)+30)*M_PI/180));
delay(100);
}
setcolor(BLACK);
line(x,y,x+(r-10)*cos((thetasec+(6*k))*M_PI/180),y+(r-10)*sin((thetasec+(6*k))*M_PI/180));
setcolor(WHITE);
line(x,y,x+(r-10)*cos((thetasec+(6*k)+6)*M_PI/180),y+(r-10)*sin((thetasec+(6*k)+6)*M_PI/180));
delay(100);
}
}
}
}
}
int main()
{
int gd=DETECT,gm;
int h,m,s;
int theta=0,thetamin=0,thetasec=0;
printf("Enter the time:hour,min,secondsn");
scanf("%d%d%d",&h,&m,&s);
initgraph(&gd,&gm,"..//bgi");
draw_clock();
draw_time(h,m,s,theta,thetamin,thetasec);
getch();
return 1;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment