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:
|
for shape in self.sketch:
|
||||||
if isinstance(shape, Line):
|
if isinstance(shape, Line):
|
||||||
glBegin(GL_LINES)
|
self.drawLine(shape)
|
||||||
glVertex(shape.vars[0], shape.vars[1])
|
|
||||||
glVertex(shape.vars[2], shape.vars[3])
|
|
||||||
glEnd()
|
|
||||||
elif isinstance(shape, Circle):
|
elif isinstance(shape, Circle):
|
||||||
glBegin(GL_LINE_LOOP)
|
self.drawCircle(shape)
|
||||||
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()
|
|
||||||
|
|
||||||
if gldrawable.is_double_buffered():
|
if gldrawable.is_double_buffered():
|
||||||
gldrawable.swap_buffers()
|
gldrawable.swap_buffers()
|
||||||
@ -97,3 +88,18 @@ class SketchWidget:
|
|||||||
gldrawable.gl_end()
|
gldrawable.gl_end()
|
||||||
|
|
||||||
return True
|
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