2D shape primitives for pyglet.
Project description
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 its position will be updated when Shape.update is called.
A Shape can be scaled and translated using the methods Shape.scale and Shape.translate, or with in-place arithmetic.
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 |, &, and ^.
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_test.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_test.py
Requirements
Installation
pip install pyglet2d --upgrade
Documentation
Development
To run the all tests run:
tox
Changelog
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.
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
Built Distribution
Hashes for pyglet2d-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66bfaf5a3527a0cae67c1496a436ceb65bc1ae48b7147f54ed4b4f2f7857d5a2 |
|
MD5 | 0e7d68af133662eee428d5f5c42e83d1 |
|
BLAKE2b-256 | 148602a4f9fb20ae385b13dd5dd4fece95ad4f1524c6fc78e95fe7f75b72b437 |