SketchWidget: add drawFilledLine()

This commit is contained in:
Josh Holtrop 2011-03-31 21:42:13 -04:00
parent 87348d3605
commit 1203478a33

View File

@ -90,10 +90,8 @@ class SketchWidget:
return True return True
def drawLine(self, shape): def drawLine(self, shape):
glBegin(GL_LINES) self.drawFilledLine(shape.vars[0], shape.vars[1],
glVertex(shape.vars[0], shape.vars[1]) shape.vars[2], shape.vars[3], 0.03)
glVertex(shape.vars[2], shape.vars[3])
glEnd()
def drawCircle(self, shape): def drawCircle(self, shape):
glBegin(GL_LINE_LOOP) glBegin(GL_LINE_LOOP)
@ -103,3 +101,20 @@ class SketchWidget:
shape.vars[1] + shape.vars[1] +
shape.vars[2] * math.cos(i * 2 * math.pi / 24.0)) shape.vars[2] * math.cos(i * 2 * math.pi / 24.0))
glEnd() glEnd()
def drawFilledLine(self, x0, y0, x1, y1, size):
glBegin(GL_QUADS)
angle = math.atan2(y1 - y0, x1 - x0)
ninety = math.pi / 2
glVertex(x0 + size * math.cos(angle + ninety),
y0 + size * math.sin(angle + ninety))
glVertex(x0 + size * math.cos(angle - ninety),
y0 + size * math.sin(angle - ninety))
glVertex(x1 + size * math.cos(angle - ninety),
y1 + size * math.sin(angle - ninety))
glVertex(x1 + size * math.cos(angle + ninety),
y1 + size * math.sin(angle + ninety))
glEnd()
def drawFilledCircle(self, x, y, radius, steps):
pass