def centerel(elsize, contsize):
    """Centers an element of the given size in the container of the given size.
    Returns the coordinates of the top-left corner of the element relative to
    the container."""
    w, h = elsize
    W, H = contsize
    x = (W-w)//2
    y = (H-h)//2
    return (x, y)