Пример #1
0
 def _render_legend(self, x, y):
     # render oscilloscope window edge
     gl.glPushMatrix()
     gl.glTranslatef(.5,.5,0.)
     gl.glLineWidth(1.)
     gl.glDisable(gl.GL_LINE_SMOOTH)
     # calculate legend window size
     w = 0.
     h = self.font.height * len(self.graph_renderer.channels)
     for channel in self.graph_renderer.channels:
         w = max(w, self.font.width(channel.name))
     # draw legend window background and border
     draw.filled_rect(x, y, w+24, h+4, (0.3, 0.3, 0.3, 0.3))
     draw.rect(x, y, w+24, h+4, (0.4, 0.4, 0.4, .8))
     # draw legend window example linesegments
     dy = y + 2. + self.font.height / 2.
     gl.glEnable(gl.GL_LINE_SMOOTH)
     for channel in self.graph_renderer.channels:
         gl.glLineWidth(channel.f_linewidth)
         draw.line(x + 4, dy, x + 14, dy, channel.f_color_avg)
         dy += self.font.height
     # draw legend window text
     gl.glTranslatef(-.5, -.5, 0.)
     dy = y + 2.
     for channel in self.graph_renderer.channels:
         self.font.drawtl(channel.name, x + 20, dy, bgcolor=(0.,0.,0.,0.), fgcolor=(0.9, 0.9, 0.9, .8))
         dy += self.font.height
     gl.glPopMatrix()
Пример #2
0
    def render(self):
        """ render everything. window edge, scrollbar, legend, and the graph itself. the graph object
         renders the grid, background, grid text and the graph line """
        draw.filled_rect(self.x, self.y, self.w, self.h, (0.0,0.0,0.0,1.))
        self._render_scrollbar(self.x, self.y + 1, self.w, 8)

        # render oscilloscope window edge
        gl.glPushMatrix()
        gl.glTranslatef(.5,.5,0.)
        gl.glLineWidth(1.)
        draw.rect(self.x, self.y, self.w, self.h, (0.6,0.6,0.6,1.))
        gl.glPopMatrix()

        gl.glPushMatrix()
        x, y, w, h = self._raw_graph_window_dim()
        xx, yy = self.parent.gl_coordinates(x, y)
        gl.glScissor(int(xx), int(yy - h), int(w), int(h))
        gl.glEnable(gl.GL_SCISSOR_TEST)
        #print "sy1 %.2f sy2 %.2f sy2 - sy1 %.2f" % (self.sy1, self.sy2, self.sy2 - self.sy1)
        self.graph_renderer.render(x, y, w, h, self.sx1, self.sy1, self.sx2 - self.sx1, self.sy2 - self.sy1)
        gl.glDisable(gl.GL_SCISSOR_TEST)
        gl.glPopMatrix()

        if self.render_legend:
            x, y = self.render_legend_pos
            self._render_legend(self.x + x, self.y + y)
Пример #3
0
def draw_card():
    global last_card, current_card, next_card, transition_time
    draw.set_color(1, 1, 1, 1)
    draw.rect(0, 0, env.norm_w, env.norm_h)
    try:
        current_card.draw()
    except:
        pass
    if transition_time > 0:
        if next_card != None:
            a = 1.0 - transition_time / 0.5
        else:
            a = transition_time / 0.5
        draw.set_color(1, 1, 1, a)
        draw.rect(0, 0, env.norm_w, env.norm_h)
        transition_time -= env.dt
        if transition_time <= 0:
            if next_card != None:
                last_card = current_card
                current_card = next_card
                next_card = None
                transition_time = 0.5
            else:
                transition_time = 0.0
                push_handlers()
