Skip to main content

PyRect is a simple module with a Rect class for Pygame-like rectangular areas.

Project description

PyRect is a simple module with a Rect class for Pygame-like rectangular areas.

This module is like a stand-alone version of Pygame’s Rect class. It is similar to the Rect module by Simon Wittber, but compatible with both Python 2 and 3.

Currently under development, though the basic features work.

Examples

>>> import pyrect
>>> rectangle = pyrect.Rect(0, 0, 20, 10)
>>> rectangle.topleft
(0, 0)
>>> rectangle.bottomright
(20, 10)
>>> rectangle.width
20
>>> rectangle.height
10
>>> rectangle.width = 100 # updating one attribute automatically updates all the others
>>> rectangle.bottomright
(100, 10)
>>> rectangle.left = 50
>>> rectangle.topleft
(50, 0)
>>> rectangle.bottomright
(150, 10)
>>> rectangle.box # the box tuple shows (left, top, width, height)
(50, 0, 100, 10)
>>> floatRectangle = pyrect.Rect(0, 0.2, 20.4, 10.6, enableFloat=True) # allow float values
>>> floatRectangle.box
(0.0, 0.2, 20.4, 10.6)
>>> intRectangle = pyrect.Rect(0, 0.2, 20.4, 10.6) # integers-only by default
>>> intRectangle.box
(0, 0, 20, 10)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyRect-0.0.1.tar.gz (7.9 kB view details)

Uploaded Source

File details

Details for the file PyRect-0.0.1.tar.gz.

File metadata

  • Download URL: PyRect-0.0.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyRect-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4b66c0cf8aaab222d093ce5b9a6f87aefb12b1ca3341eaef107010c011ac60a3
MD5 3eb4cddfdbf2cb633ae3dda71d637c1e
BLAKE2b-256 a9708d3c38490b1bce8a65dc264188ec26a692a216254830fe6c839c703ed181

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page