First Commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,141 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: PyRect
|
||||
Version: 0.2.0
|
||||
Summary: PyRect is a simple module with a Rect class for Pygame-like rectangular areas.
|
||||
Home-page: https://github.com/asweigart/pyrect
|
||||
Author: Al Sweigart
|
||||
Author-email: al@inventwithpython.com
|
||||
License: BSD
|
||||
Keywords: pygame rect rectangular rectangle area
|
||||
Classifier: Development Status :: 4 - Beta
|
||||
Classifier: Environment :: Win32 (MS Windows)
|
||||
Classifier: Environment :: MacOS X
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.5
|
||||
Classifier: Programming Language :: Python :: 2.6
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.1
|
||||
Classifier: Programming Language :: Python :: 3.2
|
||||
Classifier: Programming Language :: Python :: 3.3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Programming Language :: Python :: 3.7
|
||||
Classifier: Programming Language :: Python :: 3.8
|
||||
Classifier: Programming Language :: Python :: 3.9
|
||||
Classifier: Programming Language :: Python :: 3.10
|
||||
Classifier: Programming Language :: Python :: 3.11
|
||||
License-File: LICENSE.txt
|
||||
License-File: AUTHORS.txt
|
||||
Dynamic: author
|
||||
Dynamic: author-email
|
||||
Dynamic: classifier
|
||||
Dynamic: description
|
||||
Dynamic: home-page
|
||||
Dynamic: keywords
|
||||
Dynamic: license
|
||||
Dynamic: license-file
|
||||
Dynamic: summary
|
||||
|
||||
======
|
||||
PyRect
|
||||
======
|
||||
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.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
``pip install pyrect``
|
||||
|
||||
Quickstart Guide
|
||||
================
|
||||
|
||||
First, create a Rect object by providing the XY coordinates of its top-left corner, and then the width and height:
|
||||
|
||||
>>> import pyrect
|
||||
>>> r = pyrect.Rect(0, 0, 10, 20)
|
||||
|
||||
There are several attributes that are automatically calculated (they have the same names as Pygame's Rect objects):
|
||||
|
||||
>>> r.width, r.height, r.size
|
||||
(10, 20, (10, 20))
|
||||
>>> r. left
|
||||
0
|
||||
>>> r.right
|
||||
10
|
||||
>>> r.top
|
||||
0
|
||||
>>> r.bottom
|
||||
20
|
||||
>>> r.center
|
||||
(5, 10)
|
||||
>>> r.topleft
|
||||
(0, 0)
|
||||
>>> r.topright
|
||||
(10, 0)
|
||||
>>> r.midleft
|
||||
(0, 10)
|
||||
|
||||
Changing these attributes re-calculates the others. The top-left corner is anchored for any growing or shrinking that takes place.
|
||||
|
||||
>>> r.topleft
|
||||
(0, 0)
|
||||
>>> r.left = 100
|
||||
>>> r.topleft
|
||||
(100, 0)
|
||||
>>> r.topright
|
||||
(110, 0)
|
||||
>>> r.width = 30
|
||||
>>> r.topright
|
||||
(130, 0)
|
||||
|
||||
Rect objects are locked to integers, unless you set `enableFloat` to `True`:
|
||||
|
||||
>>> r = pyrect.Rect(0, 0, 10, 20)
|
||||
>>> r.width = 10.5
|
||||
>>> r.width
|
||||
10
|
||||
>>> r.enableFloat = True
|
||||
>>> r.width = 10.5
|
||||
>>> r.width
|
||||
10.5
|
||||
>>> r2 = pyrect.Rect(0, 0, 10.5, 20.5, enableFloat=True)
|
||||
>>> r2.size
|
||||
(10.5, 20.5)
|
||||
|
||||
Rect Attributes
|
||||
===============
|
||||
|
||||
Rect objects have several attributes that can be read or modified. They are identical to Pygame's Rect objects:
|
||||
|
||||
``x, y``
|
||||
|
||||
``top, left, bottom, right``
|
||||
|
||||
``topleft, bottomleft, topright, bottomright``
|
||||
|
||||
``midtop, midleft, midbottom, midright``
|
||||
|
||||
``center, centerx, centery``
|
||||
|
||||
``size, width, height``
|
||||
|
||||
``w, h``
|
||||
|
||||
There are a couple other attributes as well:
|
||||
|
||||
``box (a tuple (left, top, width, height))``
|
||||
|
||||
``area (read-only)``
|
||||
|
||||
``perimeter (read-only)``
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
pyrect-0.2.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
pyrect-0.2.0.dist-info/METADATA,sha256=9EatJgmoV5eE-OiqsXpF3wlL9J1VZkp52qXFDkpTwMI,3764
|
||||
pyrect-0.2.0.dist-info/RECORD,,
|
||||
pyrect-0.2.0.dist-info/WHEEL,sha256=4YBfCYNH4wlLpv3pzq1hbEuIlXA4WJabKLFurZ7eTL0,109
|
||||
pyrect-0.2.0.dist-info/licenses/AUTHORS.txt,sha256=ag_hlAcX0gTe-ymJzRtkWtUBCZ8e7-4MyLtsju415xU,268
|
||||
pyrect-0.2.0.dist-info/licenses/LICENSE.txt,sha256=mxMj1hW-JJEBiFYMqfIR0AIb26CnCnXcY7WC-JMq5RU,1511
|
||||
pyrect-0.2.0.dist-info/top_level.txt,sha256=zRKhS2KGlJmow_PYupJ21SKCmAyorrFofAC7QGsXt5g,7
|
||||
pyrect/__init__.py,sha256=-9NfC3OF77hl9Aoa5-4vRdQm-hcbmDfheISG8vPZVNE,50395
|
||||
pyrect/__pycache__/__init__.cpython-311.pyc,,
|
||||
@@ -0,0 +1,6 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: setuptools (84.0.0)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py2-none-any
|
||||
Tag: py3-none-any
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS --
|
||||
people who have submitted patches, reported bugs, added translations, helped
|
||||
answer newbie questions, and generally made PyRect that much better:
|
||||
|
||||
Al Sweigart https://github.com/asweigart/
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2018, Al Sweigart
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the PyBresenham nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1 @@
|
||||
pyrect
|
||||
Reference in New Issue
Block a user