Exemplo n.º 1
0
 def select(self):
     self.canvas_pre = graphics.get_canvas()
     self.bg = tool.generate_line_selector()
     
     self.button_group = gui.ButtonGroup()
     buttons = []
     
     def generate_side_function(n):
         def temporary_function():
             self.sides = n
         return temporary_function
     
     def generate_poly_button(x, y, w, h, n):
         def poly_func():
             theta = 0
             y_offset = 0
             if n == 3: y_offset = -5
             if n % 2 == 1: theta = -math.pi/n/2
             poly = draw._concat(draw._iter_ngon(x+w/2,y+h/2+y_offset,(w-10)/2,n,theta))
             graphics.set_color(1,1,1,1)
             draw.polygon(poly)
             graphics.set_color(0,0,0,1)
             graphics.set_line_width(1)
             draw.line_loop(poly)
         return poly_func
     
     w, h = resources.SquareButton.width, resources.SquareButton.height
     for i in xrange(0,self.num_buttons):
         temporary_button = gui.Button(resources.SquareButton, generate_side_function(i+3),
                                         i*w+5, h+5, "", parent_group=self.button_group,
                                         more_draw = generate_poly_button(i*w+5, h+5, w, h, i+3))
         buttons.append(temporary_button)
         tool.controlspace.add(temporary_button)
         buttons[0].select()
         buttons[0].action()
Exemplo n.º 2
0
 def select(self):
     self.canvas_pre = graphics.get_canvas()
     self.bg1 = tool.generate_brush_selector()
     
     images = [resources.Spray, resources.Spray_double, resources.Spray_bubble, resources.Fire]
     functions = [self.select_single, self.select_double, self.select_bubble, self.select_fire]
     self.bg2 = tool.generate_button_row(images, functions)
Exemplo n.º 3
0
 def init(self):
     if not self.should_init: return
     self.should_init = False
     graphics.set_cursor(graphics.cursor['CURSOR_WAIT'])
     self.canvas_pre = graphics.get_canvas()
     #Convert to array
     data = ""
     data = self.canvas_pre.get_data('RGBA',self.canvas_pre.width*4)
     #Convert to integer
     self.pixel_data = map(ord, list(data))
     graphics.set_cursor(graphics.cursor['CURSOR_DEFAULT'])
Exemplo n.º 4
0
 def finalize_selection(self):
     if self.selection != None:
         graphics.set_color(1,1,1,1)
         draw.image(self.canvas_pre,0,0)
         if not self.copy:
             self.draw_selection_mask(
                 self.original_x, self.original_y,
                 self.original_x+abs(self.w), self.original_y+abs(self.h)
             )
         self.draw_selection_image()
         self.canvas_pre = graphics.get_snapshot()
         self.undo_image = graphics.get_canvas()
Exemplo n.º 5
0
 def select(self):
     self.canvas_pre = graphics.get_snapshot()
     self.undo_image = graphics.get_canvas()
     self.selection = None
     self.x1, self.y1, self.x2, self.y2 = 0.0, 0.0, 0.0, 0.0
     self.img_x, self.img_y = 0.0, 0.0
     self.w, self.h = 0.0, 0.0
     self.original_x, self.original_y = 0.0, 0.0
     self.mouse_offset_x, self.mouse_offset_y = 0.0, 0.0
     self.dragging = False
     self.mouse_start_x, self.mouse_start_y = -1, -1
     
     images = [
         resources.Selection, resources.SelectEllipse,
         resources.SelectionCopy, resources.SelectEllipseCopy
     ]
     functions = [
         self.select_rect, self.select_ellipse,
         self.select_rect_copy, self.select_ellipse_copy
     ]
     self.bg = tool.generate_button_row(images, functions)
Exemplo n.º 6
0
	def stop_drawing(self, x, y):
		self.canvas_pre = graphics.get_canvas()
Exemplo n.º 7
0
	def select(self):
		self.writing = False
		self.canvas_pre = graphics.get_canvas()
Exemplo n.º 8
0
 def stop_drawing(self, x, y):
     self.keep_drawing(x, y, 0, 0)
     self.canvas_pre = graphics.get_canvas()
Exemplo n.º 9
0
 def canvas_changed(self):
     self.canvas_pre = graphics.get_canvas()
Exemplo n.º 10
0
 def select(self):
     self.canvas_pre = graphics.get_canvas()
     self.bg = tool.generate_line_selector()