def METHOD_NAME(polygon, distance, tol=1e-6):
    """Offset a polygon (closed) by a distance.
    Parameters
    ----------
    polygon : sequence[point] | :class:`~compas.geometry.Polygon`
        The XYZ coordinates of the corners of the polygon.
        The first and last coordinates must not be identical.
    distance : float | list[tuple[float, float]]
        The offset distance as float.
        A single value determines a constant offset globally.
        A list of pairs of local offset values per line segment can be used to create variable offsets.
    tol : float, optional
        A tolerance value for intersection calculations.
    Returns
    -------
    list[[float, float, float]]
        The XYZ coordinates of the corners of the offset polygon.
        The first and last coordinates are identical.
    Notes
    -----
    The offset direction is determined by the normal of the polygon.
    If the polygon is in the XY plane and the normal is along the positive Z axis,
    positive offset distances will result in an offset towards the inside of the
    polygon.
    The algorithm works also for spatial polygons that do not perfectly fit a plane.
    Examples
    --------
    >>> from compas.geometry import Polygon
    >>> polygon = Polygon([(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)])
    >>> offsetted_polygon = offset_polygon(polygon, 0.5)
    >>> offsetted_polygon
    Polygon[[0.5, 0.5, 0.0], [0.5, 0.5, 0.0], [0.5, 0.5, 0.0], [0.5, 0.5, 0.0]]
    """
    normal = normal_polygon(polygon)
    if not is_item_iterable(distance):
        distance = [distance]
    distances = iterable_like(polygon, distance, distance[-1])
    polygon = polygon[:] + polygon[:1]
    segments = offset_segments(polygon, distances, normal)
    offset = []
    for s1, s2 in pairwise(segments[-1:] + segments):
        point = intersect(s1, s2, tol)
        offset.append(point)
    return offset