Skip to content

Commit c56200a

Browse files
committed
setters and getters for the fill and outline colors
1 parent 0db4dfc commit c56200a

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

adafruit_display_shapes/rect.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,28 @@ def __init__(self, x, y, width, height, *, stroke=1, fill=None, outline=None):
7171
self._palette.make_transparent(0)
7272
super().__init__(self._bitmap, pixel_shader=self._palette, position=(x, y))
7373

74+
@property
75+
def fill(self):
76+
return self._palette[0]
77+
78+
@fill.setter
79+
def fill(self, color):
80+
if color is None:
81+
self._palette.make_transparent(0)
82+
else:
83+
self._palette[0] = color
84+
85+
@property
86+
def outline(self):
87+
return self._palette[1]
88+
89+
@outline.setter
90+
def outline(self, color):
91+
if color is None:
92+
self._palette.make_transparent(1)
93+
else:
94+
self._palette[1] = color
95+
7496
@property
7597
def x(self):
7698
"""The x coordinate of the position"""

adafruit_display_shapes/roundrect.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,29 @@ def _helper(self, x0, y0, r, *, color, x_offset=0, y_offset=0,
130130
self._bitmap[x0+y+x_offset-line, y0-x] = color
131131
# pylint: enable=invalid-name, too-many-locals, too-many-branches
132132

133+
@property
134+
def fill(self):
135+
return self._palette[2]
136+
137+
@fill.setter
138+
def fill(self, color):
139+
if color is None:
140+
self._palette.make_transparent(2)
141+
else:
142+
self._palette[2] = color
143+
144+
@property
145+
def outline(self):
146+
return self._palette[1]
147+
148+
@outline.setter
149+
def outline(self, color):
150+
if color is None:
151+
self._palette.make_transparent(1)
152+
else:
153+
self._palette[1] = color
154+
155+
133156
@property
134157
def x(self):
135158
"""The x coordinate of the position"""

0 commit comments

Comments
 (0)