@@ -174,19 +174,26 @@ def text(self, new_text):
174
174
self ._update_text (new_text )
175
175
176
176
@property
177
- def cx (self ):
178
- """Center X of the Label """
179
- return self .x + self ._boundingbox [2 ]/ 2
180
-
181
- @property
182
- def cy (self ):
183
- """Center Y of the Label """
184
- return self .y + self ._boundingbox [3 ]/ 2
185
-
186
- @cx .setter
187
- def cx (self , new_cx ):
188
- self .x = int (new_cx - (self ._boundingbox [2 ]/ 2 ))
189
-
190
- @cy .setter
191
- def cy (self , new_cy ):
192
- self .y = int (new_cy - (self ._boundingbox [3 ]/ 2 ))
177
+ def anchor_point (self ):
178
+ """Point that anchored_position moves relative to.
179
+ Tuple with decimal percentage of width and height.
180
+ (E.g. (0,0) is top left, (1.0, 0.5): is middle right.)"""
181
+ return self ._anchor_point
182
+
183
+ @anchor_point .setter
184
+ def anchor_point (self , new_anchor_point ):
185
+ self ._anchor_point = new_anchor_point
186
+
187
+ @property
188
+ def anchored_position (self ):
189
+ """Position relative to the anchor_point. Tuple containing x,y
190
+ pixel coordinates."""
191
+ _anchored_position = (
192
+ self .x - self ._boundingbox [2 ]* self ._anchor_point [0 ],
193
+ self .y - self ._boundingbox [3 ]* self ._anchor_point [1 ])
194
+ return _anchored_position
195
+
196
+ @anchored_position .setter
197
+ def anchored_position (self , new_position ):
198
+ self .x = int (new_position [0 ]- (self ._boundingbox [2 ]* self ._anchor_point [0 ]))
199
+ self .y = int (new_position [1 ]- (self ._boundingbox [3 ]* self ._anchor_point [1 ]))
0 commit comments