-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathexample_polygons.py
executable file
·33 lines (27 loc) · 1.05 KB
/
example_polygons.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
import st7565
import xglcd_font as font
from time import sleep
glcd = st7565.Glcd(rgb=[21, 20, 16])
glcd.init()
glcd.set_backlight_color(0, 100, 0)
x0, y0 = 40, 31
rout, rmid, rin = 30, 20, 10
incr = 2
path = "/home/pi/Pi-ST7565/"
wendy = font.XglcdFont(path + 'fonts/Wendy7x8.c', 7, 8)
ship = glcd.load_bitmap(path + 'images/ship_38x29.raw',
width=38, height=29, invert=True)
for angle in range(0, 360, incr):
glcd.clear_back_buffer()
glcd.draw_rectangle(0, 0, 128, 64)
glcd.draw_string("Angle: {0}".format(angle), wendy, 85, 2,spacing=0)
glcd.draw_bitmap(ship, 87, 32)
glcd.draw_polygon(6, x0, y0, rout, rotate=angle-180, color=1)
glcd.draw_polygon(5, x0, y0, rmid, rotate=-angle, color=1)
glcd.fill_polygon(3, x0, y0, rin, rotate=angle, color=1)
glcd.draw_polygon(6, x0, y0, rout, rotate=angle-180 + incr, color=1)
glcd.draw_polygon(5, x0, y0, rmid, rotate=-angle - incr, color=1)
glcd.fill_polygon(3, x0, y0, rin, rotate=angle + incr, color=1)
glcd.flip()
sleep(.01)
glcd.cleanup()