def get_aligned_rects(
    surfaces:Iterable,
    retrieve_pos_from : {
        'widget_name': 'option_menu',
        'widget_kwargs': {
            'options': [
                'topleft', 'topright', 'bottomleft', 'bottomright',
                'midleft', 'midright', 'midtop', 'midbottom',
                'center'
            ]
        },
        'type': str,
    } = 'center',
    assign_pos_to : {
        'widget_name': 'option_menu',
        'widget_kwargs': {
            'options': [
                'topleft', 'topright', 'bottomleft', 'bottomright',
                'midleft', 'midright', 'midtop', 'midbottom',
                'center'
            ]
        },
        'type': str,
    } = 'center',
    offset_pos_by: 'python_literal' = (0, 0),
) -> [
    {'name': 'rects', 'type': list}
]:
    """Return list of rects positioned relative to each other."""

    rects = [surf.get_rect() for surf in surfaces]

    rects_copy = rects.copy()

    rects.reverse()

    while True:

        pos = getattr(rects.pop().move(offset_pos_by), retrieve_pos_from)

        if rects:

            setattr(rects[-1], assign_pos_to, pos)
            continue

        break

    return rects_copy
Return list of rects positioned relative to each other.
nodezator/graphman/capsulenode/pygamedefs.py