From e9850a093463581853affc48c3d1ef6623dbc6cf Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 27 Nov 2021 12:30:04 -0600 Subject: [PATCH] add height and width properties for Rect and RoundRect --- adafruit_display_shapes/rect.py | 14 ++++++++++++++ adafruit_display_shapes/roundrect.py | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/adafruit_display_shapes/rect.py b/adafruit_display_shapes/rect.py index 8ced77d..3f051eb 100644 --- a/adafruit_display_shapes/rect.py +++ b/adafruit_display_shapes/rect.py @@ -95,3 +95,17 @@ def outline(self, color): else: self._palette[1] = color self._palette.make_opaque(1) + + @property + def width(self) -> int: + """ + :return: the width of the rectangle in pixels + """ + return self._bitmap.width + + @property + def height(self) -> int: + """ + :return: the height of the rectangle in pixels + """ + return self._bitmap.height diff --git a/adafruit_display_shapes/roundrect.py b/adafruit_display_shapes/roundrect.py index 82ea8b6..0df799b 100644 --- a/adafruit_display_shapes/roundrect.py +++ b/adafruit_display_shapes/roundrect.py @@ -170,3 +170,17 @@ def outline(self, color): else: self._palette[1] = color self._palette.make_opaque(2) + + @property + def width(self) -> int: + """ + :return: the width of the rounded rectangle in pixels + """ + return self._bitmap.width + + @property + def height(self) -> int: + """ + :return: the height of the rounded rectangle in pixels + """ + return self._bitmap.height