Draw a clock: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: added syntax colouring, made p2js compatible)
Line 1,764: Line 1,764:
[https://easylang.online/apps/clock.html Run it]
[https://easylang.online/apps/clock.html Run it]


<lang>func draw hour min sec . .
<lang># Clock
#
func draw hour min sec . .
# dial
# dial
set_color 333
color 333
move_pen 50 50
move 50 50
draw_circle 45
circle 45
set_color 797
color 797
draw_circle 44
circle 44
set_color 333
color 333
for i range 60
for i range 60
a = i * 6
a = i * 6
move_pen 50 + sin a * 40 50 - cos a * 40
move 50 + sin a * 40 50 - cos a * 40
draw_circle 0.25
circle 0.25
.
.
for i range 12
for i range 12
a = i * 30
a = i * 30
move_pen 50 + sin a * 40 50 - cos a * 40
move 50 + sin a * 40 50 - cos a * 40
draw_circle 1
circle 1
.
.
# hour
# hour
set_linewidth 2
linewidth 2
set_color 000
color 000
a = (hour * 60 + min) / 2
a = (hour * 60 + min) / 2
move_pen 50 50
move 50 50
draw_line 50 + sin a * 32 50 - cos a * 32
line 50 + sin a * 32 50 - cos a * 32
# min
# min
set_linewidth 1.5
linewidth 1.5
a = (sec + min * 60) / 10
a = (sec + min * 60) / 10
move_pen 50 50
move 50 50
draw_line 50 + sin a * 40 50 - cos a * 40
line 50 + sin a * 40 50 - cos a * 40
# sec
# sec
set_linewidth 1
linewidth 1
set_color 700
color 700
a = sec * 6
a = sec * 6
move_pen 50 50
move 50 50
draw_line 50 + sin a * 40 50 - cos a * 40
line 50 + sin a * 40 50 - cos a * 40
.
.
on timer
on timer
if t <> time_secs
if t <> floor systime
t = time_secs
t = floor systime
h$ = time_str t
h$ = timestr t
sec = number substr h$ 17 2
sec = number substr h$ 17 2
min = number substr h$ 14 2
min = number substr h$ 14 2
Line 1,811: Line 1,813:
.
.
call draw hour min sec
call draw hour min sec
set_timer 0.98
else
set_timer 0.01
.
.
timer 0.1
.
.
set_timer 0</lang>
timer 0</lang>


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==