96 lines
1.5 KiB
Plaintext
96 lines
1.5 KiB
Plaintext
' --------------------------------------------
|
|
' clock. I got nothing but time
|
|
' ---------------------------------------------
|
|
n = 12 ' num of points
|
|
r = 95 ' radius
|
|
pi = 22/7
|
|
alpha = pi * 2 / n
|
|
dim points(n)
|
|
graphic #g2, 200, 200
|
|
' --------------------------------------
|
|
' Draw the clock
|
|
' --------------------------------------
|
|
#g2 size(2) 'pen size
|
|
#g2 down()
|
|
#g2 font("arial", 20, "bold")
|
|
#g2 place(85,30)
|
|
#g2 "\12"
|
|
#g2 place(170,105)
|
|
#g2 "\3"
|
|
#g2 place(10,105)
|
|
#g2 "\9"
|
|
#g2 place(90,185)
|
|
#g2 "\6"
|
|
for i = 0 to n - 1
|
|
theta = alpha * i
|
|
px = cos( theta ) * r
|
|
py = sin( theta ) * r
|
|
px = px + 100
|
|
py = py + 100
|
|
#g2 place(px,py)
|
|
#g2 circle(2)
|
|
next i
|
|
|
|
[shoTime]
|
|
' -------------------------
|
|
' clear previous sec,min,hr
|
|
' -------------------------
|
|
r = 63
|
|
p = se
|
|
#g2 color("white")
|
|
gosub [h2Dot]
|
|
r = 50
|
|
p = mi
|
|
#g2 color("white")
|
|
gosub [h2Dot]
|
|
r = 30 ' radius
|
|
p = hr * 5
|
|
#g2 color("white")
|
|
gosub [h2Dot]
|
|
|
|
' -------------------------
|
|
' Show new time
|
|
' -------------------------
|
|
a$ = time$()
|
|
hr = val(word$(a$,1,":"))
|
|
mi = val(word$(a$,2,":"))
|
|
se = val(word$(a$,3,":"))
|
|
|
|
' put time on the clock - gimme a hand
|
|
#g2 size(4)
|
|
' second hand
|
|
n = 60
|
|
r = 63
|
|
p = se
|
|
#g2 color("blue")
|
|
gosub [h2Dot]
|
|
|
|
' minute hand
|
|
r = 50
|
|
p = mi
|
|
#g2 color("green")
|
|
gosub [h2Dot]
|
|
|
|
' hour hand
|
|
r = 30 ' radius
|
|
p = hr * 5
|
|
#g2 color("red")
|
|
gosub [h2Dot]
|
|
|
|
render #g2
|
|
end
|
|
|
|
' a one liner
|
|
[h2Dot]
|
|
alpha = pi * 2 / n
|
|
i = p - 15
|
|
theta = alpha * i
|
|
px = cos( theta ) * r
|
|
py = sin( theta ) * r
|
|
px = px + 100
|
|
py = py + 100
|
|
#g2 place(px,py)
|
|
#g2 circle(2)
|
|
#g2 line(100,100,px,py)
|
|
RETURN
|