Skip to content

Commit c4782df

Browse files
committed
if None colors, make transparant center or no outline
1 parent 265f5cc commit c4782df

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

adafruit_display_shapes/rect.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
class Rect(displayio.TileGrid):
44
def __init__(self, x, y, width, height, *, fill=None, outline=None):
55
self._bitmap = displayio.Bitmap(width, height, 2)
6+
self._palette = displayio.Palette(2)
7+
68
if outline is not None:
79
for w in range(width):
810
self._bitmap[w, 0] = 1
911
self._bitmap[w, height-1] = 1
1012
for h in range(height):
1113
self._bitmap[0, h] = 1
1214
self._bitmap[width-1, h] = 1
13-
14-
self._palette = displayio.Palette(2)
15-
self._palette[0] = fill
16-
self._palette[1] = outline
15+
self._palette[1] = outline
16+
if fill is not None:
17+
self._palette[0] = fill
18+
else:
19+
self._palette.make_transparent(0)
1720
super().__init__(self._bitmap, pixel_shader=self._palette, position=(x, y))
1821

19-
2022
@property
2123
def x(self):
2224
return self.position[0]

0 commit comments

Comments
 (0)