I'm using the UIBezierPath() and DragGesture in my iOS app to draw lines on a canvas. To achieve this, I collect the gesture points and add them to a path, which is an object of UIBezierPath. I then set a specific lineWidth and stroke the path in a graphics context.
However, I'm facing an issue when trying to draw a circle shape quickly. Instead of getting a smooth curve, the connecting points of the path create corners, resulting in an angular shape rather than a circular one. This issue specifically occurs when drawing circles rapidly, and it affects the overall quality of my drawings. For more visualisation look here: 
func draw(size: CGSize, drawingImage: UIImage, lines: [Line], path: UIBezierPath) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, 1.0)
drawingImage.draw(at: .zero)
let pathCount = lines.count
let pointCount = lines[pathCount-1].line.count
let point = lines[pathCount-1].line[pointCount-1]
path.addLine(to: point.toCGPoint())
let context = UIGraphicsGetCurrentContext()!
context.addPath(path.cgPath)
context.setStrokeColor(Color.white.cgColor)
path.lineWidth = 50
path.lineCapStyle = .round
path.lineJoinStyle = .round
path.stroke()
let myImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return myImage
}
I'm seeking guidance on how to ensure that the connecting points of the path create smooth curves even when drawing a circle shape quickly. Any insights or suggestions would be greatly appreciated. Thank you!
you will need to add curves to your bezier rather then lines. and in order for the curves to look good, you will need to calculate the appropriate control points between successive points on the curve.
i'm adapting code from this answer. note that this example accepts an array of CGPoints rather than the class you reference (Line).
execute it like this
and calculate the UIBezierPath like this