def add_texture(self, width, height, name):
        TexturePacker.add_texture(self, width, height, name)
        result = None

        if self.heuristic == FreeRectChoiceHeuristicEnum.RectBestShortSideFit:
            result = self._find_position_for_new_node_best_short_side_fit(width, height)
        elif self.heuristic == FreeRectChoiceHeuristicEnum.RectBestLongSideFit:
            result = self._find_position_for_new_node_best_long_side_fit(width, height)
        elif self.heuristic == FreeRectChoiceHeuristicEnum.RectBestAreaFit:
            result = self._find_position_for_new_node_best_area_fit(width, height)
        elif self.heuristic == FreeRectChoiceHeuristicEnum.RectBottomLeftRule:
            result = self._find_position_for_new_node_bottom_left(width, height)
        elif self.heuristic == FreeRectChoiceHeuristicEnum.RectContactPointRule:
            result = self._find_position_for_new_node_contact_point(width, height)
        else:
            raise NotImplementedError('Unknown MaxRects Heuristic encountered')

        if result[0] is None:
            raise PackerError('Failed to fit in %s' % (name))

        if (result[0].get_height() == 0):
            return result[0]

        if (result[0].y2) > self.bin_height:
            raise PackerError('Can not fit in vertically %s' % (str(result[0])))

        if (result[0].x2) > self.bin_width:
            raise PackerError('Can not fit in horizontally %s' % (str(result[0])))

        self._place_rect(result[0])
        return result[0]
 def __init__(self, method, width=0, height=0):
     TexturePacker.__init__(self)
     self.used_rect_list = []
     self.free_rect_list = []
     self.bin_width = width
     self.bin_height = height
     self.free_rect_list.append(Rect.InitWithDim(0, 0, self.bin_width, self.bin_height))
     self.heuristic = method
 def add_texture(self, width, height, name=""):
     TexturePacker.add_texture(self, width, height, name)
     self.longestEdge = width if (width > self.longestEdge) else self.longestEdge
     self.longestEdge = height if (height > self.longestEdge) else self.longestEdge
     self.totalArea += width * height
 def __init__(self):
     TexturePacker.__init__(self)
     self.freeArr = []
     self.longestEdge = 0
     self.totalArea = 0