-
Notifications
You must be signed in to change notification settings - Fork 11
/
image_noop.py
59 lines (38 loc) · 1.12 KB
/
image_noop.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
import os
class NoopImage:
"""NoopImage is a fake image for printing contnet on `stdout`."""
draw = None
def print(self):
self.draw.print()
class InMemoryImageDraw:
"""InMemoryImageDraw is a fake implementation of an instance returned by
ImageDraw.Draw() (Pillow). It is used for printing content on `stdout`."""
content = []
def __init__(self, image):
image.draw = self
def text(self, xy, text, font=None, fill=None):
self.content.append(text)
def rectangle(self, *args, **kwargs):
self.content = []
def line(self, *args, **kwargs):
self.content.append('-' * 20)
def print(self):
os.system("clear")
print("\n".join(self.content))
self.content = []
class NoopDisplay:
"""NoopDisplay is a fake display for printing contnet on `stdout`."""
width = 0
height = 0
def begin(self):
pass
def clear(self):
pass
def image(self, image):
image.print()
def display(self):
pass
def set_contrast(self, contrast):
pass
def command(self, command):
pass