Move an Image to a Specific Point on a Curve
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Move an Image to a Specific Point on a Curve
I am relatively new to LiveCode. How do you move an image to specific points on a curve graphic? I know how to move it along all points, just not to one point or specific points.
Re: Move an Image to a Specific Point on a Curve
Do you mean somewhere on a circle, say? If you ask for the points of such a graphic, you will get empty, because it has no vertices.
In that case I think you will have to create a coordinate system and use X/Y pixel locations. This requires a little geometry. A circle, like I mentioned above, can be easily managed.
Another possibility is a freehand curve. If you can overlay your curve with such a graphic, you can get pretty fine control. Make a freehand curve and get the points. There are a lot. Is this resolution fine enough for your needs? If not, you can create a sublist of points between any two of them (or all of them) with a handler. Then you will have pixel resolution, and you cannot get better than that.
Write back if you need more help with this.
What sort of graphics do you have that you want to trace?
Craig Newman
In that case I think you will have to create a coordinate system and use X/Y pixel locations. This requires a little geometry. A circle, like I mentioned above, can be easily managed.
Another possibility is a freehand curve. If you can overlay your curve with such a graphic, you can get pretty fine control. Make a freehand curve and get the points. There are a lot. Is this resolution fine enough for your needs? If not, you can create a sublist of points between any two of them (or all of them) with a handler. Then you will have pixel resolution, and you cannot get better than that.
Write back if you need more help with this.
What sort of graphics do you have that you want to trace?
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Move an Image to a Specific Point on a Curve
Throughout the history of xTalks many of us have relied on one person for such geometry needs: Jim Hurley. Now a retired physics professor, he's still the source of most useful geometry routines for LiveCode developers, just as he has been for HyperCard and SuperCard developers in years past. He's a uniquely generous soul, and his generosity is matched by his gift for the art of explanation. Man, if I had him as my physics teacher I would have loved that class. 
Here's a couple links from him which may help you find circle-plotting algos:
http://jamesphurley.on-rev.com/OnRevTimer/test.html
http://home.infostations.net/jhurley/ShapeLine.rev
He may have others at his Rev page:
http://jamesphurley.on-rev.com/runrev.html
I found the ShapeLine demo mind-blowingly beautiful to play with. Jim is a math god.

Here's a couple links from him which may help you find circle-plotting algos:
http://jamesphurley.on-rev.com/OnRevTimer/test.html
http://home.infostations.net/jhurley/ShapeLine.rev
He may have others at his Rev page:
http://jamesphurley.on-rev.com/runrev.html
I found the ShapeLine demo mind-blowingly beautiful to play with. Jim is a math god.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Move an Image to a Specific Point on a Curve
Hi Richard,
Thank for this link
Best
Jean-Marc
Thank for this link
Yes, beautiful and usefulI found the ShapeLine demo mind-blowingly beautiful to play with. Jim is a math god.
Best
Jean-Marc
https://alternatic.ch
Re: Move an Image to a Specific Point on a Curve
Thanks everyone.
Craig - I would like to get the points of a free hand curve and move an image to any point along the curve. How is this done?
Thanks
Craig - I would like to get the points of a free hand curve and move an image to any point along the curve. How is this done?
Thanks
Re: Move an Image to a Specific Point on a Curve
Hi McJazz
Best
Jean-Marc
Code: Select all
move image "myImage" to the points of grc "mypath" in 2 seconds
Jean-Marc
https://alternatic.ch
Re: Move an Image to a Specific Point on a Curve
Thank you ... but how can you move to a specific point on the curve, not the entire curve?
Re: Move an Image to a Specific Point on a Curve
You can fill in the blanks between the successive vertices that the "points" function returns. It only takes a little 9th grade math. Say you have a line graphic name "p1". In a button script, say:
The variable fillGaps has the start and ending points, and all those in between, rounded to the nearest pixel.
You can, if you are in earnest, write an elegant handler that takes each pair of successive vertices in a complex graphic and fills in ALL the gaps. This final (probably very long) list will contain every point in the graphic. This is far more worthy a task than remembering the long neglected math.
You can then move your object graphic from point to point in the target graphic, or to any point you wish.
Craig Newman
Code: Select all
on mouseUp
put the points of grc "p1" into temp
put item 1 of line 1 of temp into xStart
put item 1 of line 2 of temp - item 1 of line 1 of temp into xDif
put item 2 of line 2 of temp - item 2 of line 1 of temp into yDif
put yDif / xDif into slope
repeat with y = 0 to xDif
put xStart + Y & "," & round(xStart + y*slope) & return after fillGaps
end repeat
answer fillGaps
end mouseUp
You can, if you are in earnest, write an elegant handler that takes each pair of successive vertices in a complex graphic and fills in ALL the gaps. This final (probably very long) list will contain every point in the graphic. This is far more worthy a task than remembering the long neglected math.
You can then move your object graphic from point to point in the target graphic, or to any point you wish.
Craig Newman
Re: Move an Image to a Specific Point on a Curve
Craig - Thanks!!! That really helps. I do understand the math. Since I am new to LiveCode, I do not have a grasp on all of the objects and structures yet. From your code, I understand that the points are stored as X,Y coordinates in a row type structure. I am coming from a VB/C background so the syntax is still a awkward for me. I believe that I will want to determine all points and possibly store them in an array.
Re: Move an Image to a Specific Point on a Curve
VB/C?
You will have to post back soon when you see what LC is, and can do, compared with other languages. I expect an epiphany.
Good Luck. Practice making simple stacks; that is the best way, and a method particularly suited to xTalk learning. Facility comes in a flood after a week or two.
Craig Newman
You will have to post back soon when you see what LC is, and can do, compared with other languages. I expect an epiphany.
Good Luck. Practice making simple stacks; that is the best way, and a method particularly suited to xTalk learning. Facility comes in a flood after a week or two.
Craig Newman