コード例 #1
0
 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
コード例 #2
0
ファイル: tool.py プロジェクト: irskep/splatterboard
 def keep_drawing(self, x, y, dx, dy):
     self.x2, self.y2 = x, y
     self.rot = math.degrees(-math.atan2(y-self.start_y, x-self.start_x))
     self.scale = math.sqrt((x-self.start_x)*(x-self.start_x)+(y-self.start_y)*(y-self.start_y))
     self.scale /= self.this_stamp.width//2
     graphics.set_color(1,1,1,1)
     draw.image(self.canvas_pre,graphics.canvas_x,graphics.canvas_y)
     self.draw_stamp(x, y)
コード例 #3
0
ファイル: colorpicker.py プロジェクト: irskep/splatterboard
 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)
コード例 #4
0
ファイル: colorpicker.py プロジェクト: irskep/splatterboard
 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))]
コード例 #5
0
ファイル: gui.py プロジェクト: irskep/splatterboard
 def draw(self):
     if not self.visible: return
     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=color)
     draw.image(self.image,self.x,self.y)
     if self.image_2 != None:
         graphics.set_color(1,1,1,1)
         graphics.call_twice(pyglet.gl.glPushMatrix)
         if self.scale_factor != 1.0:
             pyglet.gl.glScalef(self.scale_factor, self.scale_factor, self.scale_factor)
         graphics.call_twice(
             pyglet.gl.glTranslatef, 
             self.x/self.scale_factor, self.y/self.scale_factor, 0
         )
         if self.centered:
             graphics.call_twice(
                 pyglet.gl.glTranslatef,
                 self.image.width/self.scale_factor/2, self.image.height/self.scale_factor/2, 0
             )
         draw.image(self.image_2, 0, 0)
         graphics.call_twice(pyglet.gl.glPopMatrix)
コード例 #6
0
ファイル: gui.py プロジェクト: irskep/splatterboard
 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)
コード例 #7
0
ファイル: gui.py プロジェクト: irskep/splatterboard
 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)
コード例 #8
0
ファイル: gui.py プロジェクト: irskep/splatterboard
 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()
コード例 #9
0
ファイル: colorpicker.py プロジェクト: irskep/splatterboard
 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)
     )
コード例 #10
0
ファイル: tool.py プロジェクト: irskep/splatterboard
 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)
コード例 #11
0
ファイル: tool.py プロジェクト: irskep/splatterboard
 def draw_brush():
     graphics.set_color(0,0,0,1)
     graphics.set_line_width(size)
     draw.points((x+w/2,y+h/2))