Skip to content

Instantly share code, notes, and snippets.

@tsterker
Created November 27, 2011 02:00
Show Gist options
  • Save tsterker/1396796 to your computer and use it in GitHub Desktop.
Save tsterker/1396796 to your computer and use it in GitHub Desktop.
[py] circle in pyglet
def circle(x, y, radius):
iterations = int(2*radius*pi)
s = sin(2*pi / iterations)
c = cos(2*pi / iterations)
dx, dy = radius, 0
glBegin(GL_TRIANGLE_FAN)
glVertex2f(x, y)
for i in range(iterations+1):
glVertex2f(x+dx, y+dy)
dx, dy = (dx*c - dy*s), (dy*c + dx*s)
glEnd()
@NiclasEriksen
Copy link

Ah, this is perfect. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment