Tracing Function Help

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

wolfkillshepard
Posts: 44
Joined: Tue Jul 12, 2011 7:43 pm

Tracing Function Help

Post by wolfkillshepard » Tue Jul 12, 2011 7:47 pm

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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Tracing Function Help

Post by jacque » Wed Jul 13, 2011 4:23 am

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

wolfkillshepard
Posts: 44
Joined: Tue Jul 12, 2011 7:43 pm

Re: Tracing Function Help

Post by wolfkillshepard » Wed Jul 13, 2011 8:54 pm

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?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Tracing Function Help

Post by jmburnod » Wed Jul 13, 2011 9:22 pm

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
https://alternatic.ch

wolfkillshepard
Posts: 44
Joined: Tue Jul 12, 2011 7:43 pm

Re: Tracing Function Help

Post by wolfkillshepard » Wed Jul 13, 2011 10:54 pm

Thank you sooooo much that's perfect!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Tracing Function Help

Post by jmburnod » Thu Jul 14, 2011 9:30 am

Hi wolfkillshepard
Thank you sooooo much that's perfect!
Welcome
Next step : How the user erase a grc ?

Best

Jean-Marc
https://alternatic.ch

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Tracing Function Help

Post by Klaus » Thu Jul 14, 2011 4:40 pm

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Tracing Function Help

Post by jmburnod » Thu Jul 14, 2011 6:08 pm

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
https://alternatic.ch

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Tracing Function Help

Post by Klaus » Fri Jul 15, 2011 1:14 pm

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

wolfkillshepard
Posts: 44
Joined: Tue Jul 12, 2011 7:43 pm

Re: Tracing Function Help

Post by wolfkillshepard » Thu Oct 06, 2011 9:33 pm

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!

wolfkillshepard
Posts: 44
Joined: Tue Jul 12, 2011 7:43 pm

Re: Tracing Function Help

Post by wolfkillshepard » Thu Oct 06, 2011 9:48 pm

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.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Tracing Function Help

Post by jmburnod » Thu Oct 06, 2011 10:10 pm

Hi wolfkillshepard

Sorry no idea at this moment.

Best regards

Jean-Marc
https://alternatic.ch

wolfkillshepard
Posts: 44
Joined: Tue Jul 12, 2011 7:43 pm

Re: Tracing Function Help

Post by wolfkillshepard » Thu Oct 06, 2011 10:12 pm

How about you Klaus? Any ideas?

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Tracing Function Help

Post by Klaus » Fri Oct 07, 2011 12:32 pm

Hi guys,

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


Best

Klaus

wolfkillshepard
Posts: 44
Joined: Tue Jul 12, 2011 7:43 pm

Re: Tracing Function Help

Post by wolfkillshepard » Fri Oct 07, 2011 5:37 pm

Thanks for taking a look none the less. I hope I can find some alternative to using that method to get a signature out.

Post Reply