A class in Python is created with the class command
Functions in a Python class always have as their first argument a pointer to the object calling the function (typically named self)
One important function is the "constructor", which in Python is always named __init__
class Circle:
def __init__(self, x, y, radius, color):
self.x = x
self.y = y
self.radius = radius
self.color = color
def draw(self):
glColor3fv(self.color)
glBegin(GL_TRIANGLE_FAN)
glVertex2f(self.x, self.y)
for i in range(0,30):
glVertex2f(self.x + cos(radians(i*12.0)) * radius,
self.y + sin(radians(i*12.0)) * radius)
glEnd()
c = Circle(0, 0, 5, [1,0,0])