From 040803fe619a8f141718bd2960c74eb341270ed9 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Mon, 6 Mar 2023 19:23:43 -0800 Subject: [PATCH] Add Rect.from_raw_values --- erynrl/geometry.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erynrl/geometry.py b/erynrl/geometry.py index acb1584..050222f 100644 --- a/erynrl/geometry.py +++ b/erynrl/geometry.py @@ -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.'''