From 2b87870083fd8b5e0921f98975aa96486901ddf2 Mon Sep 17 00:00:00 2001 From: empirical-dan <52764820+empirical-dan@users.noreply.github.com> Date: Tue, 20 Apr 2021 21:30:32 +0100 Subject: [PATCH 1/2] Update circle.py Added x0, y0, the co-ordinates of the centre of the circle. Only r, radius added to Circle object to save space. Properties added for x0, y0. Setters also added so that the Circle object can be moved with reference to its center. --- adafruit_display_shapes/circle.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/adafruit_display_shapes/circle.py b/adafruit_display_shapes/circle.py index ce985bb..cd8e6bc 100644 --- a/adafruit_display_shapes/circle.py +++ b/adafruit_display_shapes/circle.py @@ -53,3 +53,22 @@ def __init__(self, x0, y0, r, *, fill=None, outline=None, stroke=1): outline=outline, stroke=stroke, ) + self.r = r + + @property + def x0(self): + """The x-position of the center of the circle.""" + return self.x + self.r + + @property + def y0(self): + """The y-position of the center of the circle.""" + return self.y + self.r + + @x0.setter + def x0(self, x0): + self.x = x0 - self.r + + @y0.setter + def y0(self, y0): + self.y = y0 - self.r From beefd49868cafe9051de44979c0acf539853ba93 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Wed, 21 Apr 2021 08:07:02 -0500 Subject: [PATCH 2/2] ran black for formatting updates --- adafruit_display_shapes/circle.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_display_shapes/circle.py b/adafruit_display_shapes/circle.py index cd8e6bc..c7636d5 100644 --- a/adafruit_display_shapes/circle.py +++ b/adafruit_display_shapes/circle.py @@ -54,21 +54,21 @@ def __init__(self, x0, y0, r, *, fill=None, outline=None, stroke=1): stroke=stroke, ) self.r = r - + @property def x0(self): """The x-position of the center of the circle.""" return self.x + self.r - + @property def y0(self): """The y-position of the center of the circle.""" return self.y + self.r - + @x0.setter def x0(self, x0): self.x = x0 - self.r - + @y0.setter def y0(self, y0): self.y = y0 - self.r