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() exit() pins = PygletCornerPin(window, source_points=[[100,100], [700,100], [100,500], [300,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()