The central component of valora is the Canvas. 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:
1
canvas.set_color(LinSrgb::new(1.,0.,1.));
2
canvas.move_to(P2::new(430.,225.));
3
canvas.line_to(P2::new(83.,225.));
4
canvas.line_to(P2::new(256.,525.));
5
canvas.close_path();
6
canvas.set_stroke_width(10.);
7
canvas.stroke();
Copied!
A stroked triangle.
β
Thankfully in valora we don't have to work at such a low level unless we want to. Valora defines the Paint 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: