> For the complete documentation index, see [llms.txt](https://paytonturnage.gitbook.io/valora/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://paytonturnage.gitbook.io/valora/path-creation.md).

# Path Creation

There are two ways to create a path in valora.

### Immediate

You could use draw commands on the canvas which immediately result in the path, but the path can only be drawn and not held for mutation or other work.&#x20;

```rust
canvas.move_to(P2::new(430., 225.));
canvas.line_to(P2::new(83., 225.));
canvas.line_to(P2::new(256., 525.));
canvas.close_path();
canvas.set_stroke_width(2.);
canvas.stroke();
```

![A path created immediately.](https://1276503419-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lw1VWDRh9_wPSAWr8kv%2F-LwFIVxP2E16aXpJH-Yr%2F-LwFO-rej_QLQd7sNXN6%2F1.gif?alt=media\&token=303d602d-16a6-4c75-a0d8-25fdd3df3169)

### Held

Alternatively, you could use some types provided by valora to define the path in a way you can hold, mutate, and otherwise do work with. For example, this code which repeats the triangle scaling down each time:

```rust
let triangle = Ngon::triangle(world.center(), 200.);
let repeated = std::iter::successors(Some(triangle), |t| {
    Some(t.clone().scale(0.9))
});

for triangle in repeated.take(15) {
    canvas.paint(Stroked {
        width: 2.,
        element: triangle,
    });
}
```

![A path generated, held, and manipulated.](https://1276503419-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lw1VWDRh9_wPSAWr8kv%2F-LwFIVxP2E16aXpJH-Yr%2F-LwFNl9v5FjinlXpsz1k%2F1.gif?alt=media\&token=1c186681-f538-4b98-88a6-a50e722a5d46)

Valora provides [Ngon](https://docs.rs/valora/0.2.0/valora/forms/struct.Ngon.html) for equilateral shapes, [Ellipse](https://docs.rs/valora/0.2.0/valora/forms/struct.Ellipse.html) for ellipses, and [Polygon](https://docs.rs/valora/0.2.0/valora/forms/struct.Polygon.html) for all other shapes.
