Skip to content
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
14 changes: 14 additions & 0 deletions arcade/types/rect.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,20 @@ def uv_to_position(self, uv: Point2) -> Vec2:
x, y = uv
return Vec2(self.left + x * self.width, self.bottom + y * self.height)

def get_relative_to_anchor(self, point: Point2, anchor: Vec2 = AnchorPoint.CENTER) -> Vec2:
"""Convert a point to a relative offset from the anchor point.

Args:
point:
The point to make relative.
anchor:
The anchor point to make the point relative to.
"""
x, y = point
rx = x - (self.left + (self.width * anchor.x))
ry = y - (self.bottom + (self.height * anchor.y))
return Vec2(rx, ry)

def to_points(self) -> tuple[Vec2, Vec2, Vec2, Vec2]:
"""Return a new :py:class:`tuple` of this rectangle's corner points.

Expand Down
Loading