Skip to content

Commit 2b87870

Browse files
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.
1 parent 5d8bffe commit 2b87870

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

adafruit_display_shapes/circle.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,22 @@ def __init__(self, x0, y0, r, *, fill=None, outline=None, stroke=1):
5353
outline=outline,
5454
stroke=stroke,
5555
)
56+
self.r = r
57+
58+
@property
59+
def x0(self):
60+
"""The x-position of the center of the circle."""
61+
return self.x + self.r
62+
63+
@property
64+
def y0(self):
65+
"""The y-position of the center of the circle."""
66+
return self.y + self.r
67+
68+
@x0.setter
69+
def x0(self, x0):
70+
self.x = x0 - self.r
71+
72+
@y0.setter
73+
def y0(self, y0):
74+
self.y = y0 - self.r

0 commit comments

Comments
 (0)