skip to navigation
skip to content

pyglet2d 0.1.0

2D shape primitives for pyglet.

Latest Version: 0.2.1

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.


  • In addition the standard constructor (from a list or array of points), Shape``s can be constructed with ``Shape.regular_polygon,, Shape.rectangle, and Shape.from_dict. The latter is a specification-based constructor that is easy to be use with JSON or YAML.
  • Shape has two methods that are useful as pyglet callbacks: Shape.draw and Shape.update. Shape``s can be given a velocity, and their positions 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 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).


See tests/ 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/


  • Python >= 3.3
  • pyglet >= 1.2alpha1. This must be manually installed as it is not on PyPi.
  • polygon >= 3
  • numpy


pip install pyglet2d --upgrade


To run the all tests run:



0.1.0 (2014-07-25)

  • First release on PyPI.
File Type Py Version Uploaded on Size
pyglet2d-0.1.0-py2.py3-none-any.whl (md5) Python Wheel 3.4 2014-07-26 7KB
pyglet2d-0.1.0.tar.gz (md5) Source 2014-07-26 13KB