Skip to main content

Add a corner pin transform to a pyglet window

Project description

Pyglet CornerPin

This is a little utility that adds corner pin transforms to a pyglet window.

Installation

pip install pyglet-cornerpin

Usage

Create instance for a window, and register the event handlers for dragging the pins. A on_key_release is also registered to handle keyboard controls to move the pins.

pins = PygletCornerPin(window)
# event handlers for dragging:
window.push_handlers(pins)

Then you can draw the pins in your on_draw() event.

@window.event
def on_draw():
    window.clear()
    ...
    # draw corner pins
    pins.draw()

Optionally you can provide initial positions for the pins.

corners = [
    (0, 0),                        # Bottom left
    (window.width),                # Bottom right
    (0, window.height),            # Top left
    (window.width, window.height), # Top right
]
pins = PygletCornerPin(window, corners)

Moreover, you don't need to pin the window corners, but can pin from any four arbitrary points, by providing source_points.

Run pattern.py in the examples folder for a demo.

To use the keyboard, select a pin with number keys 1-4, the use the arrow keys (optionally with ctrl/shift modifier) to move the handle.

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

pyglet_cornerpin-0.3.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

pyglet_cornerpin-0.3.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pyglet_cornerpin-0.3.2.tar.gz.

File metadata

  • Download URL: pyglet_cornerpin-0.3.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Linux/6.11.5-amd64

File hashes

Hashes for pyglet_cornerpin-0.3.2.tar.gz
Algorithm Hash digest
SHA256 ac220e9895b5f5dff97ef7dd1680f5aef86e5371a1b2554e562dfd0786e28afd
MD5 17904ff191874c46ee533d12de2a3266
BLAKE2b-256 f9f70676a1e7702099af7edb1f13e5b001bc002f6d3fe7762aee0693ff9c0e0d

See more details on using hashes here.

File details

Details for the file pyglet_cornerpin-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: pyglet_cornerpin-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Linux/6.11.5-amd64

File hashes

Hashes for pyglet_cornerpin-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 94b1990a511b545f9d20e89135e314179344ee9b6e63cd3f6c0c17aa9bf1b365
MD5 414bd57273a4b030d9738a2b7277d2c6
BLAKE2b-256 17cdf4f4061e41da99ad1b39ec91f41cdefb33421c09180970b49f2b1e628843

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