HELP with paint like app

Hello every one I am trying to make an app where the user can input there own signature. I tried this code

local function draw( x, y )     local o = display.newImageRect( "brush.png", 40, 40 )         o.x = x; o.y = y end local function onTouch(event)     local x = event.x     local y = event.y     local phase = event.phase          if phase == "began" then         previousX,previousY = x,y     draw( x, y )         draw( x, y )         previousX,previousY = x,y     end end Runtime:addEventListener("touch", onTouch)  

which was fine until I tried to draw faster by swiping my fingers faster and it failed to draw in some of the area that my fingers swiped. As you can see from the image below. Can anyone help me with this?

391052ce-57cc-4aea-af20-71bf564d8f36_zps

use newLine and append

If I understood, when dragging your finger faster the deltax, deltay from touch to touch will be higher. When this happens you’ll need to add extra ‘dots’ in between if you want to present a filled line

@igenapps Yes you are correct. how do I do that?

Well thats mostly a matter of trigonometry. See when deltax or deltay are ‘big’ and try to position ‘dots’ in the middle if that’s the case. using previousx, previousy, x and y it’s easy to figure out where these dots should be placed.

I’m a little weak when it comes to math. If your willing to provide a sample code to this problem of mine I will be in great debt to you. If not, it’s ok. :slight_smile:

jstrahan

@jstrahan I tried what you said. It’s working fine but it has problems with curves. 

use newLine and append

If I understood, when dragging your finger faster the deltax, deltay from touch to touch will be higher. When this happens you’ll need to add extra ‘dots’ in between if you want to present a filled line

@igenapps Yes you are correct. how do I do that?

Well thats mostly a matter of trigonometry. See when deltax or deltay are ‘big’ and try to position ‘dots’ in the middle if that’s the case. using previousx, previousy, x and y it’s easy to figure out where these dots should be placed.

I’m a little weak when it comes to math. If your willing to provide a sample code to this problem of mine I will be in great debt to you. If not, it’s ok. :slight_smile:

jstrahan

@jstrahan I tried what you said. It’s working fine but it has problems with curves.