-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframebuilder.py
More file actions
45 lines (37 loc) · 1.1 KB
/
Copy pathframebuilder.py
File metadata and controls
45 lines (37 loc) · 1.1 KB
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
### framebuilder.py
###
### This class contains the code needed to build to build a frame of
### a television "field"
###
### Author: GavinPlusPlus
### Date: Mar 15, 2023
class FrameBuilder:
def __new(cls, *args, **kwargs):
return super().__new__(cls)
def __init__(self, pre_processed_frame):
self.frame = pre_processed_frame
self.last_output_frame = ""
def convert_pixel_to_ascii(self, val):
if (val > 224):
return " "
elif (val > 153):
return "░"
elif (val > 102):
return "▒"
elif (val > 51):
return "▓"
else:
return "█"
def build_frame(self):
transformed_ascii = []
# Loop through each
for i in self.frame:
scanlines = []
for j in i:
scanlines.append(self.convert_pixel_to_ascii(j[0]))
scanlines.append("\n")
transformed_ascii.append(scanlines)
output = ""
for i in transformed_ascii:
output = output + "".join(i)
return output