CLOCK.PAS 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. uses graph,crt,vga,DOS;
  2. var
  3. i,j,x,y,x1,y1,x02,y02,x12,y12 : integer;
  4. SecX,SecY,SecXL,SecYL,HourX,HourY,HourXL,HourYL,MinX,MinY,MinXL,MinYL
  5. : real;
  6. Hour : string;
  7. TH,TM,TS,TMS,THL,TML,TSL : word;
  8. const
  9. Rad1=200;
  10. Rad2=180;
  11. CenX=320;
  12. CenY=240;
  13. begin
  14. InitVGA;
  15. Circle(CenX,CenY,Rad1);
  16. x:=rad2;
  17. y:=0;
  18. x1:=rad1;
  19. y1:=0;
  20. SetTextJustify(CenterText,CenterText);
  21. for i:= 1 to 60 do
  22. begin
  23. Line(cenx+X1,ceny+Y1,cenX+X,CenY+Y);
  24. if (I) mod 5 = 0 then begin
  25. x1:=round(rad1*cos(6*i*pi/180));
  26. y1:=round(rad1*sin(6*i*pi/180));
  27. x:=round(rad2*cos(6*i*pi/180));
  28. y:=round(rad2*sin(6*i*pi/180));
  29. end
  30. else begin
  31. x1:=round(rad1*cos(6*i*pi/180));
  32. y1:=round(rad1*sin(6*i*pi/180));
  33. x:=round((rad1-5)*cos(6*i*pi/180));
  34. y:=round((rad1-5)*sin(6*i*pi/180));
  35. end;
  36. if (I) mod 5 = 0 then begin
  37. str(((I-1) div 5+3) mod 12+1,hour);
  38. OutTextXY(cenx+round((rad2-10)*cos(6*i*pi/180)),
  39. ceny+round((rad2-10)*sin(6*i*pi/180)),hour);
  40. end;
  41. end;
  42. GetTime(TH,TM,TS,TMS);
  43. TH:=TH mod 12;
  44. SecXL:=round((rad1-10)*cos((6*TS-90)*pi/180));
  45. SecYL:=round((rad1-10)*sin((6*TS-90)*pi/180));
  46. MinXL:=round((rad2-10)*cos((6*TM+6/60*TS-90)*pi/180));
  47. MinYL:=round((rad2-10)*sin((6*TM+6/60*TS-90)*pi/180));
  48. HourXL:=round((rad2-70)*cos((30*TH+0.5*TM+30/60/60*TS-90)*pi/180));
  49. HourYL:=round((rad2-70)*sin((30*TH+0.5*TM+30/60/60*TS-90)*pi/180));
  50. SetWriteMode(XORPut);
  51. Line(CenX,CenY,round(CenX+HourXL),round(ceny+HourYL));
  52. Line(CenX,CenY,round(CenX+MinXL),round(ceny+MinYL));
  53. Line(CenX,CenY,round(CenX+SecXL),round(ceny+SEcYL));
  54. repeat
  55. GetTime(THL,TML,TSL,TMS);
  56. if (TH<>THL) or (TM<>TML) or (TS<>TSL) then begin
  57. Line(CenX,CenY,round(CenX+HourXL),round(ceny+HourYL));
  58. Line(CenX,CenY,round(CenX+MinXL),round(ceny+MinYL));
  59. Line(CenX,CenY,round(CenX+SecXL),round(ceny+SEcYL));
  60. SecX := SecXL*cos(6*pi/180) - SecYL*sin(6*pi/180);
  61. SecY := SecXL*sin(6*pi/180) + SecYL*Cos(6*pi/180);
  62. MinX := MinXL*cos(6/60*pi/180) - MinYL*sin(6/60*pi/180);
  63. MinY := MinXL*sin(6/60*pi/180) + MinYL*Cos(6/60*pi/180);
  64. HourX := HourXL*cos(6/60/12*pi/180) - HourYL*sin(6/60/12*pi/180);
  65. HourY := HourXL*sin(6/60/12*pi/180) + HourYL*Cos(6/60/12*pi/180);
  66. Line(CenX,CenY,round(CenX+HourX),round(ceny+HourY));
  67. Line(CenX,CenY,round(CenX+MinX),round(ceny+MinY));
  68. Line(CenX,CenY,round(CenX+SecX),round(ceny+SEcY));
  69. SecXL:=SecX;
  70. SecYL:=SecY;
  71. minXL:=MinX;
  72. MinYL:=MinY;
  73. HourXL:=HourX;
  74. HourYL:=HourY;
  75. end;
  76. TH:=THL;
  77. TM:=TML;
  78. TS:=TSL;
  79. until keypressed;
  80. Closegraph;
  81. end.