diff --git a/adafruit_display_shapes/rect.py b/adafruit_display_shapes/rect.py index 0ea637a..4eecacc 100755 --- a/adafruit_display_shapes/rect.py +++ b/adafruit_display_shapes/rect.py @@ -76,7 +76,9 @@ def __init__(self, x, y, width, height, *, fill=None, outline=None, stroke=1): if fill is not None: self._palette[0] = fill + self._palette.make_opaque(0) else: + self._palette[0] = 0 self._palette.make_transparent(0) super().__init__(self._bitmap, pixel_shader=self._palette, x=x, y=y) @@ -89,9 +91,11 @@ def fill(self): @fill.setter def fill(self, color): if color is None: + self._palette[0] = 0 self._palette.make_transparent(0) else: self._palette[0] = color + self._palette.make_opaque(0) @property def outline(self): @@ -102,6 +106,8 @@ def outline(self): @outline.setter def outline(self, color): if color is None: + self._palette[1] = 0 self._palette.make_transparent(1) else: self._palette[1] = color + self._palette.make_opaque(1) diff --git a/adafruit_display_shapes/roundrect.py b/adafruit_display_shapes/roundrect.py index 0fca3d2..8f923e2 100755 --- a/adafruit_display_shapes/roundrect.py +++ b/adafruit_display_shapes/roundrect.py @@ -23,18 +23,8 @@ `roundrect` ================================================================================ -Various common shapes for use with displayio - Rounded Rectangle shape! - - -* Author(s): Limor Fried - -Implementation Notes --------------------- - -**Software and Dependencies:** - -* Adafruit CircuitPython firmware for the supported boards: - https://github.com/adafruit/circuitpython/releases +A slightly modified version of Adafruit_CircuitPython_Display_Shapes that includes +an explicit call to palette.make_opaque() in the fill color setter function. """ @@ -65,16 +55,18 @@ def __init__(self, x, y, width, height, r, *, fill=None, outline=None, stroke=1) self._palette = displayio.Palette(3) self._palette.make_transparent(0) self._bitmap = displayio.Bitmap(width, height, 3) + for i in range(0, width): # draw the center chunk + for j in range(r, height - r): # draw the center chunk + self._bitmap[i, j] = 2 + self._helper(r, r, r, color=2, fill=True, + x_offset=width-2*r-1, y_offset=height-2*r-1) if fill is not None: - for i in range(0, width): # draw the center chunk - for j in range(r, height - r): # draw the center chunk - self._bitmap[i, j] = 2 - self._helper(r, r, r, color=2, fill=True, - x_offset=width-2*r-1, y_offset=height-2*r-1) self._palette[2] = fill + self._palette.make_opaque(2) else: self._palette.make_transparent(2) + self._palette[2] = 0 if outline is not None: self._palette[1] = outline @@ -148,9 +140,11 @@ def fill(self): @fill.setter def fill(self, color): if color is None: + self._palette[2] = 0 self._palette.make_transparent(2) else: self._palette[2] = color + self._palette.make_opaque(2) @property def outline(self): @@ -161,6 +155,8 @@ def outline(self): @outline.setter def outline(self, color): if color is None: + self._palette[1] = 0 self._palette.make_transparent(1) else: self._palette[1] = color + self._palette.make_opaque(2) diff --git a/adafruit_display_shapes/triangle.py b/adafruit_display_shapes/triangle.py index bde221c..6d1a623 100755 --- a/adafruit_display_shapes/triangle.py +++ b/adafruit_display_shapes/triangle.py @@ -89,7 +89,7 @@ def __init__(self, x0, y0, x1, y1, x2, y2, *, fill=None, outline=None): self._palette.make_transparent(2) if outline is not None: - print("outline") + # print("outline") self._palette[1] = outline self._line(x0 - min(xs), 0, x1 - min(xs), y1 - y0, 1) self._line(x1 - min(xs), y1 - y0, x2 - min(xs), y2 - y0, 1) @@ -186,9 +186,11 @@ def fill(self): @fill.setter def fill(self, color): if color is None: + self._palette[2] = 0 self._palette.make_transparent(2) else: self._palette[2] = color + self._palette.make_opaque(2) @property def outline(self): @@ -199,6 +201,8 @@ def outline(self): @outline.setter def outline(self, color): if color is None: + self._palette[1] = 0 self._palette.make_transparent(1) else: self._palette[1] = color + self._palette.make_opaque(1)