PistonDevelopers/graphics

Draw path

Opened this issue · 7 comments

Hi,
Is there a way to draw multiple points that are collected by lines? The polygon method fills the shape. What can I use to draw the entire path as a set of lines? Drawing each line of the path individually is extremely slow at the moment.

Thanks!

This library doesn't do triangulation of paths in general, only convex polygons. Perhaps you could use https://github.com/nical/lyon for paths?

@bvssvni Thanks! Can I use that with piston?

I have not tried it yet, but believe it should work.

Would it be possible to add support for simple paths without bringing in something like lyon? All I need is something like line that accepts more than two points. It could be like polygon except the color shades the line instead of filling the area within the points. Is that a hard thing to add? (I'm genuinely asking because I don't know how much effort that would take.)

Could use this method https://github.com/PistonDevelopers/graphics/blob/master/src/triangulation.rs#L493. It generates triangles by emitting 2 points.

The work is to get the edge cases right. Depending on how the corner bends, you want to "lock" one point and move the other.

This could be added to the Polygon struct, just like Rectangle that has border settings.

If I'm understanding correctly, triangles would need to be closed. Is there a way to render a path of points that wouldn't connect end-to-end?

I don't think the quad stream function requires closing.