#include #include #include #include #include #define K M_PI/180 char A[11][16][24]; int TIME[8]; void getdata() { char text[][2] = {"0","1","2","3","4","5","6","7","8","9",":"}; int i,j,k,x,y; int l = 0; settextstyle(3,HORIZ_DIR,4); for(i=0;i<11;i++) { if(i==10) l = 5; cleardevice(); outtextxy(320+l,240,text[i]); for(x=320,j=0;x<336;x++,j++) { for(y=250,k=0;y<274;y++,k++) { A[i][j][k] = getpixel(x,y)==0 ? 0 : 1; } } } } void transform(int &x,int &y,int z,int theta,int phi) { float sint = sin(K*theta); float sinp = sin(K*phi); float cost = cos(K*theta); float cosp = cos(K*phi); float tx = x*cost - y*sint + 0.5; float ty = x*sint*cosp + y*cost*cosp - z*sinp + 0.5; x = 320 + tx; y = 240 - ty; } void display(int i,int l,int theta,int phi) { int x,y,z,j,k; for(z=80;z<84;z++) { for(j=0;j<16;j++) { for(k=0;k<24;k++) { if(A[i][j][k]!=0) { x = l*19 + j + 20; y = k + 20; transform(x,y,z,theta,phi); putpixel(x,y,8); } } } } } void getsystime() { struct time t; gettime(&t); TIME[1] = t.ti_hour%10; TIME[0] = t.ti_hour/10; TIME[2] = 10; TIME[4] = t.ti_min%10; TIME[3] = t.ti_min/10; TIME[5] = 10; TIME[7] = t.ti_sec%10; TIME[6] = t.ti_sec/10; } void showtime() { int i,theta,phi; theta = 0;phi = 360; while(!kbhit()) { getsystime(); cleardevice(); for(i=0;i<4;i++) { display(TIME[i],i,theta,phi); display(TIME[7-i],7-i,theta,phi); } theta++; phi-=2; if(theta==360) { theta = 0; } if(phi==0) { phi = 360; } delay(25); } } void main() { int driver,mode; driver = DETECT; initgraph(&driver,&mode,"\\tc\\bgi"); getdata(); showtime(); closegraph(); }