draw thick circle as well

This commit is contained in:
Josh Holtrop 2011-03-31 22:13:03 -04:00
parent 7fb5a06088
commit 03f3245721

View File

@ -76,9 +76,9 @@ class SketchWidget:
for shape in self.sketch:
if isinstance(shape, Line):
self.drawLine(shape)
self.drawLine(shape, 0.03)
elif isinstance(shape, Circle):
self.drawCircle(shape)
self.drawCircle(shape, 0.03)
if gldrawable.is_double_buffered():
gldrawable.swap_buffers()
@ -89,18 +89,20 @@ class SketchWidget:
return True
def drawLine(self, shape):
def drawLine(self, shape, size):
self.drawFilledLine(shape.vars[0], shape.vars[1],
shape.vars[2], shape.vars[3], 0.03)
shape.vars[2], shape.vars[3], size)
def drawCircle(self, shape):
glBegin(GL_LINE_LOOP)
for i in range(24):
glVertex(shape.vars[0] +
shape.vars[2] * math.sin(i * 2 * math.pi / 24.0),
shape.vars[1] +
shape.vars[2] * math.cos(i * 2 * math.pi / 24.0))
glEnd()
def drawCircle(self, shape, size):
steps = 24
for i in range(steps + 1):
angle = i * 2 * math.pi / steps
next_angle = (i + 1) * 2 * math.pi / steps
self.drawFilledLine(shape.vars[0] + shape.vars[2] * math.cos(angle),
shape.vars[1] + shape.vars[2] * math.sin(angle),
shape.vars[0] + shape.vars[2] * math.cos(next_angle),
shape.vars[1] + shape.vars[2] * math.sin(next_angle),
size)
def drawFilledLine(self, x0, y0, x1, y1, size):
glBegin(GL_QUADS)