Add Rect.edges
Iterates the minimum and maximum x and y edges for the Rect.
This commit is contained in:
parent
e6c4717e80
commit
633580e27a
1 changed files with 10 additions and 0 deletions
|
@ -186,6 +186,16 @@ class Rect:
|
|||
'''A Point in the middle of the Rect'''
|
||||
return Point(self.mid_x, self.mid_y)
|
||||
|
||||
@property
|
||||
def edges(self) -> Iterator[int]:
|
||||
'''
|
||||
An iterator over the edges of this Rect in the order of: `min_x`, `max_x`, `min_y`, `max_y`.
|
||||
'''
|
||||
yield self.min_x
|
||||
yield self.max_x
|
||||
yield self.min_y
|
||||
yield self.max_y
|
||||
|
||||
def intersects(self, other: 'Rect') -> bool:
|
||||
'''Returns `True` if `other` intersects this Rect.'''
|
||||
if other.min_x > self.max_x:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue