def _transform_rect(rect, template):
    """Calculates the position of a relative notated rectangle within
    another rectangle.

    Parameters
    ----------
    rect : Rectangle
        The container rectangle to contain the other reactangle.
    template : Rectangle
        the rectangle to be contained in the other rectangle.
    """
    assert len(rect) == len(template
        ) == 4, 'Wrong inputs : [x, y, width, height]'
    x = rect[0] + template[0] * rect[2]
    y = rect[1] + template[1] * rect[3]
    w = rect[2] * template[2]
    h = rect[3] * template[3]
    return [x, y, w, h]
