from math import * from time import * from pyglet.gl import * class Circle: def __init__(self,radius,r,g,b,x=0,y=0): self.radius = radius self.r = r self.g = g self.b = b self.x = x self.y = y def draw(self): glColor3f(self.r,self.g,self.b) glPushMatrix() glTranslatef(self.x, self.y ,0) glBegin(GL_TRIANGLE_FAN) glVertex2f(0,0) for angle in range(0,370,10): x = self.radius * cos(radians(angle)) y = self.radius * sin(radians(angle)) glVertex2f(x,y) glEnd() glPopMatrix() window = pyglet.window.Window() c = Circle(100, 0.5, 1, 0.2) @window.event def on_draw(): global c glClear(GL_COLOR_BUFFER_BIT) c.draw() def update(dt): global c c.radius = 30 + 30*sin(time()) c.x = 200 + 200*cos(time()) c.y = 200 + 200*sin(time()) pyglet.clock.schedule_interval(update,1/60.0) pyglet.app.run()