Home > Net >  How can I smooth out the curves of a drawn Path using SwiftUI with a fat Stroke?
How can I smooth out the curves of a drawn Path using SwiftUI with a fat Stroke?

Time:02-05

I am making a basic drawing app and using the following tutorial to allow the user to draw:

enter image description here

Is there anyway to smoothen out these curves using this approach?

CodePudding user response:

You're currently creating a new line segment for every point.

What you likely want to do is move To: the first point, and then addLine: To the successive points:

private func add(drawing: Drawing, toPath path: inout Path) {
    let points = drawing.points
    if points.count > 1 {
        path.move(to: points[0])
        for i in 1..<points.count-1 {
            path.addLine(to: points[i])
        }
    }
}
  •  Tags:  
  • Related