def polygon_to_path(polygon):
    """
    Load shapely Polygon objects into a trimesh.path.Path2D object

    Parameters
    -------------
    polygon : shapely.geometry.Polygon
      Input geometry

    Returns
    -------------
    kwargs : dict
      Keyword arguments for Path2D constructor
    """
    # start with a single polyline for the exterior
    entities = deque([Line(points=np.arange(
        len(polygon.exterior.coords)))])
    # start vertices
    vertices = np.array(polygon.exterior.coords).tolist()

    # append interiors as single Line objects
    for boundary in polygon.interiors:
        entities.append(Line(np.arange(len(boundary.coords)) +
                             len(vertices)))
        # append the new vertex array
        vertices.extend(boundary.coords)

    # make sure result arrays are numpy
    kwargs = {'entities': np.array(entities),
              'vertices': np.array(vertices)}

    return kwargs
Load shapely Polygon objects into a trimesh.path.Path2D object

    Parameters
    -------------
    polygon : shapely.geometry.Polygon
      Input geometry

    Returns
    -------------
    kwargs : dict
      Keyword arguments for Path2D constructor