예제 #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)
예제 #2
0
파일: stimulus.py 프로젝트: JingLu92/pyff
 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)
예제 #3
0
파일: stimulus.py 프로젝트: JingLu92/pyff
 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)
예제 #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)
예제 #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)
예제 #6
0
 def draw(self):
     p = self.parameters
     if p.on:
         self._gl_color(*self._color)
         gl.glDisable(gl.GL_TEXTURE_2D)
         if p.depth_test:
             gl.glEnable(gl.GL_DEPTH_TEST)
         else:
             gl.glDisable(gl.GL_DEPTH_TEST)
         if p.blending_enabled:
             gl.glEnable(gl.GL_BLEND)
         else:
             gl.glDisable(gl.GL_BLEND)
         gl.glLineWidth(self._line_width)
         gl.glBegin(gl.GL_LINE_LOOP)
         for vertex in self._vertices:
             gl.glVertex(*vertex)
         gl.glEnd()
예제 #7
0
 def draw(self):
     p = self.parameters
     if p.on:
         self._gl_color(*self._color)
         gl.glDisable(gl.GL_TEXTURE_2D)
         if p.depth_test:
             gl.glEnable(gl.GL_DEPTH_TEST)
         else:
             gl.glDisable(gl.GL_DEPTH_TEST)
         if p.blending_enabled:
             gl.glEnable(gl.GL_BLEND)
         else:
             gl.glDisable(gl.GL_BLEND)
         gl.glLineWidth(self._line_width)
         gl.glBegin(gl.GL_LINE_LOOP)
         for vertex in self._vertices:
             gl.glVertex(*vertex)
         gl.glEnd()
예제 #8
0
파일: stimulus.py 프로젝트: JingLu92/pyff
 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)
예제 #9
0
        def draw(self):
            if self.parameters.on:
                gl.glDisable(gl.GL_TEXTURE_2D)
                gl.glDisable(gl.GL_DEPTH_TEST)

                gl.glMatrixMode(gl.GL_MODELVIEW)
                gl.glPushMatrix()
                gl.glTranslate(self.parameters.lowerleft[0],
                               self.parameters.lowerleft[1], 0.0)
                gl.glRotate(self.parameters.orientation, 0.0, 0.0, 1.0)

                c = self.parameters.color
                if len(c) == 3:
                    gl.glColor3f(*c)
                elif len(c) == 4:
                    gl.glColor4f(*c)

                gl.glLineWidth(self.parameters.linewidth)

                if self.parameters.anti_aliasing:
                    gl.glEnable(gl.GL_BLEND)
                    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
                    gl.glEnable(gl.GL_LINE_SMOOTH)
                else:
                    gl.glDisable(gl.GL_BLEND)

    ##            # This code successfully draws a box...
    ##            gl.glBegin(gl.GL_QUADS)
    ##            gl.glVertex2f(0.0,0.0)
    ##            gl.glVertex2f(0.0,0.1)
    ##            gl.glVertex2f(0.1,0.1)
    ##            gl.glVertex2f(0.1,0.0)
    ##            gl.glEnd()

    # But this code does not draw the string!?!
                for char in self.parameters.text:
                    glut.glutStrokeCharacter(self.parameters.font, ord(char))
                gl.glPopMatrix()
예제 #10
0
        def draw(self):
            if self.parameters.on:
                gl.glDisable(gl.GL_TEXTURE_2D)
                gl.glDisable(gl.GL_DEPTH_TEST)

                gl.glMatrixMode(gl.GL_MODELVIEW)
                gl.glPushMatrix()
                gl.glTranslate(self.parameters.lowerleft[0],self.parameters.lowerleft[1],0.0)
                gl.glRotate(self.parameters.orientation,0.0,0.0,1.0)

                c = self.parameters.color
                if len(c)==3:
                    gl.glColor3f(*c)
                elif len(c)==4:
                    gl.glColor4f(*c)

                gl.glLineWidth(self.parameters.linewidth)

                if self.parameters.anti_aliasing:
                    gl.glEnable(gl.GL_BLEND)
                    gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA)
                    gl.glEnable(gl.GL_LINE_SMOOTH)
                else:
                    gl.glDisable(gl.GL_BLEND)

    ##            # This code successfully draws a box...
    ##            gl.glBegin(gl.GL_QUADS)
    ##            gl.glVertex2f(0.0,0.0)
    ##            gl.glVertex2f(0.0,0.1)
    ##            gl.glVertex2f(0.1,0.1)
    ##            gl.glVertex2f(0.1,0.0)
    ##            gl.glEnd()

                # But this code does not draw the string!?!
                for char in self.parameters.text:
                    glut.glutStrokeCharacter(self.parameters.font,ord(char))
                gl.glPopMatrix()
예제 #11
0
    def draw(self):
        p = self.parameters # shorthand

        width = self.size[0]
        height = self.size[1]

        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPushMatrix()
        gl.glLoadIdentity()
        gl.glOrtho(-width, width, -height, height, -200, 200)
        gl.glScalef(2, -2, 2)
        gl.glMatrixMode(gl.GL_MODELVIEW)

        if len(p.color)==3:
            gl.glColor3f(*p.color)
        elif len(p.color)==4:
            gl.glColor4f(*p.color)

        # this is necessary for the antialiasing
        gl.glDisable(gl.GL_DEPTH_TEST)
        gl.glDisable(gl.GL_TEXTURE_2D)
        gl.glEnable(gl.GL_LINE_SMOOTH)
        gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA)
        gl.glEnable(gl.GL_BLEND)
        gl.glLineWidth(p.line_width)

        # draw the polygon
        gl.glBegin(gl.GL_POLYGON)
        for point in p.points:
            gl.glVertex3f(point[0], point[1], 0.0)
        gl.glVertex3f(p.points[0][0], p.points[0][1], 0.0)
        gl.glEnd() # GL_LINE_STRIP

        gl.glDisable(gl.GL_LINE_SMOOTH)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPopMatrix()