39 lines
1.1 KiB
Plaintext
39 lines
1.1 KiB
Plaintext
|
#!/usr/bin/python3
|
||
|
import curses
|
||
|
import time
|
||
|
|
||
|
from hilbertgenerator import Vector, hilbertgenerator
|
||
|
|
||
|
win = curses.initscr()
|
||
|
curses.curs_set(0)
|
||
|
n = 16
|
||
|
state = [ [0] * 2*n for x in range(2*n) ]
|
||
|
lastpos = None
|
||
|
# 0123456789abcdef
|
||
|
linechars = "·─│┌──┐┬│└│├┘┴┤┼"
|
||
|
for pos in hilbertgenerator(Vector(n, n), Vector(n, 0), Vector(0,n)):
|
||
|
if lastpos is not None:
|
||
|
dir = pos - lastpos
|
||
|
state[int(lastpos.y)][int(lastpos.x)] |= (
|
||
|
(dir.x > 0) * 1 |
|
||
|
(dir.y > 0) * 2 |
|
||
|
(dir.x < 0) * 4 |
|
||
|
(dir.y < 0) * 8
|
||
|
)
|
||
|
state[int(pos.y)][int(pos.x)] |= (
|
||
|
(dir.x < 0) * 1 |
|
||
|
(dir.y < 0) * 2 |
|
||
|
(dir.x > 0) * 4 |
|
||
|
(dir.y > 0) * 8
|
||
|
)
|
||
|
win.addch(int(lastpos.y), int(lastpos.x), linechars[state[int(lastpos.y)][int(lastpos.x)]])
|
||
|
win.refresh()
|
||
|
time.sleep(0.1)
|
||
|
win.addch(int(pos.y), int(pos.x),
|
||
|
linechars[state[int(pos.y)][int(pos.x)]])
|
||
|
win.refresh()
|
||
|
time.sleep(0.1)
|
||
|
lastpos = pos
|
||
|
time.sleep(5)
|
||
|
curses.endwin()
|