Замена линий на кривые

Jek0011

Новичок
Пользователь
Авг 24, 2021
2
0
1
Есть код который по заданным точкам проводит прямую линию в результате получаем рисунок.
256-4024-tsp.png
Код:
def get_routes(solution, routing, manager):
    """Get vehicle routes from a solution and store them in an array."""
    # Get vehicle routes and store them in a two dimensional array whose
    # i,j entry is the jth location visited by vehicle i along its route.
    routes = []
    for route_nbr in range(routing.vehicles()):
        index = routing.Start(route_nbr)
        route = [manager.IndexToNode(index)]
        while not routing.IsEnd(index):
            index = solution.Value(routing.NextVar(index))
            route.append(manager.IndexToNode(index))
        routes.append(route)
    return routes[0]


def draw_routes(nodes, path):
    """Takes a set of nodes and a path, and outputs an image of the drawn TSP path"""
    tsp_path = []
    for location in path:
        tsp_path.append(nodes[int(location)])

    original_image = Image.open(ORIGINAL_IMAGE)
    width, height = original_image.size

    tsp_image = Image.new("RGBA", (width, height), color='white')
    tsp_image_draw = ImageDraw.Draw(tsp_image)
    # tsp_image_draw.point(tsp_path,fill='black')
    tsp_image_draw.line(tsp_path, fill='black', width=1)
    tsp_image = tsp_image.transpose(Image.FLIP_TOP_BOTTOM)
    FINAL_IMAGE = IMAGE_TSP.replace("-stipple.tsp", "-tsp.png")
    tsp_image.save(FINAL_IMAGE)
    print("TSP solution has been drawn and can be viewed at", FINAL_IMAGE)

Как сделать чтобы вместо линий между точками были кривые.
eA97_m3Cl28.jpg
 

Форум IT Специалистов