The horizontal line at the bottom of the arc is caused by the CGContextClosePath
. To make this same image without the horizontal line change the code:
//tracer l'arc supérieur
CGContextMoveToPoint(context, rightX, startingY-wormHeight);
CGContextAddArc(context, centerX, startingY-wormHeight, echelleSize/2, 0,M_PI , 1);
CGContextClosePath(context);
CGContextAddLineToPoint(context, rightX, startingY);
to:
//tracer l'arc supérieur
CGContextMoveToPoint(context, rightX, startingY-wormHeight);
CGContextAddArc(context, centerX, startingY-wormHeight, echelleSize/2, 0,M_PI , 1);
CGContextMoveToPoint(context, rightX, startingY-wormHeight);
CGContextAddLineToPoint(context, rightX, startingY);
Edit:
Modified the code to draw the path in a way that it can be filled, and added a fill at the end.
//Tracer
CGContextBeginPath(context);
CGContextSetStrokeColorWithColor(context, wormBorderColor);
CGContextSetFillColorWithColor(context, wormFillColor);
//Déplacez à l'origine
CGContextMoveToPoint(context, leftX, startingY);
//Tracer la ligne de gauche
CGContextAddLineToPoint(context, leftX, startingY-wormHeight);
//tracer l'arc supérieur - clockwise
CGContextAddArc(context, centerX, startingY-wormHeight, echelleSize/2, 0,M_PI , 0);
//Tracer la ligne de droite
CGContextAddLineToPoint(context, rightX, startingY);
CGContextStrokePath(context);
CGContextFillPath(context);
Sorry for my poor French ;-)