Add Rect.from_raw_values
This commit is contained in:
parent
edbc76d2ff
commit
040803fe61
1 changed files with 8 additions and 1 deletions
|
@ -163,11 +163,18 @@ class Size:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Rect:
|
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
|
origin: Point
|
||||||
size: Size
|
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
|
@property
|
||||||
def min_x(self) -> int:
|
def min_x(self) -> int:
|
||||||
'''Minimum x-value that is still within the bounds of this rectangle. This is the origin's x-value.'''
|
'''Minimum x-value that is still within the bounds of this rectangle. This is the origin's x-value.'''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue