Drawing with Drag through Script

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

Post Reply
monicaBUSGk9X
Posts: 5
Joined: Thu Jun 21, 2012 9:47 pm
Contact:

Drawing with Drag through Script

Post by monicaBUSGk9X »

Hello!
I am attempting to automate drawing a line over an image but am unsure how to target the image I'm "dragging" over. Here is what I have thus far:

Code: Select all

on mouseUp
   choose pencil tool
   set the penColor to "red"
   set the lineSize to 10
 
   drag from 690,424 to 540,424
   drag from 540,424 to 540,435
   drag from 540,435 to 462,435
   drag from 462,435 to 462,248
   drag from 462,248 to 620,248
  
   choose browse tool
end mouseUp
My image is named "imgDragTarget".

**EDIT I have this script on a button

Thanks in advance!
Cheers,
Monica
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Drawing with Drag through Script

Post by mwieder »

Monica - that works for me - I get red lines drawn over an image. What's not working?
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: Drawing with Drag through Script

Post by dunbarx »

Hi.

When you say "target" an image, are you thinking about the sort of procedure whereby one can move an object over a list of points in a graphic? (see the "move" command in the dictionary) In your post, you had an actual list of points that you, er, drew from.

Without such an explicit list of vertices, I don't think you can find anything to "follow". I would be fascinated to think that a routine could be written that would "read", say, the black pixels in a simple image (not a graphic), and move an object over some processed pathway derived from such a thing.

Craig Newman
monicaBUSGk9X
Posts: 5
Joined: Thu Jun 21, 2012 9:47 pm
Contact:

Re: Drawing with Drag through Script

Post by monicaBUSGk9X »

Hi Guys,
Thanks for writing! I'll clarify...
Am going to have an image that may need to be resized (to zoom in or zoom out of it) with a pinch and zoom.
Can I have the points and line drawn "scale" relative to the image?

Thanks again
Monica
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: Drawing with Drag through Script

Post by dunbarx »

Hi.

You can certainly link the rect of a graphic to the rect of an image:

set the rect of yourGraphic to the rect of yourImage.

Or somesuch.

In this way the vertices will scale as well, and if you are using the "move" command to have an object trace a path, then you should be set.

Provided I understand your intentions at all.

Craig Newman
Post Reply