Ejemplo n.º 1
0
 def _draw(self):
     p = self.parameters
     side = p.side
     height = side * numpy.sqrt(3) / 2.
     center = VisionEgg._get_center(p.position, p.anchor, (side, height))
     position = numpy.array(center)
     hh = height / 2
     ll = position - (hh, hh)
     lr = position - (-hh, hh)
     u = position + (0., hh)
     gl.glDisable(gl.GL_DEPTH_TEST)
     gl.glDisable(gl.GL_TEXTURE_2D)
     gl.glDisable(gl.GL_BLEND)
     gl.glColor(p.color)
     gl.glBegin(gl.GL_TRIANGLES)
     self._draw_vertices(ll, lr, u)
     gl.glEnd()
     gl.glColor(p.color_edge)
     if p.anti_aliasing:
         gl.glEnable(gl.GL_LINE_SMOOTH)
     gl.glLineWidth(p.width)
     gl.glBegin(gl.GL_LINE_STRIP)
     self._draw_vertices(ll, lr, u, ll)
     gl.glEnd()
     gl.glDisable(gl.GL_LINE_SMOOTH)
Ejemplo n.º 2
0
 def _draw(self):
     p = self.parameters
     side = p.side
     height = side * numpy.sqrt(3) / 2.
     center = VisionEgg._get_center(p.position, p.anchor, (side, height))
     position = numpy.array(center)
     hh = height / 2
     ll = position - (hh, hh)
     lr = position - (-hh, hh)
     u = position + (0., hh)
     gl.glDisable(gl.GL_DEPTH_TEST)
     gl.glDisable(gl.GL_TEXTURE_2D)
     gl.glDisable(gl.GL_BLEND)
     gl.glColor(p.color)
     gl.glBegin(gl.GL_TRIANGLES)
     self._draw_vertices(ll, lr, u)
     gl.glEnd()
     gl.glColor(p.color_edge)
     if p.anti_aliasing:
         gl.glEnable(gl.GL_LINE_SMOOTH)
     gl.glLineWidth(p.width)
     gl.glBegin(gl.GL_LINE_STRIP)
     self._draw_vertices(ll, lr, u, ll)
     gl.glEnd()
     gl.glDisable(gl.GL_LINE_SMOOTH)
Ejemplo n.º 3
0
 def _draw(self):
     p = self.parameters
     gl.glDisable(gl.GL_DEPTH_TEST)
     gl.glDisable(gl.GL_TEXTURE_2D)
     gl.glDisable(gl.GL_BLEND)
     gl.glColor(p.color)
     if p.anti_aliasing:
         gl.glEnable(gl.GL_LINE_SMOOTH)
     gl.glLineWidth(p.width)
     gl.glBegin(gl.GL_LINES)
     gl.glVertex(p.position)
     gl.glVertex(p.end)
     gl.glEnd()
     gl.glDisable(gl.GL_LINE_SMOOTH)
Ejemplo n.º 4
0
 def _draw(self):
     p = self.parameters
     gl.glDisable(gl.GL_DEPTH_TEST)
     gl.glDisable(gl.GL_TEXTURE_2D)
     gl.glDisable(gl.GL_BLEND)
     gl.glColor(p.color)
     if p.anti_aliasing:
         gl.glEnable(gl.GL_LINE_SMOOTH)
     gl.glLineWidth(p.width)
     gl.glBegin(gl.GL_LINES)
     gl.glVertex(p.position)
     gl.glVertex(p.end)
     gl.glEnd()
     gl.glDisable(gl.GL_LINE_SMOOTH)
Ejemplo n.º 5
0
 def _draw(self):
     p = self.parameters
     center = VisionEgg._get_center(p.position, p.anchor,
                                    (p.radius, p.radius))
     gl.glDisable(gl.GL_DEPTH_TEST)
     gl.glDisable(gl.GL_TEXTURE_2D)
     gl.glDisable(gl.GL_BLEND)
     gl.glColor(p.color)
     start, end = p.start, p.end
     if end < start:
         start -= 360.
     start, end = map(numpy.deg2rad, (start, end))
     frac = (end - start) / (2 * numpy.pi)
     num_triangles = float(p.num_triangles) * frac
     angles = numpy.linspace(start, end, num_triangles)
     verts = numpy.zeros((num_triangles, 2))
     verts[:, 0] = center[0] + p.radius * numpy.cos(angles)
     verts[:, 1] = center[1] + p.radius * numpy.sin(angles)
     if p.disk:
         gl.glBegin(gl.GL_TRIANGLE_FAN)
         gl.glVertex(center)
         self._draw_vertices(*verts)
         gl.glEnd()
         if p.anti_aliasing:
             gl.glEnable(gl.GL_LINE_SMOOTH)
             gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
             gl.glEnable(gl.GL_BLEND)
             # Draw a second polygon in line mode, so the edges are anti-aliased
             gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
             gl.glBegin(gl.GL_TRIANGLE_FAN)
             gl.glVertex(center)
             self._draw_vertices(*verts)
             gl.glEnd()
             gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
             gl.glDisable(gl.GL_LINE_SMOOTH)
     if p.circle:
         if p.anti_aliasing:
             gl.glEnable(gl.GL_LINE_SMOOTH)
         gl.glColor(p.color_edge)
         gl.glLineWidth(p.circle_width)
         gl.glBegin(gl.GL_LINES)
         for i in range(verts.shape[0] - 1):
             self._draw_vertices(verts[i], verts[i + 1])
         gl.glEnd()
         gl.glDisable(gl.GL_LINE_SMOOTH)
Ejemplo n.º 6
0
 def _draw(self):
     p = self.parameters
     center = VisionEgg._get_center(p.position, p.anchor, (p.radius, p.radius))
     gl.glDisable(gl.GL_DEPTH_TEST)
     gl.glDisable(gl.GL_TEXTURE_2D)
     gl.glDisable(gl.GL_BLEND)
     gl.glColor(p.color)
     start, end = p.start, p.end
     if end < start:
         start -= 360.
     start, end = map(numpy.deg2rad, (start, end))
     frac = (end - start) / (2 * numpy.pi)
     num_triangles = float(p.num_triangles) * frac
     angles = numpy.linspace(start, end, num_triangles)
     verts = numpy.zeros((num_triangles, 2))
     verts[:,0] = center[0] + p.radius * numpy.cos(angles)
     verts[:,1] = center[1] + p.radius * numpy.sin(angles)
     if p.disk:
         gl.glBegin(gl.GL_TRIANGLE_FAN)
         gl.glVertex(center)
         self._draw_vertices(*verts)
         gl.glEnd()
         if p.anti_aliasing:
             gl.glEnable(gl.GL_LINE_SMOOTH)
             gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
             gl.glEnable(gl.GL_BLEND)
             # Draw a second polygon in line mode, so the edges are anti-aliased
             gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
             gl.glBegin(gl.GL_TRIANGLE_FAN)
             gl.glVertex(center)
             self._draw_vertices(*verts)
             gl.glEnd()
             gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
             gl.glDisable(gl.GL_LINE_SMOOTH)
     if p.circle:
         if p.anti_aliasing:
             gl.glEnable(gl.GL_LINE_SMOOTH)
         gl.glColor(p.color_edge)
         gl.glLineWidth(p.circle_width)
         gl.glBegin(gl.GL_LINES)
         for i in range(verts.shape[0]-1):
             self._draw_vertices(verts[i], verts[i+1])
         gl.glEnd()
         gl.glDisable(gl.GL_LINE_SMOOTH)