diff --git a/SketchWidget.py b/SketchWidget.py index a189cb5..3ecdbb3 100644 --- a/SketchWidget.py +++ b/SketchWidget.py @@ -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)