How i implent the CGContext function in iphone using objective-C?
- by Rajendra Bhole
Hi,
I want to divide the circle using CGContext and following code of function,
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?