File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -572,6 +572,20 @@ def uv_to_position(self, uv: Point2) -> Vec2:
572572 x , y = uv
573573 return Vec2 (self .left + x * self .width , self .bottom + y * self .height )
574574
575+ def get_relative_to_anchor (self , point : Point2 , anchor : Vec2 = AnchorPoint .CENTER ) -> Vec2 :
576+ """Convert a point to a relative offset from the anchor point.
577+
578+ Args:
579+ point:
580+ The point to make relative.
581+ anchor:
582+ The anchor point to make the point relative to.
583+ """
584+ x , y = point
585+ rx = x - (self .left + (self .width * anchor .x ))
586+ ry = y - (self .bottom + (self .height * anchor .y ))
587+ return Vec2 (rx , ry )
588+
575589 def to_points (self ) -> tuple [Vec2 , Vec2 , Vec2 , Vec2 ]:
576590 """Return a new :py:class:`tuple` of this rectangle's corner points.
577591
You can’t perform that action at this time.
0 commit comments