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.
1
canvas.move_to(P2::new(430.,225.));
2
canvas.line_to(P2::new(83.,225.));
3
canvas.line_to(P2::new(256.,525.));
4
canvas.close_path();
5
canvas.set_stroke_width(2.);
6
canvas.stroke();
Copied!
A path created immediately.
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:
1
let triangle =Ngon::triangle(world.center(),200.);
2
let repeated =std::iter::successors(Some(triangle),|t|{
3
Some(t.clone().scale(0.9))
4
});
5
β
6
for triangle in repeated.take(15){
7
canvas.paint(Stroked{
8
width:2.,
9
element: triangle,
10
});
11
}
Copied!
A path generated, held, and manipulated.
Valora provides Ngon for equilateral shapes, Ellipse for ellipses, and Polygon for all other shapes.