-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDigital_Stream.py
More file actions
33 lines (29 loc) · 867 Bytes
/
Copy pathDigital_Stream.py
File metadata and controls
33 lines (29 loc) · 867 Bytes
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
import random, shutil, sys, time
from colorama import Fore,Back,Style
MIN_STREAM_LENGTH = 6
MAX_STREAM_LENGTH = 14
PAUSE = 0.1
STREAM_CHARS = ['0','1']
DENSITY = 0.02
WIDTH = shutil.get_terminal_size()[0]
WIDTH -= 1
print('Digital Stream, by sinster-geek')
print('Press Ctrl-C to quit.')
time.sleep(2)
try:
columns = [0] * WIDTH
while True:
for i in range(WIDTH):
if columns[i] == 0:
if random.random() <= DENSITY:
columns[i] = random.randint(MIN_STREAM_LENGTH,MAX_STREAM_LENGTH)
if columns[i] > 0:
print(random.choice(STREAM_CHARS),end='')
columns[i] -= 1
else:
print(' ',end='')
print()
sys.stdout.flush()
time.sleep(PAUSE)
except KeyboardInterrupt:
sys.exit()