6
6
use_braille = True
7
7
8
8
columns = 160
9
- rows = 40
9
+ rows = 50
10
10
11
11
omega = 0.1
12
12
offset = 0
@@ -52,7 +52,7 @@ def get_polar(self):
52
52
return (mag , phi )
53
53
54
54
class Matrix :
55
- def __init__ (self , w , h , fill ):
55
+ def __init__ (self , w , h ):
56
56
self .w = w
57
57
self .h = h
58
58
self ._data = np .zeros ((h , w ))
@@ -75,19 +75,6 @@ def rows(self):
75
75
def points (self ):
76
76
return self ._data .flat
77
77
78
- def extract (self , _start , _end ):
79
- start = Coord (min (_start .x , _end .x ), min (_start .y , _end .y ))
80
- end = Coord (max (_start .x , _end .x ), max (_start .y , _end .y ))
81
-
82
- #print("extract from %s to %s" % (start, end))
83
-
84
- #diffx = end.x-start.x
85
- #diffy = end.y-start.y
86
-
87
- #new_matrix = Matrix(diffx+1, diffy+1, 0)
88
-
89
- return self ._data [start .y :end .y + 1 , start .x :end .x + 1 ]
90
-
91
78
def draw_line (self , start , end ):
92
79
diffx = end .x - start .x
93
80
diffy = end .y - start .y
@@ -104,23 +91,23 @@ def render(self, ren):
104
91
ren .draw (self )
105
92
106
93
def scale (self , new_w , new_h ):
107
- new_matrix = Matrix (new_w , new_h , 0 )
94
+ new_matrix = Matrix (new_w , new_h )
108
95
109
96
factor_w = self .w / new_w
110
97
factor_h = self .h / new_h
111
98
112
99
for y in range (new_h ):
113
100
for x in range (new_w ):
114
- extracted = self . extract (
115
- Coord (
116
- math . floor ( factor_w * x + 0.5 ),
117
- math .floor (factor_h * y + 0.5 )
118
- ),
119
- Coord (
120
- math . floor ( factor_w * ( x + 1 ) - 0.5 ),
121
- math . floor ( factor_h * ( y + 1 ) - 0.5 )
122
- )
123
- )
101
+ start_x = math . floor ( factor_w * x + 0.5 )
102
+ end_x = math . floor ( factor_w * ( x + 1 ) + 0.5 )
103
+
104
+ start_y = math .floor (factor_h * y + 0.5 )
105
+ end_y = math . floor ( factor_h * ( y + 1 ) + 0.5 )
106
+
107
+ extracted = self . _data [
108
+ start_y : end_y ,
109
+ start_x : end_x
110
+ ]
124
111
125
112
avg = extracted .mean ()
126
113
@@ -146,8 +133,8 @@ def draw(self, matrix):
146
133
self .matrix = matrix .scale (self .w , self .h )
147
134
for row in reversed (self .matrix .rows ()):
148
135
print ("" .join ([
149
- [" " , "-" , "o" , "x" ][max (min (math .floor (p / 40 ), 3 ), 0 )]
150
- # "x" if p else " "
136
+ # [" ", "-", "o", "x"][max(min(math.floor(p/40), 3), 0)]
137
+ "x" if p else " "
151
138
for p in row
152
139
]))
153
140
@@ -164,7 +151,7 @@ def draw(self, matrix):
164
151
for n in vals
165
152
]
166
153
167
- matrix = Matrix (300 , 100 , 0 )
154
+ matrix = Matrix (300 , 100 )
168
155
169
156
for col , val in enumerate (vals ):
170
157
# get previous column's value
0 commit comments