ICL1901
ICL1901

Reputation: 7778

How do I approach smooth line drawing such as the example below in ios 5/6?

I have been developing line drawing apps that produce lines such as these:

enter image description here

I really want to draw lines such as these:

enter image description here

I dont know what technique is used to produce the lines that look like brushwork.

I would appreciate advice, or redirection to a post that looks at this question. I've looked for an hour. I dont know the terminology to ask the right question..

Thanks

Upvotes: 0

Views: 271

Answers (1)

Hitesh
Hitesh

Reputation: 1403

You have two problems you need to solve:

  1. How to determine the width of the line to be drawn
  2. Drawing the appropriate width line

Ideally you would want pressure information from the user's finger to know how wide the line should be. The harder the user presses, the fatter the line. However, the capacitive touch devices that run iOS don't have the ability to get this information. So your next option is to use some algorithm based on how fast the user is moving their finger on the screen. Slow movement may mean fatter lines and fast movement may mean thinner lines. Or the reverse, depends on what you want to achieve.

Drawing the appropriate width line has many options depending on whether your app is using OpenGL. Mainly, I would look at using a small anti-aliased circle image that is used to paint into a pixel buffer. Scale the image appropriately to paint sections of the line at varying widths. This part of your question has a lot of options so you may want to ask it as a separate question while also including details of whether you're using OpenGL, Core Graphics or something else.

Upvotes: 1

Related Questions