RosettaCodeData/Task/Draw-a-clock/Sidef/draw-a-clock.sidef

32 lines
839 B
Text
Raw Permalink Normal View History

2017-09-23 10:01:46 +02:00
STDOUT.autoflush(true)
2016-12-05 23:44:36 +01:00
2017-09-23 10:01:46 +02:00
var (rows, cols) = `stty size`.nums...
2016-12-05 23:44:36 +01:00
var x = (rows/2 - 1 -> int)
var y = (cols/2 - 16 -> int)
var chars = [
"┌─┐ ╷╶─┐╶─┐╷ ╷┌─╴┌─╴╶─┐┌─┐┌─┐ ",
"│ │ │┌─┘╶─┤└─┤└─┐├─┐ │├─┤└─┤ : ",
"└─┘ ╵└─╴╶─┘ ╵╶─┘└─┘ ╵└─┘╶─┘ "
].map {|s| s.split(3) }
func position(i,j) {
2017-09-23 10:01:46 +02:00
"\e[%d;%dH" % (i, j)
2016-12-05 23:44:36 +01:00
}
func indices {
2017-09-23 10:01:46 +02:00
var t = Time.local
"%02d:%02d:%02d" % (t.hour, t.min, t.sec) -> split(1).map{|c| c.ord - '0'.ord }
2016-12-05 23:44:36 +01:00
}
loop {
2017-09-23 10:01:46 +02:00
print "\e[H\e[J"
for i in ^chars {
print position(x + i, y)
print [chars[i][indices()]].join(' ')
2016-12-05 23:44:36 +01:00
}
2017-09-23 10:01:46 +02:00
print position(1, 1)
Sys.sleep(0.1)
2016-12-05 23:44:36 +01:00
}