def save(self): if self.busy: return self.canvas_image = graphics.get_snapshot() img = graphics.get_canvas() img = img.get_region(1,1,img.width-1,img.height-1) if not settings.settings['fullscreen']: self.save_2(0,img) return graphics.main_window.set_fullscreen(False) pyglet.clock.schedule_once(self.save_2,0.5,img) self.busy = True
def on_mouse_press(self, x, y, button, modifiers): self.try_redraw() if x > graphics.canvas_x and y > graphics.canvas_y: if self.current_tool.ask_undo(): self.push_undo(graphics.get_canvas()) graphics.drawing = True graphics.enter_canvas_mode() self.current_tool.start_drawing(x,y) else: #pick a color if click was in color picker if self.colorpicker.coords_inside(x,y): graphics.set_selected_color(self.colorpicker.get_color(x,y))
def init(self, stamp_folder): self.stamp_folder = os.path.join('Stamps', stamp_folder) self.canvas_pre = graphics.get_canvas() loaded_items = resources.load([self.stamp_folder])[self.stamp_folder] def get_stamp_switcher(stamp): def switch(): self.this_stamp = stamp return switch images = [resources.StampMove, resources.StampRotateScale]#, resources.StampScale] functions = [self.select_move, self.select_rotatescale]#, self.select_scale] self.bg2 = generate_button_row(images, functions, 25, 5) images = [getattr(resources, i) for i in loaded_items] functions = [get_stamp_switcher(s) for s in images] self.bg = generate_button_row(images, functions, centered=True, page=True) self.this_stamp = images[0]
def push_undo(canvas_image_to_push=None): """Pushes the passed image onto the undo stack. See selection tool for an example.""" if canvas_image_to_push == None: canvas_image_to_push = graphics.get_canvas() painting_env.push_undo(canvas_image_to_push)
def stop_drawing(self, x, y): self.keep_drawing(x, y, 0, 0) graphics.call_twice(self.draw_stamp, x, y) self.canvas_pre = graphics.get_canvas() if self.mode == MOVE: graphics.show_cursor()
def canvas_changed(self): self.canvas_pre = graphics.get_canvas()