Пример #4
0
    def render(self):
        """ render everything. window edge, scrollbar, legend, and the graph itself. the graph object
         renders the grid, background, grid text and the graph line """
        draw.filled_rect(self.x, self.y, self.w, self.h, (0.0, 0.0, 0.0, 1.))
        self._render_scrollbar(self.x, self.y + 1, self.w, 8)

        # render oscilloscope window edge
        gl.glPushMatrix()
        gl.glTranslatef(.5, .5, 0.)
        gl.glLineWidth(1.)
        draw.rect(self.x, self.y, self.w, self.h, (0.6, 0.6, 0.6, 1.))
        gl.glPopMatrix()

        gl.glPushMatrix()
        x, y, w, h = self._raw_graph_window_dim()
        xx, yy = self.parent.gl_coordinates(x, y)
        gl.glScissor(int(xx), int(yy - h), int(w), int(h))
        gl.glEnable(gl.GL_SCISSOR_TEST)
        #print "sy1 %.2f sy2 %.2f sy2 - sy1 %.2f" % (self.sy1, self.sy2, self.sy2 - self.sy1)
        self.graph_renderer.render(x, y, w, h, self.sx1, self.sy1,
                                   self.sx2 - self.sx1, self.sy2 - self.sy1)
        gl.glDisable(gl.GL_SCISSOR_TEST)
        gl.glPopMatrix()

        if self.render_legend:
            x, y = self.render_legend_pos
            self._render_legend(self.x + x, self.y + y)
Пример #5
0
 def _render_legend(self, x, y):
     # render oscilloscope window edge
     gl.glPushMatrix()
     gl.glTranslatef(.5, .5, 0.)
     gl.glLineWidth(1.)
     gl.glDisable(gl.GL_LINE_SMOOTH)
     # calculate legend window size
     w = 0.
     h = self.font.height * len(self.graph_renderer.channels)
     for channel in self.graph_renderer.channels:
         w = max(w, self.font.width(channel.name))
     # draw legend window background and border
     draw.filled_rect(x, y, w + 24, h + 4, (0.3, 0.3, 0.3, 0.3))
     draw.rect(x, y, w + 24, h + 4, (0.4, 0.4, 0.4, .8))
     # draw legend window example linesegments
     dy = y + 2. + self.font.height / 2.
     gl.glEnable(gl.GL_LINE_SMOOTH)
     for channel in self.graph_renderer.channels:
         gl.glLineWidth(channel.f_linewidth)
         draw.line(x + 4, dy, x + 14, dy, channel.f_color_avg)
         dy += self.font.height
     # draw legend window text
     gl.glTranslatef(-.5, -.5, 0.)
     dy = y + 2.
     for channel in self.graph_renderer.channels:
         self.font.drawtl(channel.name,
                          x + 20,
                          dy,
                          bgcolor=(0., 0., 0., 0.),
                          fgcolor=(0.9, 0.9, 0.9, .8))
         dy += self.font.height
     gl.glPopMatrix()
Пример #6
0
 def draw(self):
     for edge in self.edges.viewvalues():
         ax, ay = self.points[edge.a]
         bx, by = self.points[edge.b]
         if edge.counterpart:
             draw.line(ax, ay, bx, by, colors=(0, 255, 0, 255, 0, 255, 0, 255))
         else:
             draw.line(ax, ay, bx, by, colors=(255, 0, 0, 255, 0, 0, 255, 255))
     draw.set_color(1,0,0,1)
     for point in self.points.viewvalues():
         draw.rect(point[0]-5, point[1]-5, point[0]+5, point[1]+5)
Пример #7
0
	def draw_rect(self, rect, color=draw.WHITE, filled=True):
		rect = Rect(
				(rect.x - self.origin.x) * self.scale,
				(rect.y - self.origin.y) * self.scale,
				rect.width * self.scale,
				rect.height * self.scale)
		
		draw.rect(
				self.screen,
				rect,
				color=color,
				filled=filled)
