I am able to draw shapes using the UIBezierPath object. Now I want to identify different shapes drawn using this eg. Rectangle , Square , Triangle , Circle etc. Then next thing I want to do is that user should be able to select a particular shape and should be able to move the whole shape to different location on the screen. The actual requirement is even more complex , but If I could make this much then I can work out on the rest.
Any suggestion or links or points on how do I start with this is welcome . I am thinking of writing a separate view to handle every shape but not getting how do I do that..
Thank You all in advance !!
I recommend David Gelphmans Programming with Quartz.
In his chapter Drawing with Paths he has a section on Path Construction Primitives which provides a crossroads:
If you use
CGContextAddLineToPoint your user could make straight lines defined by known Cartesian points. You would use basic math to deduce the geometric shapes defined by those points.
If you use
CGContextAddCurveToPoint your user could make curved lines defined by known points, and Im pretty sure that those lines would run through the points, so you could still use basic math to determine at least an approximation of the types of shapes formed.
But if you use
CGContextAddQuadCurveToPoint, the points define a framework outside of the drawn curve. Youd need more advanced math to determine the shapes formed by curves along tangents.
Gelphman also discusses Path Utility Functions, like getting a bounding box and checking whether a given point is inside the path.
As for moving the completed paths, I think you would use