Skip to main content

2D shape primitives for pyglet.

Project description

Polygon primitives for pyglet.

Travis-CI Build Status
Coverage Status
PyPi Package
License
Git Repository
Mercurial Repository

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 the standard constructor (from a list or array of points), Shape``s can be constructed with ``Shape.regular_polygon, Shape.circle, 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 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

  • Python >= 3.3

  • pyglet >= 1.2alpha1. This must be manually installed as it is not on PyPi.

  • polygon >= 3

  • numpy

Installation

pip install pyglet2d --upgrade

Documentation

https://pyglet2d.readthedocs.org/

Development

To run the all tests run:

tox

Changelog

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

pyglet2d-0.1.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyglet2d-0.1.0-py2.py3-none-any.whl (8.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyglet2d-0.1.0.tar.gz.

File metadata

  • Download URL: pyglet2d-0.1.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyglet2d-0.1.0.tar.gz
Algorithm Hash digest
SHA256 41f17b04e24ba77c27303d56062c988a182ba343517da22596b902cb7722061e
MD5 81243da886f35db7acbab2a6a441879e
BLAKE2b-256 bd25fc556c22fd5b8b203e78b7b901ebc1d01b68577d2223a4ae914971b3de65

See more details on using hashes here.

File details

Details for the file pyglet2d-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pyglet2d-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 96732d73f1f87928624fe71b6632625fa94328f5b41650061906212d6ff0e6aa
MD5 eb053c79285a397e85c0f5f458e9f93b
BLAKE2b-256 46c411efde6cfd4a0413f53692dc12320363c96bd1e8e0cc11b2a2d7ce3d04ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page