-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdc.py
executable file
·81 lines (71 loc) · 4.02 KB
/
dc.py
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
#!/usr/bin/env python3
TEXT = """ ./--::/`{a}
`.-.`:`/`
`-:` -`:.
.--``-`..
`.-- `-:--
.--- `.:-/
.--. .:--{a}
`.--. `-:--`
..-...`--:-`
`.--````.-:.. `````{a}
.......```.--``.`.-+.- `..`-.-
`:.-/:////--.``` ..:./ `.` ..-`
`:--:--://-``. `.-:.: ```` `.`.
````....` `:..--.-`- ``` `.`-
..-`` . .`..-..` ```` `..-`
`````````````````````````.-.-.-.:-...`..:.:```````````` .``` `.``-
`.-..--...`..`````..````````````.`.``...`````.`.-...........-::..-...```-.`:`
`-/+-```` ` ` ` -:...:-/:--:-:-/--.`
.-//.```` ` ` ` ` ` -:`` :-:--:-::/o///:`
.-:..-..`````````````` ` ` ` ` ` ````-:-----:-.-:-.:.``
```````..`................-----::/:------:-/-.........``..``.` ` `. -`
``..```. ` .`:`-` `. `. :
`..-`` `...----`. ```` `....
--.-..:--.``:` .--/.: `.`` `-`:
`:`:+://++:-`````.-: : `.` `:`:
:-`--.-....-.````.-/:. `.` -::`
`.:.`.``.:.-` ...:..{a}
`..-`.``./.:
.-:.. `./.-
`.:.` `./.-
.--` `./--{a}
..:. `-:+.
`-:. `: :`
.-- `: /`
.-:``:`/
`./.-::/
......`{a} """
TEXT = tuple(TEXT.format(a=('*' if t else ' ')).split('\n') for t in range(2))
from shutil import get_terminal_size
from time import sleep
from os import popen
from signal import signal, SIGINT
def out(*xargs):
print(*xargs, sep='', end='')
def setx(x):
out('\x1b[', x + 1, 'G')
def setxy(x, y):
out('\x1b[', y + 1, ';', x + 1, 'H')
def down():
out('\x1b[1B')
def clear():
out('\x1b[2J')
def draw(t, x=0):
setxy(0, h//2 - len(t)//2)
for line in t:
if x >= 0:
setx(x)
out(line[:w - x])
else:
out(line[-x:])
print()
if __name__ == '__main__':
signal(SIGINT, lambda a, b: None)
h, w = (int(i) for i in popen('stty size', 'r').read().split())
x = w
clear()
while x > -len(TEXT[0][0]):
draw(TEXT[(x % 40) < 16], x)
x -= 1
sleep(0.05)