diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index 9f65598..fd299ba 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -385,11 +385,16 @@ def anchored_position(self): if self._anchor_point is None: return None return ( - int(self.x + (self._anchor_point[0] * self._boundingbox[2] * self._scale)), int( - self.y - + (self._anchor_point[1] * self._boundingbox[3] * self._scale) - - round((self._boundingbox[3] * self._scale) / 2.0) + self.x + + round(self._anchor_point[0] * self._boundingbox[2] * self._scale) + ), + int( + round( + self.y + + (self._anchor_point[1] * self._boundingbox[3] * self._scale) + - ((self._boundingbox[3] * self._scale) / 2.0) + ) ), ) @@ -399,12 +404,14 @@ def anchored_position(self, new_position): return # Note: anchor_point must be set before setting anchored_position new_x = int( new_position[0] - - self._anchor_point[0] * (self._boundingbox[2] * self._scale) + - round(self._anchor_point[0] * (self._boundingbox[2] * self._scale)) ) new_y = int( - new_position[1] - - (self._anchor_point[1] * self._boundingbox[3] * self._scale) - + round((self._boundingbox[3] * self._scale) / 2.0) + round( + new_position[1] + - (self._anchor_point[1] * self._boundingbox[3] * self._scale) + + ((self._boundingbox[3] * self._scale) / 2.0) + ) ) self.x = new_x self.y = new_y