-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoise.py
112 lines (92 loc) · 1.89 KB
/
noise.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import pyaudio
import struct
import numpy as numpy
import os
from perlin import PerlinNoiseFactory
import colorama
from colorama import Fore, Back, Style
def createChars(noise, xOff2, xOffDown2, columns, rows,color,scale):
char=""
xOff=xOff2
xOffDown=xOffDown2
for i in range(rows):
yOff=123
yOffDown=23
for j in range(columns):
n = noise(xOff,yOff)
nd = noise(xOffDown, yOffDown)
if(n>-0.06 and nd>-0.05):
char+="#"
else:
char+=" "
yOff += scale
yOffDown += scale
xOff+=scale
xOffDown+=scale
os.system("cls")
print(color+ char)
if __name__ == '__main__':
colorama.init()
noise = PerlinNoiseFactory(2,1)
scale=0
xOff2 = 213
xOffDown2 =1337
COLORS = ["red", "yellow", "green", "blue", "white"]
COLORS_C=[Fore.RED,Fore.YELLOW, Fore.GREEN,Fore.BLUE,Fore.WHITE]
color=""
while True:
print("")
color = input("Which Color?: ")
if color in COLORS:
print("")
print("COLOR: "+color)
color = COLORS_C[COLORS.index(color)]
break
else:
print("")
print("Color Not Found.")
speed = 0
while True:
try:
print("")
speed = float(input("Speed?: "))
break
except KeyboardInterrupt:
exit()
pass
except:
pass
scale = 0.01
while True:
try:
print("")
scale = float(input("Scale?: "))
break
except KeyboardInterrupt:
exit()
pass
except:
pass
while True:
try:
columns, rows = os.get_terminal_size(0)
except OSError:
columns, rows = os.get_terminal_size(1)
xOff2 +=speed
xOffDown2-=speed
createChars(noise, xOff2, xOffDown2, columns, rows, color, scale)
# CHUNK = 1024* 4
# FORMAT = pyaudio.paInt16
# CHANNELS = 1
# RATE=44100
# p = pyaudio.PyAudio()
# stream = p.open(
# format=FORMAT,
# channels=CHANNELS,
# rate=RATE,
# input=True,
# output=True,
# frames_per_buffer=CHUNK
# )
# data = stream.read(CHUNK)
# data_int = np.array(struct.unpack(str(2*CHUNK)+'B',data), dtype='b')[::2]+127