PyRect is a simple module that provides a `Rect` class, mimicking the functionality of Pygame's `Rect` objects for handling rectangular areas. It is designed to be a standalone, lightweight solution for geometric operations. The current version is 0.2.0, released in March 2022, indicating an infrequent release cadence.
pip install pyrectVerified import paths — ran on the pinned version, not inferred.
Create a Rect object with x, y, width, and height. Access various calculated attributes like topleft, center, and size. Demonstrate moving a rectangle (which returns a new object) versus modifying its attributes in-place. Also shows how to enable float coordinates.
To enable float coordinates, create the Rect object with `enableFloat=True` (e.g., `Rect(x, y, w, h, enableFloat=True)`) or set `rect.enableFloat = True` on an existing object.
If you intend to modify the rectangle in-place, use the `_ip` suffix methods (e.g., `move_ip()`, `inflate_ip()`) or directly assign to attributes like `rect.x`, `rect.y`, `rect.width`, `rect.height`.
Be aware of this anchoring behavior when performing resizing operations. If a different anchor point is desired, you will need to manually adjust the `topleft` coordinates after resizing.
pip install pyrect
from pyrect import Rect
my_rect = Rect(10, 20, 100, 50)
my_rect = Rect(10, 20, 100, 50) print(my_rect.width)
No dependency data recorded yet.