Help with kurbo flatten

I'm currently making a passion project in which I need to read an svg file and convert it into a path, and I'm using kurbo for that because frankly, I don't want to write that myself. I'm able to get the path, and I need to get n roughly equally-spaced points around it.

What I thought of doing was converting it to lines (because they're easier than cubic beziers), and then looping through it to get the points I need. But the part I'm stuck on is converting it to lines. There's path.flatten for that, but it works differently from what I'd expect.

It takes in a tolerance and a callback which is called for each point. I want to collect those points into a BezPath. And I have no idea how to do that.

I tried doing path.flatten(0.1, new_path.push), using new_path.push as the callback to automatically push new points, but that didn't compile.

What's the error? You may just need to do

path.flatten(0.1, |segment| new_path.push(segment));

Note that push takes two arguments -- more generally, Self-receivers like &mut self are an argument, and method call syntax is a form of syntactic sugar.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.