def keep_drawing(self, x, y, dx, dy): self.x2, self.y2 = x, y graphics.set_color(1,1,1,1) draw.image(self.canvas_pre,graphics.canvas_x,graphics.canvas_y) graphics.set_line_width(graphics.user_line_size) graphics.set_color(color=self.line_color) draw.line(self.x1, self.y1, self.x2, self.y2)
def keep_drawing(self, x, y, dx, dy): self.x2, self.y2 = x, y graphics.set_color(1,1,1,1) draw.image(self.canvas_pre,graphics.canvas_x,graphics.canvas_y) if graphics.fill_shapes: draw.rect(self.x1, self.y1, self.x2, self.y2, self.fill_colors) if graphics.outline_shapes: graphics.set_line_width(graphics.user_line_size) graphics.set_color(color=self.line_color) draw.rect_outline(self.x1, self.y1, self.x2, self.y2)
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()
def keep_drawing(self, x, y, dx, dy): self.rx, self.ry = x, y radius = math.sqrt( (self.rx - self.x)*(self.rx - self.x)+(self.ry - self.y)*(self.ry - self.y) ) theta = math.atan2(self.ry-self.y, self.rx-self.x) graphics.set_color(1,1,1,1) draw.image(self.canvas_pre,graphics.canvas_x,graphics.canvas_y) if graphics.fill_shapes: #graphics.set_color(color=self.fill_color) draw.ngon(self.x,self.y,radius,self.sides,theta, self.fill_colors) if graphics.outline_shapes: graphics.set_line_width(graphics.user_line_size) graphics.set_color(color=self.line_color) draw.ngon_outline(self.x, self.y, radius, self.sides, theta)
def keep_drawing(self, x, y, dx, dy): self.x2, self.y2 = x, y graphics.set_color(1, 1, 1, 1) draw.image(self.canvas_pre, graphics.canvas_x, graphics.canvas_y) if ( graphics.fill_shapes and abs(self.x2 - self.x1) >= graphics.user_line_size and abs(self.y2 - self.y1) >= graphics.user_line_size ): graphics.set_color(color=self.fill_color) draw.ellipse(self.x1, self.y1, self.x2, self.y2) if graphics.outline_shapes: graphics.set_line_width(graphics.user_line_size) graphics.set_color(color=self.line_color) draw.ellipse_outline(self.x1, self.y1, self.x2, self.y2)
def draw_selection_image(self): if self.selection == None: return self.img_x, self.img_y = min(self.x1, self.x2), min(self.y1, self.y2) graphics.set_color(1,1,1,1) self.draw_selection_mask(self.x1,self.y1,self.x2,self.y2) graphics.init_stencil_mode() graphics.set_color(1,1,1,1) draw.rect(self.x1,self.y1,self.x2,self.y2) graphics.set_color(0,0,0,1) self.draw_selection_mask(self.x1,self.y1,self.x2,self.y2) graphics.stop_drawing_stencil() graphics.set_color(1,1,1,1) draw.image(self.selection, self.img_x, self.img_y) graphics.reset_stencil_mode()
def keep_drawing(self, x, y, dx, dy): x = min(max(x, graphics.canvas_x), graphics.width) y = min(max(y, graphics.canvas_y), graphics.height) graphics.set_color(1,1,1,1) draw.image(self.canvas_pre,0,0) if self.dragging: self.x1 = x - self.mouse_offset_x self.y1 = y - self.mouse_offset_y self.x2, self.y2 = self.x1 + self.w, self.y1 + self.h self.img_x = min(self.x1, self.x2) self.img_y = min(self.y1, self.y2) graphics.set_color(1,1,1,1) 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() else: self.x2, self.y2 = x, y self.w = self.x2 - self.x1 self.h = self.y2 - self.y1 self.img_x, self.img_y = min(self.x1, self.x2), min(self.y1, self.y2) self.draw_selection_shape()
def draw(self): # TODO show a caret, maybe use a real TextLayout graphics.set_color(1,1,1,1) draw.image(self.canvas_pre,graphics.canvas_x,graphics.canvas_y) draw.label(self.label)
def unselect(self): graphics.set_color(1,1,1,1) draw.image(self.canvas_pre,0,0) graphics.set_color(1,1,1,1)