diff --git a/SketchWidget.py b/SketchWidget.py index c035297..6e794a7 100644 --- a/SketchWidget.py +++ b/SketchWidget.py @@ -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()