Add Rect.from_raw_values

This commit is contained in:
Eryn Wells 2023-03-06 19:23:43 -08:00
parent edbc76d2ff
commit 040803fe61

View file

@ -163,11 +163,18 @@ class Size:
@dataclass
class Rect:
'''A two-dimensional rectangle, defined by an origin point and size'''
'''
A two-dimensional rectangle defined by an origin point and size
'''
origin: Point
size: Size
@staticmethod
def from_raw_values(x: int, y: int, width: int, height: int):
'''Create a rect from raw (unpacked from their struct) values'''
return Rect(Point(x, y), Size(width, height))
@property
def min_x(self) -> int:
'''Minimum x-value that is still within the bounds of this rectangle. This is the origin's x-value.'''