This is an analog clock program using the unit circle.
the weird decimal places in the Repeat loop are to fix a ghosting bug when drawing hands
Code:
an explanation with full source would be very nice (maybe in "//" comments?)
the weird decimal places in the Repeat loop are to fix a ghosting bug when drawing hands
Code:
//setup
StoreGDB 1
FnOff
AxesOff
ClrDraw
//set friendly window
1.3->Xmax
1.3->Ymax
~1.3->Xmin
~1.3->Ymin
ZSquare
Radian
//draw clock face
Circle(0,0,1
//draw tick marks
For(B,0,60*pi/30,pi/30
Line(.925*cos(B),.925*sin(B),cos(B),sin(B)
End
For(B,0,12*pi/6,pi/6
Line(.85*cos(B),.85*sin(B),cos(B),sin(B)
End
For(B,0,4*pi/2,pi/2
Line(.8*cos(B),.8*sin(B),cos(B),sin(B)
End
//draw hour labels
Text(0,44,"12
Text(28,75,"3
Text(56,46,"6
Text(28,19,"9
//repeats until keypress
Repeat getKey
//erase previously drawn hour hand and the draw a new one
getTime->L1
L1(1)->H
Line(0,0,.45*sin((H-1)*pi/6),.5*cos((H-1)*pi/6),0
Line(0,0,.45*sin((H)*pi/6),.5*cos((H)*pi/6)
//erase previously drawn minute hand and the draw a new one
getTime->L1
L1(2)->M
Line(0,0,.65*sin((M-1)*pi/30),.7*cos((M-1)*pi/30),0
Line(0,0,.65*sin((M)*pi/30),.7*cos((M)*pi/30)
//erase previously drawn second hand and the draw a new one
getTime->L1
L1(3)->S
Line(0,0,.7*sin((S-1)*pi/30),.75*cos((S-1)*pi/30),0
Line(0,0,.7*sin((S)*pi/30),.75*cos((S)*pi/30)
//draw date in corners of screen
getDate->L2
Text(55,74,L2(1)
Text(1,1,L2(2)
Text(7,1,L2(3)
End
RecallGDB 1
an explanation with full source would be very nice (maybe in "//" comments?)