How do I set the current point in a CG graphics context?
Posted
by Joe
on Stack Overflow
See other posts from Stack Overflow
or by Joe
Published on 2010-05-11T18:31:31Z
Indexed on
2010/05/11
18:34 UTC
Read the original article
Hit count: 368
When running the code below in the iphone simulator I get the error : CGContextClosePath: no current point. Why is the current point not being set? Or is the context not set to the correct state?
CGContextBeginPath(ctx);
CGMutablePathRef pathHolder;
pathHolder = CGPathCreateMutable();
//move to point for the initial point
NSLog(@"Drawing a state point %f, %f", [[holder.points objectAtIndex:0] floatValue],
[[holder.points objectAtIndex:1] floatValue]);
CGPathMoveToPoint(pathHolder, NULL, [[holder.points objectAtIndex:0] floatValue],
[[holder.points objectAtIndex:1] floatValue]);
for(int x = 2; x < [holder.points count] - 1; x += 2)
{
NSLog(@"Drawing a state point %f, %f", [[holder.points objectAtIndex:x] floatValue],
[[holder.points objectAtIndex:(x+1)] floatValue]);
CGPathAddLineToPoint(pathHolder, NULL, [[holder.points objectAtIndex:x] floatValue],
[[holder.points objectAtIndex:(x+1)] floatValue]);
}
CGContextClosePath(ctx);
CGContextFillPath(ctx);
© Stack Overflow or respective owner