From c033675c02e841647938c89cd921a0790a3904b7 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Tue, 7 Jul 2020 11:03:00 -0500 Subject: [PATCH] fix anchored position getter and setter --- adafruit_display_text/label.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index 748cba8..4c29a99 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -351,15 +351,11 @@ def anchored_position(self): """Position relative to the anchor_point. Tuple containing x,y pixel coordinates.""" return ( - int( - self.x - + self._boundingbox[0] - + self._anchor_point[0] * self._boundingbox[2] - ), + int(self.x + (self._anchor_point[0] * self._boundingbox[2] * self._scale)), int( self.y - + self._boundingbox[1] - + self._anchor_point[1] * self._boundingbox[3] + + (self._anchor_point[1] * self._boundingbox[3] * self._scale) + - round((self._boundingbox[3] * self._scale) / 2.0) ), ) @@ -369,11 +365,10 @@ def anchored_position(self, new_position): new_position[0] - self._anchor_point[0] * (self._boundingbox[2] * self._scale) ) - new_y = self.y = int( + new_y = int( new_position[1] - - self._anchor_point[1] * (self._boundingbox[3] * self._scale) - + (self._boundingbox[3] * self._scale) / 2 + - (self._anchor_point[1] * self._boundingbox[3] * self._scale) + + round((self._boundingbox[3] * self._scale) / 2.0) ) - self._boundingbox = (new_x, new_y, self._boundingbox[2], self._boundingbox[3]) self.x = new_x self.y = new_y