| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -29,17 +29,14 @@ class Point: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__viewport_width = viewport_width | 
					 | 
					 | 
					 | 
					        self.__viewport_width = viewport_width | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__viewport_height = viewport_height | 
					 | 
					 | 
					 | 
					        self.__viewport_height = viewport_height | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        half_point = floor(point_size / 2.0) | 
					 | 
					 | 
					 | 
					        self.__calculate_hitbox() | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__check_window_bounds(x, y) | 
					 | 
					 | 
					 | 
					        self.__check_window_bounds(x, y) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__selected = False | 
					 | 
					 | 
					 | 
					        self.__selected = False | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__top_left_corner = (self.__x - half_point, | 
					 | 
					 | 
					 | 
					        self.__attributes = [] | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                  self.__y + half_point) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__bottom_right_corner = (self.__x + half_point, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                      self.__y - half_point) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @property | 
					 | 
					 | 
					 | 
					    @property | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def x(self): | 
					 | 
					 | 
					 | 
					    def x(self): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return self.__x | 
					 | 
					 | 
					 | 
					        return self.__x | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -56,6 +53,26 @@ class Point: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def selected(self): | 
					 | 
					 | 
					 | 
					    def selected(self): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return self.__selected | 
					 | 
					 | 
					 | 
					        return self.__selected | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    @property | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    def attributes(self): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return self.__attributes | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    def add_attribute(self, attr): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        self.__attributes.append(attr) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    def __calculate_hitbox(self): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        """ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        Calculates the hit box for the point given the current | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        position (center) and the point size. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        """ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        half_point = floor(self.point_size / 2.0) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        self.__top_left_corner = (self.__x - half_point, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                                  self.__y + half_point) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        self.__bottom_right_corner = (self.__x + half_point, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                                  self.__y - half_point) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def __check_window_bounds(self, x, y): | 
					 | 
					 | 
					 | 
					    def __check_window_bounds(self, x, y): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        """ | 
					 | 
					 | 
					 | 
					        """ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Simple window bound check that raises an exception when | 
					 | 
					 | 
					 | 
					        Simple window bound check that raises an exception when | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -91,6 +108,10 @@ class Point: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__x += dx | 
					 | 
					 | 
					 | 
					        self.__x += dx | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__y += dy | 
					 | 
					 | 
					 | 
					        self.__y += dy | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        # It's important to note as we move the point we need to | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        # make sure we are constantly updating it's hitbox. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        self.__calculate_hitbox() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def __eq__(self, other): | 
					 | 
					 | 
					 | 
					    def __eq__(self, other): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        """ | 
					 | 
					 | 
					 | 
					        """ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Override for class equality. | 
					 | 
					 | 
					 | 
					        Override for class equality. | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -115,7 +136,7 @@ class Point: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        s = "<POINT " | 
					 | 
					 | 
					 | 
					        s = "<POINT " | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        s += "X: {} | Y: {} | ".format(self.__x, self.__y) | 
					 | 
					 | 
					 | 
					        s += "X: {} | Y: {} | ".format(self.__x, self.__y) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        s += "SIZE: {} | ".format(self.__point_size) | 
					 | 
					 | 
					 | 
					        s += "SIZE: {} | ".format(self.__point_size) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        s += "VIEWPORT_WIDTH: {} |".format(self.__viewport_width) | 
					 | 
					 | 
					 | 
					        s += "VIEWPORT_WIDTH: {} | ".format(self.__viewport_width) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        s += "VIEWPORT_HEIGHT: {}".format(self.__viewport_height) | 
					 | 
					 | 
					 | 
					        s += "VIEWPORT_HEIGHT: {}".format(self.__viewport_height) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        s += ">" | 
					 | 
					 | 
					 | 
					        s += ">" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -186,7 +207,6 @@ class PointSet: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					               calculations. | 
					 | 
					 | 
					 | 
					               calculations. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        """ | 
					 | 
					 | 
					 | 
					        """ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__points = set() | 
					 | 
					 | 
					 | 
					        self.__points = set() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__attributes = {} | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__point_size = point_size | 
					 | 
					 | 
					 | 
					        self.__point_size = point_size | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__viewport_width = viewport_width | 
					 | 
					 | 
					 | 
					        self.__viewport_width = viewport_width | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__viewport_height = viewport_height | 
					 | 
					 | 
					 | 
					        self.__viewport_height = viewport_height | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -203,9 +223,22 @@ class PointSet: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        attributes_equal = (attributes_equal and | 
					 | 
					 | 
					 | 
					        attributes_equal = (attributes_equal and | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                           (len(self.__points) == len(other_points))) | 
					 | 
					 | 
					 | 
					                           (len(self.__points) == len(other_points))) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        # This is O(N^2) - can it be improved using some sort of | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        # find function? | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for p in self.__points: | 
					 | 
					 | 
					 | 
					        for p in self.__points: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            attributes_equal = (attributes_equal and | 
					 | 
					 | 
					 | 
					            for i, op in enumerate(other_points): | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                (self.__attributes[p] == other.attributes(p))) | 
					 | 
					 | 
					 | 
					                if p == op: | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    attributes_equal = (attributes_equal and | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                                        (p.attributes == op.attributes)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    continue | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                if i == len(other_points) - 1: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    # In this case we have enumerated the entire second | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    # set and not found anything. We can safely say | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    # the two sets are not equal and return. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    attribute_equals = False | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    break | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return (self.__points == other_points and | 
					 | 
					 | 
					 | 
					        return (self.__points == other_points and | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                attributes_equal and | 
					 | 
					 | 
					 | 
					                attributes_equal and | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -279,8 +312,11 @@ class PointSet: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        point = Point(x, y, self.__point_size, | 
					 | 
					 | 
					 | 
					        point = Point(x, y, self.__point_size, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                      self.__viewport_width, self.__viewport_height) | 
					 | 
					 | 
					 | 
					                      self.__viewport_width, self.__viewport_height) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        for attr in attrs: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            point.add_attribute(attr) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__points.add(point) | 
					 | 
					 | 
					 | 
					        self.__points.add(point) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__attributes[point] = attrs | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def remove_point(self, x, y): | 
					 | 
					 | 
					 | 
					    def remove_point(self, x, y): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        """ | 
					 | 
					 | 
					 | 
					        """ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -304,15 +340,3 @@ class PointSet: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        # In place set difference | 
					 | 
					 | 
					 | 
					        # In place set difference | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.__points = self.__points - matched | 
					 | 
					 | 
					 | 
					        self.__points = self.__points - matched | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        # Remove associated attributes | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for point in matched: | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            self.__attributes.pop(point) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def attributes(self, point): | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        """ | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Returns the attribute array for a given point. | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        @param point The point to get attributes for.. | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        """ | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return self.__attributes[point] | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |