1

I want to implement mid-point/Bresenham circle drawing algorithm using objective for Iphone.please give me any tutorial or source code to drawing mid point/Bresenham circle algorithm.It is possible to draw the circle using CGPoint method?

Tirth
  • 7,801
  • 9
  • 55
  • 88
  • Have you searched if there's implementation in C or C++? You can use C and C++ for iPhone development. (With Monotouch you can use C# too.) – kennytm Mar 25 '10 at 06:30
  • Have you read the documentation on this? http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/ – Johan Kool Mar 25 '10 at 06:33
  • KennyTM, I was searching implementation in C on http://www.sourcecodesworld.com/source/show.asp?ScriptID=901. But i goes so much confusing. Is there any valid raster graphics method in iphone using objective-C. – Tirth Mar 25 '10 at 06:40
  • Johan Kool, I want to draw the circle using CGPoint context and mid-point circle drawing algorithm. – Tirth Mar 25 '10 at 06:42

1 Answers1

4

That algorithm appears to be well documented on Wikipedia, however, since it is about where to put the dots to create the circle, I have to point out the answers to this Stack Overflow question. Short summary: Core Graphics isn't pixel oriented.

So if you want to draw the circle point-by-point yourself, look at the answers for the linked question, and apply that to the algorithm from Wikipedia. If you just want to draw a circle, refer to the documentation, esp. CGContextAddEllipseInRect.

Community
  • 1
  • 1
Johan Kool
  • 15,637
  • 8
  • 64
  • 81
  • Johan Kool, I want to implement the following function for to draw the circle, void CGContextStrokeLineSegments ( CGContextRef c, const CGPoint points[], size_t count ); GContextBeginPath (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); How can i implement that code. I was spending a lot of days for searching and implementation of those functions but i can't able to do that please help anyone................ – Tirth Mar 25 '10 at 07:50