Skip to content

Commit 5dec0e3

Browse files
committed
shape corners
1 parent d6a2357 commit 5dec0e3

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import board
2+
import displayio
3+
"""
4+
Illustrate usage of displayio.Shape with boundary and mirror.
5+
"""
6+
7+
SHAPE_WIDTH = board.DISPLAY.width
8+
SHAPE_HEIGHT = board.DISPLAY.height
9+
CORNER_SIZE = board.DISPLAY.width // 4
10+
display = board.DISPLAY
11+
12+
shape = displayio.Shape(SHAPE_WIDTH, SHAPE_HEIGHT, mirror_x=True, mirror_y=True)
13+
14+
palette = displayio.Palette(2)
15+
16+
# set corner pixels out of bounds
17+
for i in range(CORNER_SIZE):
18+
shape.set_boundary(i, CORNER_SIZE-1-i, SHAPE_WIDTH//2-1)
19+
20+
palette[0] = 0x0000FF # out of bounds color
21+
palette[1] = 0x00FFFF # shape color
22+
23+
tile_grid = displayio.TileGrid(shape, pixel_shader=palette)
24+
group = displayio.Group()
25+
group.append(tile_grid)
26+
display.show(group)
27+
28+
# loop forever to keep it on the screen
29+
while True:
30+
pass

0 commit comments

Comments
 (0)