# Painting the Canvas

The central component of valora is the [Canvas](https://docs.rs/valora/0.2.0/valora/canvas/struct.Canvas.html). The canvas supports many low level drawing operations such as drawing paths and stroking or filling them. For example, we can draw a triangle like this:

```rust
canvas.set_color(LinSrgb::new(1., 0., 1.));
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(10.);
canvas.stroke();
```

![A stroked triangle.](https://1276503419-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lw1VWDRh9_wPSAWr8kv%2F-LwF-QUVynid6T93Owpa%2F-LwF205PlsMoMRPanVM0%2F1.gif?alt=media\&token=6b0ce884-141a-4109-bded-bee3b32b2743)

Thankfully in valora we don't have to work at such a low level unless we want to. Valora defines the [Paint](https://docs.rs/valora/0.2.0/valora/paint/trait.Paint.html) trait, which is implemented by any type that knows how to represent itself on a canvas. We can instead draw an equilateral triangle like this:

```rust
canvas.set_color(LinSrgb::new(1., 0., 1.));
canvas.paint(Stroked {
    width: 2.,
    element: Ngon::triangle(world.center(), /*radius=*/200.),
});
```

You can implement `Paint` for your own patterns and easily compose them, as we will see in later chapters.
