Explain custom points from which to transform
This commit is contained in:
parent
e26ad868ec
commit
e066ba7fea
2 changed files with 7 additions and 4 deletions
|
@ -42,9 +42,10 @@ corners = [
|
||||||
(window.width, window.height), # Top right
|
(window.width, window.height), # Top right
|
||||||
]
|
]
|
||||||
pins = PygletCornerPin(window, corners)
|
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.
|
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.
|
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.
|
||||||
|
|
|
@ -26,10 +26,9 @@ for i in range(y_steps+3):
|
||||||
def on_key_press(symbol, modifiers):
|
def on_key_press(symbol, modifiers):
|
||||||
if symbol == pyglet.window.key.Q or symbol == pyglet.window.key.ESCAPE:
|
if symbol == pyglet.window.key.Q or symbol == pyglet.window.key.ESCAPE:
|
||||||
window.close()
|
window.close()
|
||||||
exit()
|
|
||||||
|
|
||||||
|
|
||||||
pins = PygletCornerPin(window, corners=[[100,100],[800,100],[150,500], [300,300]], source_points=[[100,100], [700,100], [100,500], [300,300]])
|
pins = PygletCornerPin(window, source_points=[[100,100],[600,100],[100,300], [600,300]], corners= [[100, 100], [444, 155], [230, 250], [600, 300]])
|
||||||
# event handlers for dragging:
|
# event handlers for dragging:
|
||||||
window.push_handlers(pins)
|
window.push_handlers(pins)
|
||||||
|
|
||||||
|
@ -43,3 +42,6 @@ def on_draw():
|
||||||
|
|
||||||
|
|
||||||
pyglet.app.run()
|
pyglet.app.run()
|
||||||
|
|
||||||
|
print(f"point positions: {pins.pin_positions}")
|
||||||
|
print("Save these and pass them as 'corner' attribute to restore last position.")
|
Loading…
Reference in a new issue