-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathboxlines.py
58 lines (42 loc) · 1.23 KB
/
boxlines.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
"""
boxlines.py
===========
.. figure:: ../_static/boxlines.jpg
:align: center
Test for lines and rectangles.
Draws lines and rectangles in random colors at random locations on the display.
.. note:: This example requires the following modules:
.. hlist::
:columns: 3
- `st7789py`
- `tft_config`
"""
import random
import tft_config
palette = tft_config.palette
def main():
"""main"""
tft = tft_config.config(tft_config.WIDE)
while True:
color = palette.color565(
random.getrandbits(8), random.getrandbits(8), random.getrandbits(8)
)
tft.draw.line(
random.randint(0, tft.width),
random.randint(0, tft.height),
random.randint(0, tft.width),
random.randint(0, tft.height),
color,
)
width = random.randint(0, tft.width // 2)
height = random.randint(0, tft.height // 2)
col = random.randint(0, tft.width - width)
row = random.randint(0, tft.height - height)
tft.draw.fill_rect(
col,
row,
width,
height,
palette.color565(random.getrandbits(8), random.getrandbits(8), random.getrandbits(8)),
)
main()