23
23
`roundrect`
24
24
================================================================================
25
25
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.
38
28
39
29
"""
40
30
@@ -65,16 +55,18 @@ def __init__(self, x, y, width, height, r, *, fill=None, outline=None, stroke=1)
65
55
self ._palette = displayio .Palette (3 )
66
56
self ._palette .make_transparent (0 )
67
57
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 )
68
63
69
64
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 )
75
65
self ._palette [2 ] = fill
66
+ self ._palette .make_opaque (2 )
76
67
else :
77
68
self ._palette .make_transparent (2 )
69
+ self ._palette [2 ] = 0
78
70
79
71
if outline is not None :
80
72
self ._palette [1 ] = outline
@@ -148,9 +140,11 @@ def fill(self):
148
140
@fill .setter
149
141
def fill (self , color ):
150
142
if color is None :
143
+ self ._palette [2 ] = 0
151
144
self ._palette .make_transparent (2 )
152
145
else :
153
146
self ._palette [2 ] = color
147
+ self ._palette .make_opaque (2 )
154
148
155
149
@property
156
150
def outline (self ):
@@ -161,6 +155,8 @@ def outline(self):
161
155
@outline .setter
162
156
def outline (self , color ):
163
157
if color is None :
158
+ self ._palette [1 ] = 0
164
159
self ._palette .make_transparent (1 )
165
160
else :
166
161
self ._palette [1 ] = color
162
+ self ._palette .make_opaque (2 )
0 commit comments