Did it this way:
NSMutableArray *bezierPoints = [NSMutableArray array];
CGPathApply(drawPath.CGPath, (__bridge void *)(bezierPoints), MyCGPathApplierFunc);
float minX = 100000.f;
float minY = 100000.f;
for(NSValue* value in bezierPoints)
{
CGPoint point = value.CGPointValue;
if (point.x<minX)
minX = point.x;
if (point.y<minY)
minY = point.y;
}
float midX = minX + (drawPath.bounds.size.width/2);
float midY = minY + (drawPath.bounds.size.height/2);
float radius = 0.f;
if (drawPath.bounds.size.width>drawPath.bounds.size.height)
{
radius = drawPath.bounds.size.width * 0.65;
}
else
{
radius = drawPath.bounds.size.height * 0.65;
}
CGMutablePathRef myPath = CGPathCreateMutable();
CGPathAddArc(myPath, NULL, midX,midY,radius , 0, M_PI*2, YES);
SKShapeNode* node = [[SKShapeNode alloc]init];
node.path = myPath;
node.fillColor = nil;
node.strokeColor = SKColor.redColor;
[self addChild:node];
void MyCGPathApplierFunc (void *info, const CGPathElement *element) {
NSMutableArray *bezierPoints = (__bridge NSMutableArray *)info;
CGPoint *points = element->points;
CGPathElementType type = element->type;
switch(type) {
case kCGPathElementMoveToPoint:
[bezierPoints addObject:[NSValue valueWithCGPoint:points[0]]];
break;
case kCGPathElementAddLineToPoint:
[bezierPoints addObject:[NSValue valueWithCGPoint:points[0]]];
break;
case kCGPathElementAddQuadCurveToPoint:
[bezierPoints addObject:[NSValue valueWithCGPoint:points[0]]];
[bezierPoints addObject:[NSValue valueWithCGPoint:points[1]]];
break;
case kCGPathElementAddCurveToPoint:
[bezierPoints addObject:[NSValue valueWithCGPoint:points[0]]];
[bezierPoints addObject:[NSValue valueWithCGPoint:points[1]]];
[bezierPoints addObject:[NSValue valueWithCGPoint:points[2]]];
break;
case kCGPathElementCloseSubpath:
break;
}
}
bounds
and describe what it does wrong. – Wain