ipygame.rect
pygame-compatible Rect and FRect classes.
Rect Objects
Section titled “Rect Objects”class Rect()Stores rectangular coordinates (int).
__init__
Section titled “__init__”def __init__(*args)@propertydef x() -> int@x.setterdef x(v: int) -> None@propertydef y() -> int@y.setterdef y(v: int) -> None@propertydef w() -> int@w.setterdef w(v: int) -> None@propertydef h() -> int@h.setterdef h(v: int) -> Nonewidth = wheight
Section titled “height”height = h@propertydef width() -> int@width.setterdef width(v: int) -> Noneheight
Section titled “height”@propertydef height() -> intheight
Section titled “height”@height.setterdef height(v: int) -> None@propertydef size() -> tuple[int, int]@size.setterdef size(v: tuple[int, int]) -> None@propertydef top() -> int@top.setterdef top(v: int) -> None@propertydef left() -> int@left.setterdef left(v: int) -> Nonebottom
Section titled “bottom”@propertydef bottom() -> intbottom
Section titled “bottom”@bottom.setterdef bottom(v: int) -> None@propertydef right() -> int@right.setterdef right(v: int) -> Nonetopleft
Section titled “topleft”@propertydef topleft() -> tuple[int, int]topleft
Section titled “topleft”@topleft.setterdef topleft(v: tuple[int, int]) -> Nonetopright
Section titled “topright”@propertydef topright() -> tuple[int, int]topright
Section titled “topright”@topright.setterdef topright(v: tuple[int, int]) -> Nonebottomleft
Section titled “bottomleft”@propertydef bottomleft() -> tuple[int, int]bottomleft
Section titled “bottomleft”@bottomleft.setterdef bottomleft(v: tuple[int, int]) -> Nonebottomright
Section titled “bottomright”@propertydef bottomright() -> tuple[int, int]bottomright
Section titled “bottomright”@bottomright.setterdef bottomright(v: tuple[int, int]) -> Nonecenterx
Section titled “centerx”@propertydef centerx() -> intcenterx
Section titled “centerx”@centerx.setterdef centerx(v: int) -> Nonecentery
Section titled “centery”@propertydef centery() -> intcentery
Section titled “centery”@centery.setterdef centery(v: int) -> Nonecenter
Section titled “center”@propertydef center() -> tuple[int, int]center
Section titled “center”@center.setterdef center(v: tuple[int, int]) -> Nonemidtop
Section titled “midtop”@propertydef midtop() -> tuple[int, int]midtop
Section titled “midtop”@midtop.setterdef midtop(v: tuple[int, int]) -> Nonemidbottom
Section titled “midbottom”@propertydef midbottom() -> tuple[int, int]midbottom
Section titled “midbottom”@midbottom.setterdef midbottom(v: tuple[int, int]) -> Nonemidleft
Section titled “midleft”@propertydef midleft() -> tuple[int, int]midleft
Section titled “midleft”@midleft.setterdef midleft(v: tuple[int, int]) -> Nonemidright
Section titled “midright”@propertydef midright() -> tuple[int, int]midright
Section titled “midright”@midright.setterdef midright(v: tuple[int, int]) -> Nonedef move(x: int, y: int) -> Rectmove_ip
Section titled “move_ip”def move_ip(x: int, y: int) -> Nonemove_to
Section titled “move_to”def move_to(**kwargs) -> Rectinflate
Section titled “inflate”def inflate(x: int, y: int) -> Rectinflate_ip
Section titled “inflate_ip”def inflate_ip(x: int, y: int) -> Nonescale_by
Section titled “scale_by”def scale_by(sx: float, sy: float | None = None) -> Rectscale_by_ip
Section titled “scale_by_ip”def scale_by_ip(sx: float, sy: float | None = None) -> Noneupdate
Section titled “update”def update(*args) -> Nonenormalize
Section titled “normalize”def normalize() -> Nonedef clamp(other) -> Rectclamp_ip
Section titled “clamp_ip”def clamp_ip(other) -> Nonedef clip(other) -> Rectclipline
Section titled “clipline”def clipline(*args) -> tuple[tuple[int, int], tuple[int, int]] | tuple[()]Cohen-Sutherland line clipping.
def union(other) -> Rectunion_ip
Section titled “union_ip”def union_ip(other) -> Noneunionall
Section titled “unionall”def unionall(others: Sequence) -> Rectunionall_ip
Section titled “unionall_ip”def unionall_ip(others: Sequence) -> Nonedef fit(other) -> RectScale and center self to fit inside other, preserving aspect ratio.
contains
Section titled “contains”def contains(other) -> boolcollidepoint
Section titled “collidepoint”def collidepoint(*args) -> boolcolliderect
Section titled “colliderect”def colliderect(other) -> boolcollidelist
Section titled “collidelist”def collidelist(rects: Sequence) -> intcollidelistall
Section titled “collidelistall”def collidelistall(rects: Sequence) -> list[int]collidedict
Section titled “collidedict”def collidedict(d: dict, use_values: bool = True) -> tuple | Nonecollidedictall
Section titled “collidedictall”def collidedictall(d: dict, use_values: bool = True) -> list[tuple]collideobjects
Section titled “collideobjects”def collideobjects(objects, key=None)collideobjectsall
Section titled “collideobjectsall”def collideobjectsall(objects, key=None) -> listdef copy() -> RectFRect Objects
Section titled “FRect Objects”class FRect()Stores rectangular coordinates (float).
__init__
Section titled “__init__”def __init__(*args)@propertydef x() -> float@x.setterdef x(v) -> None@propertydef y() -> float@y.setterdef y(v) -> None@propertydef w() -> float@w.setterdef w(v) -> None@propertydef h() -> float@h.setterdef h(v) -> None@propertydef width() -> float@width.setterdef width(v) -> Noneheight
Section titled “height”@propertydef height() -> floatheight
Section titled “height”@height.setterdef height(v) -> None@propertydef size() -> tuple[float, float]@size.setterdef size(v) -> None@propertydef top() -> float@top.setterdef top(v) -> None@propertydef left() -> float@left.setterdef left(v) -> Nonebottom
Section titled “bottom”@propertydef bottom() -> floatbottom
Section titled “bottom”@bottom.setterdef bottom(v) -> None@propertydef right() -> float@right.setterdef right(v) -> Nonetopleft
Section titled “topleft”@propertydef topleft() -> tuple[float, float]topleft
Section titled “topleft”@topleft.setterdef topleft(v) -> Nonetopright
Section titled “topright”@propertydef topright() -> tuple[float, float]topright
Section titled “topright”@topright.setterdef topright(v) -> Nonebottomleft
Section titled “bottomleft”@propertydef bottomleft() -> tuple[float, float]bottomleft
Section titled “bottomleft”@bottomleft.setterdef bottomleft(v) -> Nonebottomright
Section titled “bottomright”@propertydef bottomright() -> tuple[float, float]bottomright
Section titled “bottomright”@bottomright.setterdef bottomright(v) -> Nonecenterx
Section titled “centerx”@propertydef centerx() -> floatcenterx
Section titled “centerx”@centerx.setterdef centerx(v) -> Nonecentery
Section titled “centery”@propertydef centery() -> floatcentery
Section titled “centery”@centery.setterdef centery(v) -> Nonecenter
Section titled “center”@propertydef center() -> tuple[float, float]center
Section titled “center”@center.setterdef center(v) -> Nonemidtop
Section titled “midtop”@propertydef midtop() -> tuple[float, float]midtop
Section titled “midtop”@midtop.setterdef midtop(v) -> Nonemidbottom
Section titled “midbottom”@propertydef midbottom() -> tuple[float, float]midbottom
Section titled “midbottom”@midbottom.setterdef midbottom(v) -> Nonemidleft
Section titled “midleft”@propertydef midleft() -> tuple[float, float]midleft
Section titled “midleft”@midleft.setterdef midleft(v) -> Nonemidright
Section titled “midright”@propertydef midright() -> tuple[float, float]midright
Section titled “midright”@midright.setterdef midright(v) -> Nonedef move(x, y) -> FRectmove_ip
Section titled “move_ip”def move_ip(x, y) -> Nonemove_to
Section titled “move_to”def move_to(**kwargs) -> FRectinflate
Section titled “inflate”def inflate(x, y) -> FRectinflate_ip
Section titled “inflate_ip”def inflate_ip(x, y) -> Nonescale_by
Section titled “scale_by”def scale_by(sx, sy=None) -> FRectscale_by_ip
Section titled “scale_by_ip”def scale_by_ip(sx, sy=None) -> Noneupdate
Section titled “update”def update(*args) -> Nonenormalize
Section titled “normalize”def normalize() -> Nonedef clamp(other) -> FRectclamp_ip
Section titled “clamp_ip”def clamp_ip(other) -> Nonedef clip(other) -> FRectdef union(other) -> FRectunion_ip
Section titled “union_ip”def union_ip(other) -> Noneunionall
Section titled “unionall”def unionall(others) -> FRectunionall_ip
Section titled “unionall_ip”def unionall_ip(others) -> Nonedef fit(other) -> FRectcontains
Section titled “contains”def contains(other) -> boolcollidepoint
Section titled “collidepoint”def collidepoint(*args) -> boolcolliderect
Section titled “colliderect”def colliderect(other) -> boolcollidelist
Section titled “collidelist”def collidelist(rects) -> intcollidelistall
Section titled “collidelistall”def collidelistall(rects) -> list[int]def copy() -> FRect