I'm trying to define and fill segments of an intersecting circles diagram using SKShapeNode with Bezier paths. It works fine when I combine two circle arc paths to make a shape, as in this case:
The arcs I used to create the path are marked in red. But when I try to do the same thing using three arcs, the fill doesn't work properly:
Here's what I use to get the individual arcs:
func circleArcPath(circle: VennCircle, start: CGFloat, end: CGFloat) -> UIBezierPath {
let arcUnit = CGFloat(M_PI / 3.0)
let path = UIBezierPath()
path.addArcWithCenter(circle.center, radius: circle.radius, startAngle: start * arcUnit, endAngle: end * arcUnit, clockwise: true)
return path
}
(The VennCircles are the white circles in the image.) And here's what I do to construct the SKShapeNode:
let path = circleArcPath(middleCircle, start: 2, end: 3)
path.appendPath(circleArcPath(leftCircle, start: 4, end: 5))
path.appendPath(circleArcPath(rightCircle, start: 3, end: 4))
let filledSection = SKShapeNode.init(path: path.CGPath)
As I said, this works fine with two arcs, but not with three. Can anyone see what might be going wrong here?
dkj