0

I have drawn two circles. They are drawn, but there is a line that connects them. How do I remove it? Here is my code:

    //Background styling
CGContextSetRGBFillColor(context, 202.0/225.0, 255.0/225.0, 112.0/225.0, 1);

//Background setup
background = CGRectMake(1, 1, 1024, 786);               
CGContextAddRect(context, background);
CGContextDrawPath(context, kCGPathFill);

//Styling
CGContextSetLineWidth(context, 2.0);
CGContextSetRGBStrokeColor(context, 0.0/225.0, 0.0/225.0, 225.0/225.0, 1);
CGContextSetRGBFillColor(context, 0.0/225.0, 0.0/255.0, 225.0/225.0, 1);

//first tower setup
CGContextAddArc(context, 200, 150, 10, 0, 2*3.14159265359, YES);

//second tower setup
CGContextAddArc(context, 800, 150, 10, 0, 2*3.14159265359, YES);

//Draw towers
CGContextDrawPath(context, kCGPathFillStroke);
Nathaniel Waisbrot
  • 23,261
  • 7
  • 71
  • 99

2 Answers2

2

You need to add a CGContextMoveToPoint() if you want to start a new, unconnected line within a single path.

EDIT: As noted in the docs for CGContextAddArc:

If the current path already contains a subpath, Quartz adds a line connecting the current point to the starting point of the arc. If the current path is empty, Quartz creates a new new subpath with a starting point set to the starting point of the arc.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
0

CGContextAddArc() API reference says: If the current path already contains a subpath, Quartz adds a line connecting the current point to the starting point of the arc. So, add a "move" before the second CGContextAddArc():

CGContextMoveToPoint(context, 800+10, 150);
Rock
  • 23
  • 4