Skip to content

Commit 68aad7c

Browse files
authored
Merge pull request #116 from lesamouraipourpre/master
Transfer the scale attribute down to the inner local_group and keep the scale of Label at 1
2 parents 474dc07 + 9871e18 commit 68aad7c

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

adafruit_display_text/label.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ def __init__(
130130
self._padding_left = padding_left
131131
self._padding_right = padding_right
132132

133-
self._scale = scale
134-
135133
if text is not None:
136134
self._update_text(str(text))
137135
if (anchored_position is not None) and (anchor_point is not None):
@@ -389,12 +387,11 @@ def text(self, new_text):
389387
@property
390388
def scale(self):
391389
"""Set the scaling of the label, in integer values"""
392-
return self._scale
390+
return self.local_group.scale
393391

394392
@scale.setter
395393
def scale(self, new_scale):
396394
current_anchored_position = self.anchored_position
397-
self._scale = new_scale
398395
self.local_group.scale = new_scale
399396
self.anchored_position = current_anchored_position
400397

@@ -438,13 +435,13 @@ def anchored_position(self):
438435
return (
439436
int(
440437
self.x
441-
+ (self._boundingbox[0] * self._scale)
442-
+ round(self._anchor_point[0] * self._boundingbox[2] * self._scale)
438+
+ (self._boundingbox[0] * self.scale)
439+
+ round(self._anchor_point[0] * self._boundingbox[2] * self.scale)
443440
),
444441
int(
445442
self.y
446-
+ (self._boundingbox[1] * self._scale)
447-
+ round(self._anchor_point[1] * self._boundingbox[3] * self._scale)
443+
+ (self._boundingbox[1] * self.scale)
444+
+ round(self._anchor_point[1] * self._boundingbox[3] * self.scale)
448445
),
449446
)
450447

@@ -454,11 +451,11 @@ def anchored_position(self, new_position):
454451
return # Note: anchor_point must be set before setting anchored_position
455452
self.x = int(
456453
new_position[0]
457-
- (self._boundingbox[0] * self._scale)
458-
- round(self._anchor_point[0] * (self._boundingbox[2] * self._scale))
454+
- (self._boundingbox[0] * self.scale)
455+
- round(self._anchor_point[0] * (self._boundingbox[2] * self.scale))
459456
)
460457
self.y = int(
461458
new_position[1]
462-
- (self._boundingbox[1] * self._scale)
463-
- round(self._anchor_point[1] * self._boundingbox[3] * self._scale)
459+
- (self._boundingbox[1] * self.scale)
460+
- round(self._anchor_point[1] * self._boundingbox[3] * self.scale)
464461
)

0 commit comments

Comments
 (0)