def on_draw(self, dt=0):
     self.try_redraw()
     if not graphics.drawing:
         #toolbar background
         #draw.rect(0,graphics.canvas_y,graphics.canvas_x,graphics.height)
         draw.gradient(
             0, graphics.canvas_y, graphics.canvas_x, graphics.height,
             self.toolbar_bg_1, self.toolbar_bg_2,
             self.toolbar_bg_2, self.toolbar_bg_1
         )
         #draw.rect(0,0,graphics.width,graphics.canvas_y)
         draw.gradient(
             0, 0, graphics.width, graphics.canvas_y,
             self.toolbar_bg_1, self.toolbar_bg_2,
             self.toolbar_bg_2, self.toolbar_bg_1
         )
         #buttons
         graphics.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 labels
         self.colorpicker.draw()                     #color picker
         #self.colordisplay.draw()                    #line/fill color selector
         tool.controlspace.draw()
         #divider lines
         graphics.set_color(0,0,0,1)
         graphics.set_line_width(1.0)
         graphics.call_twice(pyglet.gl.glDisable,pyglet.gl.GL_BLEND)
         draw.line(0, graphics.canvas_y, graphics.width, graphics.canvas_y)
         draw.line(graphics.canvas_x, graphics.canvas_y, graphics.canvas_x, graphics.height)
         graphics.call_twice(pyglet.gl.glEnable,pyglet.gl.GL_BLEND)
     self.drawn_this_frame = False
Example #2
0
 def draw(self):
     """Render the image if it has not been rendered yet. Just draw the image if it has."""
     if self.rendered:
         graphics.set_color(1,1,1,1)
         draw.image(self.image,self.x,self.y)
     else:
         self.rendered = True
         self.draw_initial()
     graphics.set_color(0,0,0,1)
     graphics.set_line_width(1)
     draw.rect_outline(self.x,self.y,self.x+self.width,self.y+self.height)
Example #3
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()
Example #4
0
 def draw(self):    
     if not self.visible: return
     super(PolygonButton, self).draw()
     
     x, y = self.x+self.width/2, self.y+self.height/2
     poly = self.generate_polygon(x,y,x,self.y+self.height*0.9,self.sides)
     if self.fill:
         if graphics.fill_rainbow():
             graphics.set_color(1,1,1,1)
         else:
             graphics.set_color(color=graphics.fill_color)
         draw.polygon(poly)
     if self.outline:
         graphics.set_line_width(2)
         if graphics.line_rainbow():
             graphics.set_color(1,1,1,1)
         else:
             graphics.set_color(color=graphics.line_color)
         draw.line_loop(poly)
         draw.points(poly)
Example #5
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
     )
Example #6
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)
Example #7
0
 def draw_line():
     graphics.set_line_width(size)
     graphics.set_color(0,0,0,1)
     draw.line(x+15,y+10, x+w-15, y+h-10)
Example #8
0
 def draw_brush():
     graphics.set_color(0,0,0,1)
     graphics.set_line_width(size)
     draw.points((x+w/2,y+h/2))