def delete(self): # TODO fix this shit if getattr(self.obj, 'token_inside', None): clean_polygon_inside(self.obj) self.obj.widget.point_set.remove(self) self.obj.widget.canvas.remove_group(str(hash(self)))
def update_position(self, x, y): self.x = x self.y = y draw_point(self) # TODO fix this shit if getattr(self.obj, 'token_inside', None): clean_polygon_inside(self.obj) self.obj.draw()
def move_active_point(self, widget): clean_polygon_inside(self) try: index = self.points.index(widget.selected_point) except ValueError: pass else: self.points[index], self.points[index-1] = ( self.points[index-1], self.points[index] ) self.draw()
def draw_texture(self, widget): clean_polygon_inside(self) max_x = max(point.x for point in self.points) max_y = max(point.y for point in self.points) min_x = min(point.x for point in self.points) min_y = min(point.y for point in self.points) im = Image.open('files/wall.png') im.load() if self.settings.bump_mapping: bump_map = Image.open('files/normal_wall.png') bump_map.load() bump_map = bump_map.resize((max_x - min_x, max_y - min_y)) else: bump_map = None if self.settings.cut_colors: pallet = cut_pallet(im, self.settings.color_count) array = list(im.getdata()) new_array = [ closest_color_from_pallet(pallet, color) for color in array ] im = Image.new(im.mode, im.size) im.putdata(new_array) im = im.rotate(180) resided = im.resize((max_x - min_x, max_y - min_y)) rgb_im = resided.convert('RGB') if self.settings.shadows: lights = [ obj for obj in self.widget.object_set if isinstance(obj, Light) ] viewer = [ obj for obj in self.widget.object_set if isinstance(obj, Viewer) and not isinstance(obj, Light) ] if len(viewer) == 1: re_draw_polygon_inside( self, texture=rgb_im, min_x=min_x, min_y=min_y, viewer=viewer[0], lights=lights, bump_map=bump_map ) else: re_draw_polygon_inside( self, texture=rgb_im, min_x=min_x, min_y=min_y )
def add_point(self, x, y, widget): clean_polygon_inside(self) point = Point(x, y, self) self.points.append(point) widget.selected_point = point self.draw()