pyglet2d
Polygon primitives for pyglet.
This package provides a Shape object that can be acts as an interface between the libraries polygon and pyglet. The former provides numerical routines for handling shapes, and the latter can process OpenGL bindings. With pyglet2d, you can incorporate 2D shapes into your applications without having to write your own OpenGL calls.
Features
In addition to the standard constructor (from a list or array of points), four others are provided: Shape.regular_polygon, Shape.circle, Shape.rectangle, and Shape.from_dict. The latter is a specification-based constructor that is easy to use with JSON or YAML.
Shape has two methods that are useful as pyglet callbacks: Shape.draw and Shape.update. A Shape can be given a velocity and/or an angular velocity, and it will be updated accordingly when Shape.update is called.
A Shape can be manipulated using the methods Shape.scale, Shape.rotate, Shape.flip_x, Shape.flip_y, Shape.flip, and Shape.translate, or with in-place arithmetic (e.g. shape += [5, 0]).
Alternatively, setting the properties Shape.center and Shape.radius will translate and scale the shape, respectively.
Clipping operations provided by polygon are bound to the operators |, +, (union), & (intersection), - (difference), and ^ (xor).
Additional polygon methods can be accessed directly from the Shape.poly attribute, where the Polygon object is stored.
Shortcuts are provided to polygon functions via the boolean methods Shape.overlaps(other) and Shape.covers(other).
Example
See tests/graphics_demo.py for a usage example. This script also serves as a test. Run it to make sure that your graphics pipeline is working correctly:
python tests/graphics_demo.py
Requirements
Installation
pip install pyglet2d --upgrade
Documentation
Development
To run the all tests run:
tox
Changelog
0.2.1 (2014-07-27)
All in-place operations now return the Shape, allowing operations to be chained.
0.2.0 (2014-07-27)
Added optional arguments y_factor and center to Shape.scale.
Implemented Shape.rotate.
Implemented angular velocity.
Argument start_angle in Shape.regular_polygon is now in radians.
graphics_test.py renamed to graphics_demo.py.
Implement Shape.flip_x, Shape.flip_y, and Shape.flip.
Explicitly set the Polygon3 data style to STYLE_NUMPY.
Implement Shape union and difference with the addition and subtraction operators.
Don’t throw an error when comparing the equality of shapes with different numbers of vertices.
0.1.2 (2014-07-26)
Fixed Shape docstring.
Changed docs from napoleon to numpydoc.
0.1.1 (2014-07-26)
Mocking of graphics calls to pyglet, for testing without a display (e.g., on Travis).
Fixed intersphinx links in docs.
Fixed coveralls.io integration.
0.1.0 (2014-07-25)
First release on PyPI.
Metadata
Release files for pyglet2d 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyglet2d-0.2.1.tar.gz | 16.3 kB | Without provenance | Details for pyglet2d-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyglet2d-0.2.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for pyglet2d-0.2.1-py2.py3-none-any.whl |
Total release size: 25.7 kB
Release files / pyglet2d-0.2.1.tar.gz
| Download URL | pyglet2d-0.2.1.tar.gz |
|---|---|
| Size | 16.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3afc2517392d2023a58526e2af21320692a91c36290069f4118b3d4fcbe2b98f
|
|
BLAKE2b-256 checksum How to use checksums |
38ebc19e645d4cfb8195cb1217888d31d0079d41ba7ed2a1147ba6d4ef414d41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pyglet2d-0.2.1-py2.py3-none-any.whl
| Download URL | pyglet2d-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f4a55f0871a2cc1628fb1f4eabfb0f70e6fcf9d98dfdd15515030b4919c16846
|
|
BLAKE2b-256 checksum How to use checksums |
f29b22f7b079732c59d1200bc6bfaff6f777828f82c31dd13b79a5681a4a6dc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pyglet2d 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.