Skip to content

Commit 0b524cf

Browse files
author
Margaret Matocha
committed
Updated anchored_position getter/setter
1 parent 11b6fcb commit 0b524cf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

adafruit_display_text/label.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,10 @@ def anchored_position(self):
351351
"""Position relative to the anchor_point. Tuple containing x,y
352352
pixel coordinates."""
353353
return (
354-
int(self.x + self._anchor_point[0] * self._boundingbox[2]),
355-
int(self.y + self._anchor_point[1] * self._boundingbox[3]),
356-
)
354+
int(self.x + self._anchor_point[0] * self._boundingbox[2] * self._scale ),
355+
int(self.y + self._anchor_point[1] * self._boundingbox[3] * self._scale
356+
- (self._boundingbox[3] * self._scale)/2 )
357+
)
357358

358359
@anchored_position.setter
359360
def anchored_position(self, new_position):
@@ -364,6 +365,7 @@ def anchored_position(self, new_position):
364365
new_y = self.y = int(
365366
new_position[1]
366367
- self._anchor_point[1] * (self._boundingbox[3] * self._scale)
368+
+ (self._boundingbox[3] * self._scale)/2
367369
)
368370
self._boundingbox = (new_x, new_y, self._boundingbox[2], self._boundingbox[3])
369371
self.x = new_x

0 commit comments

Comments
 (0)