@@ -66,6 +66,9 @@ def __init__(self, font, *, text=None, max_glyphs=None, color=0xffffff,
6666 self .width = max_glyphs
6767 self .font = font
6868 self ._text = None
69+ self ._anchor_point = (0 , 0 )
70+ self .x = 0
71+ self .y = 0
6972
7073 self .palette = displayio .Palette (2 )
7174 self .palette .make_transparent (0 )
@@ -173,3 +176,26 @@ def text(self):
173176 @text .setter
174177 def text (self , new_text ):
175178 self ._update_text (new_text )
179+
180+ @property
181+ def anchor_point (self ):
182+ """Point that anchored_position moves relative to.
183+ Tuple with decimal percentage of width and height.
184+ (E.g. (0,0) is top left, (1.0, 0.5): is middle right.)"""
185+ return self ._anchor_point
186+
187+ @anchor_point .setter
188+ def anchor_point (self , new_anchor_point ):
189+ self ._anchor_point = new_anchor_point
190+
191+ @property
192+ def anchored_position (self ):
193+ """Position relative to the anchor_point. Tuple containing x,y
194+ pixel coordinates."""
195+ return (self .x - self ._boundingbox [2 ]* self ._anchor_point [0 ],
196+ self .y - self ._boundingbox [3 ]* self ._anchor_point [1 ])
197+
198+ @anchored_position .setter
199+ def anchored_position (self , new_position ):
200+ self .x = int (new_position [0 ]- (self ._boundingbox [2 ]* self ._anchor_point [0 ]))
201+ self .y = int (new_position [1 ]- (self ._boundingbox [3 ]* self ._anchor_point [1 ]))
0 commit comments