Metadata-Version: 2.1
Name: pyglet-cornerpin
Version: 0.3.2
Summary: Add a corner pin transform to a pyglet window
Home-page: https://git.rubenvandeven.com/r/pyglet-cornerpin
License: MIT
Author: Ruben van de Ven
Author-email: git@rubenvandeven.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: pyglet (>=2.0.18,<3.0.0)
Project-URL: Repository, https://git.rubenvandeven.com/r/pyglet-cornerpin
Description-Content-Type: text/markdown

# Pyglet CornerPin

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

## Installation

```bash
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.


```python

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

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

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


Optionally you can provide initial positions for the pins.

```python
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](examples/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.

