Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
95
Task/Draw-a-clock/Run-BASIC/draw-a-clock.run
Normal file
95
Task/Draw-a-clock/Run-BASIC/draw-a-clock.run
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
' --------------------------------------------
|
||||
' 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue