2323`roundrect`
2424================================================================================
2525
26- Various common shapes for use with displayio - Rounded Rectangle shape!
27-
28-
29- * Author(s): Limor Fried
30-
31- Implementation Notes
32- --------------------
33-
34- **Software and Dependencies:**
35-
36- * Adafruit CircuitPython firmware for the supported boards:
37- https://github.com/adafruit/circuitpython/releases
26+ A slightly modified version of Adafruit_CircuitPython_Display_Shapes that includes
27+ an explicit call to palette.make_opaque() in the fill color setter function.
3828
3929"""
4030
@@ -65,16 +55,18 @@ def __init__(self, x, y, width, height, r, *, fill=None, outline=None, stroke=1)
6555 self ._palette = displayio .Palette (3 )
6656 self ._palette .make_transparent (0 )
6757 self ._bitmap = displayio .Bitmap (width , height , 3 )
58+ for i in range (0 , width ): # draw the center chunk
59+ for j in range (r , height - r ): # draw the center chunk
60+ self ._bitmap [i , j ] = 2
61+ self ._helper (r , r , r , color = 2 , fill = True ,
62+ x_offset = width - 2 * r - 1 , y_offset = height - 2 * r - 1 )
6863
6964 if fill is not None :
70- for i in range (0 , width ): # draw the center chunk
71- for j in range (r , height - r ): # draw the center chunk
72- self ._bitmap [i , j ] = 2
73- self ._helper (r , r , r , color = 2 , fill = True ,
74- x_offset = width - 2 * r - 1 , y_offset = height - 2 * r - 1 )
7565 self ._palette [2 ] = fill
66+ self ._palette .make_opaque (2 )
7667 else :
7768 self ._palette .make_transparent (2 )
69+ self ._palette [2 ] = 0
7870
7971 if outline is not None :
8072 self ._palette [1 ] = outline
@@ -148,9 +140,11 @@ def fill(self):
148140 @fill .setter
149141 def fill (self , color ):
150142 if color is None :
143+ self ._palette [2 ] = 0
151144 self ._palette .make_transparent (2 )
152145 else :
153146 self ._palette [2 ] = color
147+ self ._palette .make_opaque (2 )
154148
155149 @property
156150 def outline (self ):
@@ -161,6 +155,8 @@ def outline(self):
161155 @outline .setter
162156 def outline (self , color ):
163157 if color is None :
158+ self ._palette [1 ] = 0
164159 self ._palette .make_transparent (1 )
165160 else :
166161 self ._palette [1 ] = color
162+ self ._palette .make_opaque (2 )
0 commit comments