import pyglet from pyglet_cornerpin import PygletCornerPin window = pyglet.window.Window() # Generate a test pattern batch = pyglet.graphics.Batch() pattern = [] d = 20 y_steps = int(window.height / d) x_steps = int(window.width / d) colors = [ (255,255,255,255), (180,180,180,180) ] for i in range(y_steps+3): y = int(i * d) for j in range(x_steps+3): x = int(j * d) pattern.append( pyglet.shapes.Rectangle(x,y, d,d, colors[(i+j) % len(colors)], batch=batch) ) @window.event def on_key_press(symbol, modifiers): if symbol == pyglet.window.key.Q or symbol == pyglet.window.key.ESCAPE: window.close() 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: window.push_handlers(pins) @window.event def on_draw(): window.clear() # draw test pattern batch.draw() # draw corner pins pins.draw() pyglet.app.run() print(f"point positions: {pins.pin_positions}") print("Save these and pass them as 'corner' attribute to restore last position.")