Skip to content

Instantly share code, notes, and snippets.

@llimllib
Created July 14, 2020 03:20
Show Gist options
  • Save llimllib/d66feb4cd3f8adc70331ff7b3cd42ba0 to your computer and use it in GitHub Desktop.
Save llimllib/d66feb4cd3f8adc70331ff7b3cd42ba0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import pyglet
from pyglet import shapes
WIDTH = 960
HEIGHT = 540
RED = (255, 0, 0)
window = pyglet.window.Window(WIDTH, HEIGHT)
# the pyglet documentation strongly suggests to draw with a batch, not an
# individual shape, so, FINE
batch = pyglet.graphics.Batch()
# this needs to be a global variable to avoid being garbage collected
c = shapes.Circle(WIDTH // 2, HEIGHT // 2, HEIGHT // 10, color=RED, batch=batch)
@window.event
def on_draw():
window.clear()
batch.draw()
pyglet.app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment