def lay_rects_like_table_ip(
        self,
        ### table boundary limit
        dimension_name,
        dimension_unit,
        max_dimension_value,
        ### cell/row positioning
        intercell_pos_from="topright",
        intercell_pos_to="topleft",
        interrow_pos_from="bottomleft",
        interrow_pos_to="topleft",
        ### cell to rect positioning
        cell_pos_from="center",
        rect_pos_to="center",
        cell_padding=0,
    ):
        """Align rects as if they were inside table cells.

        Parameters
        ==========
        """
        ### backup our topleft
        backed_up_topleft = self.topleft

        ###

        if max_dimension_value <= 0:

            raise ValueError(
                """
                    'max_dimension_value' must be a
                    positive integer.
                    """
            )

        ###
        rects = [rect for rect in self._get_all_rects()]

        ###
        quantity = len(rects)

        ###

        largest_width = max(rect.width for rect in rects)
        largest_height = max(rect.height for rect in rects)

        ###

        inflation_amount = cell_padding * 2

        single_cell_rect = Rect(0, 0, largest_width, largest_height).inflate(
            inflation_amount, inflation_amount
        )

        ###

        if dimension_unit == "pixels":

            largest_dimension = getattr(single_cell_rect, dimension_name)

            if largest_dimension > max_dimension_value:

                raise ValueError(
                    f"""
                    the table can't be constrained to
                    the {max_dimension_value}
                    {dimension_name} in pixels
                    because the cell exceeds that
                    measurement.
                  """
                )

        ### (what is quicker: copying or instantiating each
        ### rect?)

        cell_rects = [single_cell_rect.copy() for rect in rects]

        ###

        row_cells = []
        row_rectsman = self.__class__(row_cells.__iter__)

        row_breaking_limit = max_dimension_value

        get_limit = get_limit_func(dimension_name, dimension_unit)

        ###

        next_cell_pos = (0, 0)

        rects.reverse()

        while cell_rects:

            ## obtain and position a cell rect

            cell_rect = cell_rects.pop()

            setattr(cell_rect, intercell_pos_to, next_cell_pos)

            ## append it in a row of cells
            row_cells.append(cell_rect)

            ## break row if limit was surpassed

            if get_limit(row_cells) > row_breaking_limit:

                row_cells.pop()

                row_pos = getattr(row_rectsman, interrow_pos_from)

                row_cells.clear()

                row_cells.append(cell_rect)

                setattr(row_rectsman, interrow_pos_to, row_pos)

            ## obtain a rect and position it relative to
            ## the cell rect

            rect_pos = getattr(cell_rect, cell_pos_from)
            setattr(rects.pop(), rect_pos_to, rect_pos)

            ## obtain pos for next cell

            next_cell_pos = getattr(cell_rect, intercell_pos_from)

        ### restore our topleft
        self.topleft = backed_up_topleft
Align rects as if they were inside table cells.

        Parameters
        ==========
        
nodezator/rectsman/singlepos.py