1

I needed to create a small drawing/paint application, so i turned to Beginning IPad Development for IPhone Developers: Mastering the IPad SDK By Jack Nutting, Dave Wooldridge, David Mark.

It's pretty nice. The architecture is strong. But, the drawing application (Dudel) is not very good in terms of performance. There are two main issues (for me, at the moment):

  1. Most Important: The drawing slows down after a while. Reason: drawRect is being called, every time, for all the paths.
  2. The drawing with Pencil tool isn't smooth. Reason: It's using addLineToPoint: instead of (may be) addQuadCurveToPoint:.
  3. There's no Eraser control. But it's really not an issue, because we can choose white color for the painting go give an illusion of an eraser. But, if there's a better implementation for that, i'm interested to know.

Question:

Is there a solution out there that addresses these issues, and provide a simple but efficient drawing application?

Note: I need the Undo/Redo feature as well.

erickson
  • 265,237
  • 58
  • 395
  • 493
Mustafa
  • 20,504
  • 42
  • 146
  • 209
  • Did u find a solution to for your Point 1? – Pranav Jaiswal Jul 08 '13 at 21:15
  • 1
    I managed to improve the performance, but at some additional cost. I don't redraw every time a new path is added. Instead I draw over an already captured image of the previously drawn image. – Mustafa Jul 10 '13 at 07:01

1 Answers1

1

Let me try to answer your question one by one.

The drawing with Pencil tool isn't smooth. Reason: It's using addLineToPoint: instead of (may be) addQuadCurveToPoint:.

What you say is true.IOS device looks for touches in a defined interval. If you move your hand fast, it is very likely that you may end up losing few touch points . Hence connecting points using lines results in ugly spikes.

We can smooth the curve by curve fitting algorithms.However Some tweaks in the drawing can result in measurable improvement in quality. Here is an example for it.

Eraser control

If you know the background color you can use that as brush color to give an eraser feeling. if you do not know the background you can use

CGContextSetBlendMode(context, kCGBlendModeClear);

Undo/Redo

you can use NSUndoManager .

Community
  • 1
  • 1
Vignesh
  • 10,205
  • 2
  • 35
  • 73