METADATA 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. Metadata-Version: 2.4
  2. Name: PyRect
  3. Version: 0.2.0
  4. Summary: PyRect is a simple module with a Rect class for Pygame-like rectangular areas.
  5. Home-page: https://github.com/asweigart/pyrect
  6. Author: Al Sweigart
  7. Author-email: al@inventwithpython.com
  8. License: BSD
  9. Keywords: pygame rect rectangular rectangle area
  10. Classifier: Development Status :: 4 - Beta
  11. Classifier: Environment :: Win32 (MS Windows)
  12. Classifier: Environment :: MacOS X
  13. Classifier: Intended Audience :: Developers
  14. Classifier: License :: OSI Approved :: BSD License
  15. Classifier: Operating System :: OS Independent
  16. Classifier: Programming Language :: Python
  17. Classifier: Programming Language :: Python :: 2
  18. Classifier: Programming Language :: Python :: 2.5
  19. Classifier: Programming Language :: Python :: 2.6
  20. Classifier: Programming Language :: Python :: 2.7
  21. Classifier: Programming Language :: Python :: 3
  22. Classifier: Programming Language :: Python :: 3.1
  23. Classifier: Programming Language :: Python :: 3.2
  24. Classifier: Programming Language :: Python :: 3.3
  25. Classifier: Programming Language :: Python :: 3.4
  26. Classifier: Programming Language :: Python :: 3.5
  27. Classifier: Programming Language :: Python :: 3.6
  28. Classifier: Programming Language :: Python :: 3.7
  29. Classifier: Programming Language :: Python :: 3.8
  30. Classifier: Programming Language :: Python :: 3.9
  31. Classifier: Programming Language :: Python :: 3.10
  32. Classifier: Programming Language :: Python :: 3.11
  33. License-File: LICENSE.txt
  34. License-File: AUTHORS.txt
  35. Dynamic: author
  36. Dynamic: author-email
  37. Dynamic: classifier
  38. Dynamic: description
  39. Dynamic: home-page
  40. Dynamic: keywords
  41. Dynamic: license
  42. Dynamic: license-file
  43. Dynamic: summary
  44. ======
  45. PyRect
  46. ======
  47. PyRect is a simple module with a Rect class for Pygame-like rectangular areas.
  48. 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.
  49. Currently under development, though the basic features work.
  50. Installation
  51. ============
  52. ``pip install pyrect``
  53. Quickstart Guide
  54. ================
  55. First, create a Rect object by providing the XY coordinates of its top-left corner, and then the width and height:
  56. >>> import pyrect
  57. >>> r = pyrect.Rect(0, 0, 10, 20)
  58. There are several attributes that are automatically calculated (they have the same names as Pygame's Rect objects):
  59. >>> r.width, r.height, r.size
  60. (10, 20, (10, 20))
  61. >>> r. left
  62. 0
  63. >>> r.right
  64. 10
  65. >>> r.top
  66. 0
  67. >>> r.bottom
  68. 20
  69. >>> r.center
  70. (5, 10)
  71. >>> r.topleft
  72. (0, 0)
  73. >>> r.topright
  74. (10, 0)
  75. >>> r.midleft
  76. (0, 10)
  77. Changing these attributes re-calculates the others. The top-left corner is anchored for any growing or shrinking that takes place.
  78. >>> r.topleft
  79. (0, 0)
  80. >>> r.left = 100
  81. >>> r.topleft
  82. (100, 0)
  83. >>> r.topright
  84. (110, 0)
  85. >>> r.width = 30
  86. >>> r.topright
  87. (130, 0)
  88. Rect objects are locked to integers, unless you set `enableFloat` to `True`:
  89. >>> r = pyrect.Rect(0, 0, 10, 20)
  90. >>> r.width = 10.5
  91. >>> r.width
  92. 10
  93. >>> r.enableFloat = True
  94. >>> r.width = 10.5
  95. >>> r.width
  96. 10.5
  97. >>> r2 = pyrect.Rect(0, 0, 10.5, 20.5, enableFloat=True)
  98. >>> r2.size
  99. (10.5, 20.5)
  100. Rect Attributes
  101. ===============
  102. Rect objects have several attributes that can be read or modified. They are identical to Pygame's Rect objects:
  103. ``x, y``
  104. ``top, left, bottom, right``
  105. ``topleft, bottomleft, topright, bottomright``
  106. ``midtop, midleft, midbottom, midright``
  107. ``center, centerx, centery``
  108. ``size, width, height``
  109. ``w, h``
  110. There are a couple other attributes as well:
  111. ``box (a tuple (left, top, width, height))``
  112. ``area (read-only)``
  113. ``perimeter (read-only)``