MCPcopy Create free account
hub / github.com/JoshuaPostel/texaform / Rect

Class Rect

python/utils.py:63–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62@dataclass
63class Rect:
64 top_left: Point
65 bot_right: Point
66
67 def height(self) -> int:
68 return self.bot_right.y - self.top_left.y
69
70 def width(self) -> int:
71 return self.bot_right.x - self.top_left.x
72
73 def contains(self, point: Point) -> bool:
74 x_contained = self.top_left.x <= point.x and point.x <= self.bot_right.x
75 y_contained = self.top_left.y <= point.y and point.y <= self.bot_right.y
76 return x_contained and y_contained
77
78 def random_point_inside(self) -> Point:
79 x = randint(self.top_left.x, self.bot_right.x)
80 y = randint(self.top_left.y, self.bot_right.y)
81 return Point(x, y)
82
83
84

Callers 4

__init__Method · 0.90
gather.pyFile · 0.90
__init__Method · 0.90
expand_areaMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected