Reputation: 33
I am working on developing a free hand drawing application for the iPad. I have just started out developing the application. I have so far succeeded in capturing the touch points. But, I am unable to render these pixels on the screen. Are their any particular methods to perform the task? Please help! Thank You.
Upvotes: 2
Views: 1447
Reputation: 2649
Hey Amitabh,I got This while surfing,may be helpful to you. You can get the zip file of the code in the same link,they are implementing freehand tool in the application. Thanks.
Upvotes: 2
Reputation: 1090
store the last point and use a CGContext to draw a bezier curve (CGContextAddCurveToPoint()) from the last point to the current point. You will probably need to not do this every time the touchesMoved instead make an accumulator.
static int accum = 0;
if ((accum == 0) || (accum == threshold)) {
// drawing code goes here
accum = 0;
}
accum++;
threshold should be an instance variable. You can change the threshold dynamically if you need more precision on curves.
Upvotes: 0
Reputation: 2835
You probably want to maintain a list of points captured and render them to the UIView instance corresponding to your app's canvas. If you want a more detailed answer, we would need a more detailed question (eg, code you have so far, structure of your GUI, etc)
Upvotes: 0