Skip to content

Transfer the scale attribute down to the inner local_group and keep the scale of Label at 1 #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions adafruit_display_text/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ def __init__(
self._padding_left = padding_left
self._padding_right = padding_right

self._scale = scale

if text is not None:
self._update_text(str(text))
if (anchored_position is not None) and (anchor_point is not None):
Expand Down Expand Up @@ -389,12 +387,11 @@ def text(self, new_text):
@property
def scale(self):
"""Set the scaling of the label, in integer values"""
return self._scale
return self.local_group.scale

@scale.setter
def scale(self, new_scale):
current_anchored_position = self.anchored_position
self._scale = new_scale
self.local_group.scale = new_scale
self.anchored_position = current_anchored_position

Expand Down Expand Up @@ -438,13 +435,13 @@ def anchored_position(self):
return (
int(
self.x
+ (self._boundingbox[0] * self._scale)
+ round(self._anchor_point[0] * self._boundingbox[2] * self._scale)
+ (self._boundingbox[0] * self.scale)
+ round(self._anchor_point[0] * self._boundingbox[2] * self.scale)
),
int(
self.y
+ (self._boundingbox[1] * self._scale)
+ round(self._anchor_point[1] * self._boundingbox[3] * self._scale)
+ (self._boundingbox[1] * self.scale)
+ round(self._anchor_point[1] * self._boundingbox[3] * self.scale)
),
)

Expand All @@ -454,11 +451,11 @@ def anchored_position(self, new_position):
return # Note: anchor_point must be set before setting anchored_position
self.x = int(
new_position[0]
- (self._boundingbox[0] * self._scale)
- round(self._anchor_point[0] * (self._boundingbox[2] * self._scale))
- (self._boundingbox[0] * self.scale)
- round(self._anchor_point[0] * (self._boundingbox[2] * self.scale))
)
self.y = int(
new_position[1]
- (self._boundingbox[1] * self._scale)
- round(self._anchor_point[1] * self._boundingbox[3] * self._scale)
- (self._boundingbox[1] * self.scale)
- round(self._anchor_point[1] * self._boundingbox[3] * self.scale)
)