SketchWidget: break out draw{Line,Circle}()
This commit is contained in:
parent
b562718db6
commit
87348d3605
@ -76,18 +76,9 @@ class SketchWidget:
|
||||
|
||||
for shape in self.sketch:
|
||||
if isinstance(shape, Line):
|
||||
glBegin(GL_LINES)
|
||||
glVertex(shape.vars[0], shape.vars[1])
|
||||
glVertex(shape.vars[2], shape.vars[3])
|
||||
glEnd()
|
||||
self.drawLine(shape)
|
||||
elif isinstance(shape, Circle):
|
||||
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()
|
||||
self.drawCircle(shape)
|
||||
|
||||
if gldrawable.is_double_buffered():
|
||||
gldrawable.swap_buffers()
|
||||
@ -97,3 +88,18 @@ class SketchWidget:
|
||||
gldrawable.gl_end()
|
||||
|
||||
return True
|
||||
|
||||
def drawLine(self, shape):
|
||||
glBegin(GL_LINES)
|
||||
glVertex(shape.vars[0], shape.vars[1])
|
||||
glVertex(shape.vars[2], shape.vars[3])
|
||||
glEnd()
|
||||
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user