Пример #8
0
def draw_level_objects():
    colors = {
        True: prim_color,
        False: (1,0,0,1)
    }
    for obj in primitives:
        if obj.yaml_tag == u"!Line":
            if obj.visible:
                draw.set_color(*prim_color)
            else:
                if obj.collides:
                    draw.set_color(0,1,0,1)
                else:
                    draw.set_color(1,0,0,1)
            draw.line(obj.x1, obj.y1, obj.x2, obj.y2)
        elif obj.yaml_tag == u"!Circle":
            if obj.visible:
                draw.set_color(*prim_color)
            else:
                if obj.collides:
                    draw.set_color(0,1,0,1)
                else:
                    draw.set_color(1,0,0,1)
            draw.circle(obj.x, obj.y, obj.radius)
        elif obj.yaml_tag == u"!FilledRect":
            draw.set_color(*colors[obj.visible])
            draw.rect(obj.x1, obj.y1, obj.x2, obj.y2)
        elif obj.yaml_tag == u"!FilledTriangle":
            draw.set_color(*colors[obj.visible])
            draw.polygon((obj.x1, obj.y1, obj.x2, obj.y2, obj.x3, obj.y3))
        elif obj.yaml_tag == u"!Door":
            draw.set_color(*resources.key_colors[obj.key])
            graphics.set_line_width(5.0)
            draw.line(obj.x1, obj.y1, obj.x2, obj.y2)
            draw.set_color(*colors[True])
            graphics.set_line_width(1.0)
            draw.line(obj.x1, obj.y1, obj.x2, obj.y2)
        elif obj.yaml_tag == u"!Key":
            draw.set_color(1,1,1,1)
            resources.key_images[obj.number].blit(obj.x, obj.y)
            
    simple_objects_batch.draw()
    draw.set_color(1,1,1,1)
    for label in labels:
        draw.rect(
            label.x-label.content_width/2-3, label.y-label.content_height/2,
            label.x+label.content_width/2+3, label.y+label.content_height/2
        )
    label_batch.draw()
Пример #9
0
 def draw(self):
     for edge in self.edges.viewvalues():
         ax, ay = self.points[edge.a]
         bx, by = self.points[edge.b]
         if edge.counterpart:
             draw.line(ax,
                       ay,
                       bx,
                       by,
                       colors=(0, 255, 0, 255, 0, 255, 0, 255))
         else:
             draw.line(ax,
                       ay,
                       bx,
                       by,
                       colors=(255, 0, 0, 255, 0, 0, 255, 255))
     draw.set_color(1, 0, 0, 1)
     for point in self.points.viewvalues():
         draw.rect(point[0] - 5, point[1] - 5, point[0] + 5, point[1] + 5)
Пример #10
0
 def draw(self):
     """Internal use only."""
     if not self.visible: return
     if self.image != None:
         color = (1,1,1,1)
         if self.parent_group != None and self.selected: color = (0.8, 0.8, 0.8, 1)
         if self.pressed: color = (0.7, 0.7, 0.7, 1)
         graphics.set_color(*color)
         draw.image(self.image,self.x,self.y)
     else:
         color = (0,0,0,0)
         if self.parent_group != None and self.selected: color = (0,0,0, 0.3)
         if self.pressed: color = (0,0,0, 0.6)
         graphics.set_color(*color)
         draw.rect(self.x, self.y, self.x + self.width, self.y+self.height)
     if self.label != None:    
         graphics.set_color(1,1,1,1)
         draw.label(self.label)
     if self.more_draw != None: self.more_draw()
Пример #11
0
 def draw_tools(self):
     #toolbar background
     draw.set_color(0.8, 0.8, 0.8, 1)
     draw.rect(0,graphics.canvas_y,graphics.canvas_x,graphics.height)
     draw.rect(0,0,graphics.width,graphics.canvas_y)
     
     #buttons
     draw.set_color(1,1,1,1)
     for button in self.toolbar: button.draw()   #toolbar buttons
     for button in self.buttons: button.draw()   #bottom buttons
     for label in self.labels: draw.label(label) #text labelsr
     
     tool.controlspace.draw()
     
     #divider lines
     draw.set_color(0,0,0,1)
     graphics.set_line_width(1.0)
     draw.line(0, graphics.canvas_y, graphics.width, graphics.canvas_y)
     draw.line(
         graphics.canvas_x, graphics.canvas_y, 
         graphics.canvas_x, graphics.height
     )
