-
Notifications
You must be signed in to change notification settings - Fork 0
/
appRefresh.py
51 lines (41 loc) · 2.19 KB
/
appRefresh.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
class Canvas:
def __init__(self, backcolor, n):
self.n = n
self.canvas = open('/tmp/canvas-'+str(self.n), 'w')
self.canvas.write('display.fill('+str(backcolor)+')\n')
display.fill(int(backcolor))
def add_rect(self, x, y, w, h, color):
self.canvas.write('display.rect('+str(x)+','+str(y)+','+str(w)+','+str(h)+','+str(color)+')\n')
display.rect(x, y, w, h, color)
def add_fill_rect(self, w, h, x, y, color):
self.canvas.write('display.fill_rect('+str(x)+','+str(y)+','+str(w)+','+str(h)+','+str(color)+')\n')
display.fill_rect(x, y, w, h, color)
def add_line(self, x, y, x2, y2, color):
self.canvas.write('display.line('+str(x)+','+str(y)+','+str(x2)+','+str(y2)+','+str(color)+')\n')
display.line(x, y, x2, y2, color)
def add_circle(self, r, x, y, color):
self.canvas.write('display.circle('+str(r)+','+str(x)+','+str(y)+','+str(color)+')\n')
display.circle(r, x, y, color)
def add_fill_circle(self, r, x, y, color):
self.canvas.write('display.fill_circle('+str(r)+','+str(x)+','+str(y)+','+str(color)+')\n')
display.fill_circle(r, x, y, color)
def add_jpg(self, file, x, y):
self.canvas.write('display.jpg('+str(file)+','+str(x)+','+str(y)+')\n')
display.jpg(file, x, y)
def add_png(self, file, x, y):
self.canvas.write('display.png('+str(file)+','+str(x)+','+str(y)+')\n')
display.png(file, x, y)
def add_text(self, font, text, x, y, c=st7789.WHITE, bd=st7789.BLACK):
if str(font) == "<module 'vga1_8x8' from 'vga1_8x8.py'>":
self.canvas.write('display.text(font,"'+text+'",'+str(x)+','+str(y)+','+str(c)+','+str(bd)+')\n')
display.text(font, text, x, y, c, bd)
elif str(font) == "<module 'vga1_bold_16x32' from 'vga1_bold_16x32.py'>":
display.text(font, text, x, y, c, bd)
self.canvas.write('display.text(fontlarge,"'+text+'",'+str(x)+','+str(y)+','+str(c)+','+str(bd)+')\n')
def save(self):
self.canvas.close()
def redraw(self):
try:
execfile('/tmp/canvas-'+str(self.n))
except:
print('Error in canvas file!')