Skip to content

Commit

Permalink
Add __bool__.
Browse files Browse the repository at this point in the history
  • Loading branch information
salt-die committed Dec 3, 2023
1 parent 32743e2 commit fadad71
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rects/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ def __sub__(self, other: Self) -> Self:
def __xor__(self, other: Self) -> Self:
return self._merge_regions(other, xor)

def __bool__(self):
"""Region is truthy if it is non-empty."""
return len(self.bands) > 0

def rects(self) -> Iterator[Rect]:
"""Yield all rects that make up the region."""
for band in self.bands:
Expand Down

0 comments on commit fadad71

Please sign in to comment.