Пример #12
0
 def init_color_array(self):    
     array_w = self.width/self.step_x
     array_h = self.height/self.step_y
     array = [[0 for y in range(int(array_h))] for x in range(int(array_w))]
     for x in xrange(0,int(array_w)):
         r,g,b = 0.0, 0.0, 0.0
         #The expressions here are simplified, so they may look confusing.
         if x < array_w/6:       r, g    = 1.0, x/array_w*6
         elif x < array_w/3:     r, g    = 2.0 - x*6/array_w, 1.0
         elif x < array_w/2:        g, b = 1.0, x*6/array_w-2
         elif x < array_w/3*2:      g, b = 4.0 - x*6/array_w, 1.0
         elif x < array_w/6*5:   r,    b = x*6/array_w-4, 1.0
         else:                   r,    b = 1.0, 6.0 - x*6/array_w
         
         for y in xrange(1,int(array_h)):
             a = y / array_h
             if a <= 0.5:
                a = a*1.6+0.2
                array[x][y] = (r*a,g*a,b*a,1.0)
             else:
                a = (a-0.5)*2
                array[x][y] = (r+(1-r)*a,g+(1-g)*a,b+(1-b)*a,1.0)
             graphics.set_color(color=array[x][y])
             draw.rect(
                 self.x+x*self.step_x,
                 self.y+y*self.step_y,
                 self.x+(x+1)*self.step_x,
                 self.y+(y+1)*self.step_y
             )
         if x < array_w/2:
             a = x*2/(array_w-2)
             array[x][0] = (a,a,a,1)
         else:
             array[x][0] = (-1,-1,-1,-1)
     self.array_w = array_w
     self.array_h = array_h
     self.array = array
     self.rainbow_colors = [array[x][3] for x in xrange(len(array))]
Пример #13
0
 def draw(self):
     if self.which_color == 0:
         if graphics.line_rainbow():
             draw.rainbow(self.x,self.y,self.x+self.width,self.y+self.height)
         else:
             graphics.set_color(color=graphics.line_color)
             draw.rect(self.x, self.y, self.x+self.width, self.y+self.height)
     else:
         if graphics.fill_rainbow():
             draw.rainbow(self.x,self.y,self.x+self.width,self.y+self.height)
         else:
             graphics.set_color(color=graphics.fill_color)
             draw.rect(self.x, self.y, self.x+self.width, self.y+self.height)
     
     if self.selected:
         graphics.set_color(1,1,1,1)
         graphics.set_line_width(1)
         draw.ellipse_outline(self.x+5, self.y+5, self.x+self.width-5, self.y+self.height-5)
         graphics.set_color(0,0,0,1)
         draw.ellipse_outline(self.x+7, self.y+7, self.x+self.width-7, self.y+self.height-7)
     graphics.set_line_width(1.0)    
     graphics.set_color(0,0,0,1)
     draw.rect_outline(self.x, self.y, self.x+self.width, self.y+self.height)
Пример #14
0
 def draw_initial(self):
     """Render the image"""
     graphics.set_color(1,1,1,1)
     draw.rect(self.x,self.y+self.height/2,self.x+self.width,self.y+self.height)
     graphics.set_color(0,0,0,1)
     draw.rect(self.x,self.y,self.x+self.width,self.y+self.height/2)
     for x in xrange(0,int(self.array_w)):
         for y in xrange(0,int(self.array_h)):
             #if y == 0 and x > int(self.array_w/2): break
             graphics.set_color(color=self.array[x][y])
             draw.rect(
                 self.x+x*self.step_x,
                 self.y+y*self.step_y,
                 self.x+(x+1)*self.step_x,
                 self.y+(y+1)*self.step_y
             )
     draw.rainbow(self.x+self.width*0.5,self.y,self.x+self.width*0.75,self.y+self.step_y)
     draw.rainbow(self.x+self.width*0.75,self.y,self.x+self.width,self.y+self.step_y)
     temp_image = pyglet.image.get_buffer_manager().get_color_buffer().get_image_data()
     self.image = temp_image.get_texture().get_region(
         self.x, self.y, int(self.width), int(self.height)
     )
Пример #15
0
 def draw(self):
     draw.set_color(*self.color)
     draw.rect(self.x, self.y, self.x+self.w, self.y+self.h)
Пример #16
0
    def draw_rect(self, rect, color=draw.WHITE, filled=True):
        rect = Rect((rect.x - self.origin.x) * self.scale,
                    (rect.y - self.origin.y) * self.scale,
                    rect.width * self.scale, rect.height * self.scale)

        draw.rect(self.screen, rect, color=color, filled=filled)