Created
November 27, 2011 02:00
-
-
Save tsterker/1396796 to your computer and use it in GitHub Desktop.
[py] circle in pyglet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, this is perfect. Thanks!