How i implement the CGContextBeginPath() functions in iphone using objective-C?
Posted
by Rajendra Bhole
on Stack Overflow
See other posts from Stack Overflow
or by Rajendra Bhole
Published on 2010-03-24T07:20:35Z
Indexed on
2010/03/24
15:13 UTC
Read the original article
Hit count: 513
iphone
Hi, I want to divide the circle using CGContext and following code of function given by apple API reference library,
CGContextBeginPath (context); for (k = 0; k < count; k += 2) { CGContextMoveToPoint(context, s[k].x, s[k].y); CGContextAddLineToPoint(context, s[k+1].x, s[k+1].y); } CGContextStrokePath(context);
The above code i want to implement inside following code instead of C5, C6 and C7 block, (void)drawRect:(CGRect)rect { // circle CGContextRef contextRef = UIGraphicsGetCurrentContext(); CGContextSetRGBFillColor(contextRef, 0, 0, 255, 0.1); CGContextSetRGBStrokeColor(contextRef, 0, 0, 255, 0.5); //CGContextFillEllipseInRect(contextRef, CGRectMake(100, 100, 150, 150)); CGContextStrokeEllipseInRect(contextRef, CGRectMake(100, 100, 150, 150));
CGContextRef c5= UIGraphicsGetCurrentContext();
CGContextSetLineWidth(c5, 2.0);
CGContextSetStrokeColorWithColor(c5, [UIColor brownColor].CGColor);
CGContextBeginPath(c5);
CGContextMoveToPoint(c5, 175.0f, 175.0f);
CGContextAddLineToPoint(c5, 100.0f, 175.0f);
CGContextStrokePath(c5);
CGContextRef c6= UIGraphicsGetCurrentContext();
CGContextSetLineWidth(c6, 2.0);
CGContextSetStrokeColorWithColor(c6, [UIColor blueColor].CGColor);
CGContextBeginPath(c6);
CGContextMoveToPoint(c6, 175.0f, 175.0f);
CGContextAddLineToPoint(c6, 175.0f, 250.0f);
CGContextStrokePath(c6);
CGContextRef c7= UIGraphicsGetCurrentContext();
CGContextSetLineWidth(c7, 02.0);
CGContextSetStrokeColorWithColor(c7, [UIColor greenColor].CGColor);
CGContextBeginPath(c7);
CGContextMoveToPoint(c7, 175.0f, 175.0f);
CGContextAddLineToPoint(c7, 175.0f, 100.0f);
CGContextStrokePath(c7);
}
It is possible, if it is then how i should have implement?
© Stack Overflow or respective owner