Code archives/Miscellaneous/Analogue Clock Function

This code has been declared by its author to be Public Domain code.

Download source code

Analogue Clock Function by Rob Farley2002
Call the function

clock(x,y,size,r,g,b)

Example of usage:

Graphics 640,480,32,1
SetBuffer BackBuffer()
x=320
y=240
xd=2
yd=1
r=0
g=0
b=0

While Not KeyHit(1)
clock(x,y,60,r,g,b)
x=x+xd
y=y+yd
If x>=639 Or x<=0 Then xd=-xd
If y>=479 Or y<=0 Then yd=-yd
r=r+1
If r>255 Then r=255:g=g+1
If g>255 Then g=255:b=b+1
If b>255 Then r=0:g=0:b=0
Flip
Cls
Wend
; analogue clock - http://www.mentalillusion.co.uk
Function clock(x,y,size#,r,g,b)
Color r,g,b
hour#=Left$(CurrentTime$(),2)
minute#=Mid$(CurrentTime$(),4,2)
second#=Right$(CurrentTime$(),2)
If hour#>12 Then hour#=hour#-12
Line x,y,x+(Sin(second#*6)*size#),y-(Cos(second#*6)*size#)
Line x,y,x+(Sin(minute#*6)*size#),y-(Cos(minute#*6)*size#)
Line x,y,x+(Sin((hour#*30)+(minute#*.2))*(size#*.7)),y-(Cos((hour#*30)+(minute#*.2))*(size#*.7))
For n=0 To 11
Line x+(Sin(n*30)*(size#*.9)),y+(Cos(n*30)*(size#*.9)),x+(Sin(n*30)*size#),y+(Cos(n*30)*size#)
Next
For n=0 To 59
Plot x+(Sin(n*6)*size#),y+(Cos(n*6)*size#)
Next
End Function

Comments

None.

Code Archives Forum