Fix: set transform on init

This commit is contained in:
Ruben van de Ven 2024-11-11 10:31:44 +01:00
parent 348a96b12c
commit e26ad868ec
3 changed files with 5 additions and 2 deletions

View file

@ -29,7 +29,7 @@ def on_key_press(symbol, modifiers):
exit() exit()
pins = PygletCornerPin(window, source_points=[[100,100], [700,100], [100,500], [300,300]]) pins = PygletCornerPin(window, corners=[[100,100],[800,100],[150,500], [300,300]], source_points=[[100,100], [700,100], [100,500], [300,300]])
# event handlers for dragging: # event handlers for dragging:
window.push_handlers(pins) window.push_handlers(pins)

View file

@ -110,6 +110,9 @@ class PygletCornerPin(pyglet.event.EventDispatcher):
] ]
self.current_corner = None self.current_corner = None
self.window.view = self.transform2d_matrix(*[x for c in self.source_points for x in c], *[x for c in self.pin_positions for x in c])
def update_handles(self): def update_handles(self):
for i, c in enumerate(self.pin_positions): for i, c in enumerate(self.pin_positions):
self.handles[i].x = c[0] self.handles[i].x = c[0]

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "pyglet-cornerpin" name = "pyglet-cornerpin"
version = "0.2.0" version = "0.3.1"
description = "Add a corner pin transform to a pyglet window" description = "Add a corner pin transform to a pyglet window"
authors = ["Ruben van de Ven <git@rubenvandeven.com>"] authors = ["Ruben van de Ven <git@rubenvandeven.com>"]
readme = "README.md" readme = "README.md"