-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path1389.bas
More file actions
93 lines (80 loc) · 1.7 KB
/
Copy path1389.bas
File metadata and controls
93 lines (80 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
'rem Analog clock.bas SmallBASIC 0.12.2 update Code Library example
'rem 2016-01-30 [B+=MGA]
' center
cx = xmax/2
cy = ymax/2
' default radius
if xmax>ymax then
r = cy * 0.9
er = cy * .95
else
r = cx * 0.9
er = cx * .95
end if
w2 = txtw("99999")
tr = r * 0.8
ir = tr - w2/2
hr = ir * 0.6
mr = ir * 0.7
sr = ir * 0.8
' display loop
while 1
color 0,1:cls
' draw frame
circle cx, cy, er, 1, rgb(255,235,125) filled
circle cx, cy, er-5 color 15
circle cx, cy, r color 0 filled
circle cx, cy, r+5 color 15
' draw hours
color 15,4
for i=1 to 12
s = ltrim(str(i))
sw = txtw(s): sh = txth(s)
sa = i * (2*PI)/12
dx = tr * sin(sa)
dy = tr * cos(sa)
x = cx+dx: y = cy-dy
circle x, y, w2 color 4 filled
at x-sw/2, y-sh/2
print s;
next i
' minute ticks
for j=1 to 60
msa = j * (2*PI)/60
mdx = (mr+5) * sin(msa)
mdy = (mr+5) * cos(msa)
mx = cx+mdx
my = cy-mdy
if j mod 5=0 then circle mx, my, 4,1,13 filled else circle mx, my, 2,1,9 filled
next
start = timer
timehms start, hour, mint, ssec
hours = hour+(mint/60)
if ( hours > 12 ) then hours -= 12
ha = hours * (2*PI)/12
ma = mint * (2*PI)/60
sa = ssec * (2*PI)/60
color 15, 0
at cx-.5*(txtw(time)), cy-.17*r
print time;
draw_arrow sa, sr, 7
draw_arrow ma, mr, 9
draw_arrow ha, hr, 12
showpage
while start - timer = 0: delay 20: wend
wend
end
sub draw_arrow(a, r, c)
local cr=10
color c
circle cx,cy,cr filled
dx = r * cos(a-pi/2)
dy = r * sin(a-pi/2)
line cx, cy, cx+dx, cy+dy
line cx+cr,cy,cx+dx,cy+dy
line cx-cr,cy,cx+dx,cy+dy
line cx,cy+cr,cx+dx,cy+dy
line cx,cy-cr,cx+dx,cy+dy
circle cx,cy,2,1,0 filled
circle cx,cy,cr-2,1,0
end