Draw Smooth Lines in Metal

I'm developing a drawing application using Metal and was wondering what the best way to draw smooth lines is? I current use the touchesMoved function to track where the user draws, and then attempt to create triangulated lines from that. The problem I am facing is that the line segments start to fold at the edges while drawing. How can I implement round line caps to avoid this? As you can see from the circled parts of the image, the ends of the brush stroke are very jagged. I'd like to avoid these and instead make them round.

Replies

I would look into algorithms that are designed to handle this case, which unfortunately I cannot answer specifically, but you would need to investigate polylines which is a common term for the kind of object you are trying to construct from your set of points.