Page 1 of 2

Tracing Function Help

Posted: Tue Jul 12, 2011 7:47 pm
by wolfkillshepard
Hey I'm new to livecode and I recently called RunRev who told me about a tracing function that will allow a user to draw with the touch screen. I am trying to make an app in which the user would sign his/her name with the trace function and a screen of the image would be taken and saved with information that user filled out. If someone would explain to me how tracing function works and give me some example code that would be brilliant.

Re: Tracing Function Help

Posted: Wed Jul 13, 2011 4:23 am
by jacque
There is no built-in tracing function, so they must have meant a script you could write. It would keep track of the mouse/touch locations at short, regular intervals, accumulating a list of points. Then it would set the points of a polygon to the list of locations you've recorded. If I had more time I'd dig for some examples I made years ago; maybe someone else has time to do it. Basically you fire off repeated checks every few milliseconds and grab the mouseloc during each check, adding each new mouse location to a list in a variable. Then set the points of a polygon to that list.

When the user is done "drawing" you can make a screenshot of the area using the "import snapshot" command, then do whatever you want with that image.

Re: Tracing Function Help

Posted: Wed Jul 13, 2011 8:54 pm
by wolfkillshepard

Code: Select all

local sMouseIsDown

## While the user is holding the mouse down draw a polygon by setting the points

on mouseDown
   set the style of the templateGraphic to "polygon"
   create graphic "sig"
   put true into sMouseIsDown
end mouseDown

on mouseMove x,y
   if sMouseIsDown then
      put the points of graphic "sig" into tPoints
      put return & x,y after tPoints
      set the points of graphic "sig" to tPoints
   end if
end mouseMove

on mouseUp
   put false into sMouseIsDown
end mouseUp
So i have this code which allows me to connect the points I create by dragging across the screen but if I were to lift my finger to start writing my last name it would connect the last point of my first name to the first point of my last name. I can't have this because I want the signature function to be as natural as possible. How can I write the code to start a new group of points each time I lift my finger?

Re: Tracing Function Help

Posted: Wed Jul 13, 2011 9:22 pm
by jmburnod
Hi wolfkillshepard,

Maeby this script help you.

Code: Select all

local sMouseIsDown

## While the user is holding the mouse down draw a polygon by setting the points

on mouseDown
   set the style of the templateGraphic to "polygon"
   --create graphic "sig"
   create graphic
   put true into sMouseIsDown
end mouseDown

on mouseMove x,y
   if sMouseIsDown then
      --put the points of graphic "sig" into tPoints
      put the points of last graphic  into tPoints
      put return & x,y after tPoints
      --set the points of graphic "sig" to tPoints
      set the points of last graphic  to tPoints
   end if
end mouseMove

on mouseUp
   put false into sMouseIsDown
end mouseUp
Best regards

Jean-Marc

Re: Tracing Function Help

Posted: Wed Jul 13, 2011 10:54 pm
by wolfkillshepard
Thank you sooooo much that's perfect!

Re: Tracing Function Help

Posted: Thu Jul 14, 2011 9:30 am
by jmburnod
Hi wolfkillshepard
Thank you sooooo much that's perfect!
Welcome
Next step : How the user erase a grc ?

Best

Jean-Marc

Re: Tracing Function Help

Posted: Thu Jul 14, 2011 4:40 pm
by Klaus
Bonjour Jean-Marc.

...
delete grc X
...
Or do you mean how the user will be able to delete a graphic?
What about a doubleclick with an modifier key like ALT?

but beware, this cannot be in the script of the graphic that will ge deleted!
Put soemthing like this into the card script:

Code: Select all

on mousedoubleup
  if the ALTkey = "down" AND word 1 of the name of the target = "graphic" then

   ## Maybe add confirmation dialog:
   ## Answer "Really delete this nice graphic?" with "No" or "OK"
   ## if it = OK then
    delete the target
  ## end if
  end if
end mousedoubleup
Best

Klaus

Re: Tracing Function Help

Posted: Thu Jul 14, 2011 6:08 pm
by jmburnod
Guten Abend Klaus,

Sorry for my poor english.
My question was about the interface (how the user can erase one grc)
I think a tools palette should be very useful (erase,editPoints,grab,setlinesize etc...)

Best from Geneva Beach

Jean-Marc

Re: Tracing Function Help

Posted: Fri Jul 15, 2011 1:14 pm
by Klaus
Bonjour Jean-Marc,

ah, looks like I misunderstood you, but not cempletely :wink:

Yes, in these cases a TOOLS palette is a MUST, otherweise the user will have no way to "switch" tools!


Best

Klaus

Re: Tracing Function Help

Posted: Thu Oct 06, 2011 9:33 pm
by wolfkillshepard
Hey guy's I know this thread hasn't been visited in a while but after doing some more testing, this drawing function isn't as smooth as I would like it to be on iOS. When signing your name its a lot less smooth on the actual phone than when on a computer. If you have an idea about how to make it good enough to the extent where I can sign a legible signature with a stylus I would really appreciate it!

Thanks!

Re: Tracing Function Help

Posted: Thu Oct 06, 2011 9:48 pm
by wolfkillshepard
I also noticed a lag time when you start to draw, its like it doesn't start the code under the mouseUp on the drawing space for a second or 2, then you can actually create a graphic on the page.

Re: Tracing Function Help

Posted: Thu Oct 06, 2011 10:10 pm
by jmburnod
Hi wolfkillshepard

Sorry no idea at this moment.

Best regards

Jean-Marc

Re: Tracing Function Help

Posted: Thu Oct 06, 2011 10:12 pm
by wolfkillshepard
How about you Klaus? Any ideas?

Re: Tracing Function Help

Posted: Fri Oct 07, 2011 12:32 pm
by Klaus
Hi guys,

sorry, no idea, except that LiveCode might not be the right tool for this task (yet?)! 8)


Best

Klaus

Re: Tracing Function Help

Posted: Fri Oct 07, 2011 5:37 pm
by wolfkillshepard
Thanks for taking a look none the less. I hope I can find some alternative to using that method to get a signature out.