dragcurve
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: dragcurve
Hi Road,
Welcome to the forum.
If I understand correctly what you want then have a look at the stack I attach below.
The math is taken from Jim Hurley. (look at revOnline search for Hurley to find examples)
Kind regards
Bernd
Welcome to the forum.
If I understand correctly what you want then have a look at the stack I attach below.
The math is taken from Jim Hurley. (look at revOnline search for Hurley to find examples)
Kind regards
Bernd
Re: dragcurve
Hi.
Did you want to actively "rotate" the small circle along that curved track, perhaps with a mouse movement, or just create the finished track as Bernd has shown you?
Craig Newman
Did you want to actively "rotate" the small circle along that curved track, perhaps with a mouse movement, or just create the finished track as Bernd has shown you?
Craig Newman
Re: dragcurve
>Did you want to actively "rotate" the small circle along that curved track
Yes,i need this,
i want the small circle to rotate the next point
thank you
Yes,i need this,
i want the small circle to rotate the next point
thank you
- Attachments
-
- dragcurve2.png (14.64 KiB) Viewed 4940 times
Re: dragcurve
Hi Road,
after I read Craig's post I figured you wanted to move the red dot. Just wanted to make shure that is what you want.
Here is a modified version of the stack that moves the red dot along the points of a graphic.
Kind regards
Bernd
after I read Craig's post I figured you wanted to move the red dot. Just wanted to make shure that is what you want.
Here is a modified version of the stack that moves the red dot along the points of a graphic.
Kind regards
Bernd
Re: dragcurve
thank you
but i want use a mouse to movement
but i want use a mouse to movement
Re: dragcurve
OK.
I would do this by creating a list of points, as many as you need for the desired resolution, that lie on the circle you require, similar to the construct that Bernd gave you. Using a mouseMove handler, you can test the motion of the mouseLoc in relation to its most recent value(s). If the new loc is to the lower left of its previous loc, for example, the dot can be moved in a similar way. The mapping of the changes in the mouseLoc is mapped to the most reasonable new point on the circle. The mapping has to make sense, in relation to the location of the dot on the circle, and the movement of the cursor. If the dot is at the lower left, it should not move at all if the mouse if moved in that direction. You get my, er, point, I hope
Now this sounds straightforward, and it is. But creating a method that is both responsive and smooth will take some work. Can you do this? It is a simple project, but one that will required finesse and perseverance.
Write back often. It is likely that several readers here will be working on their own versions. See if you can beat them. I have to go now, and start coding...oops, I mean, I have to go bathe.
Craig Newman
I would do this by creating a list of points, as many as you need for the desired resolution, that lie on the circle you require, similar to the construct that Bernd gave you. Using a mouseMove handler, you can test the motion of the mouseLoc in relation to its most recent value(s). If the new loc is to the lower left of its previous loc, for example, the dot can be moved in a similar way. The mapping of the changes in the mouseLoc is mapped to the most reasonable new point on the circle. The mapping has to make sense, in relation to the location of the dot on the circle, and the movement of the cursor. If the dot is at the lower left, it should not move at all if the mouse if moved in that direction. You get my, er, point, I hope
Now this sounds straightforward, and it is. But creating a method that is both responsive and smooth will take some work. Can you do this? It is a simple project, but one that will required finesse and perseverance.
Write back often. It is likely that several readers here will be working on their own versions. See if you can beat them. I have to go now, and start coding...oops, I mean, I have to go bathe.
Craig Newman
-
- Livecode Opensource Backer
- Posts: 328
- Joined: Mon Dec 05, 2011 5:34 pm
- Contact:
Re: dragcurve
Hi,
Are the points that are to be dragged to (as shown in your example image) discrete locations on the circumference of the circle (or half circle) ?
If so then the easiest way to do this is to initially create a small list of the centre points of those circles, then initiate the drag (however you want to do that) and then check the location of the dragged item and compare it to the list of fixed points. If it is closer to one of them than another then snap the drag item to that point. This would give you a non-smooth snapped movement.
If you require a more fine movement then you will need to work with calculating the angle of the current drag location compared to a centre point and then re-mapping it to the circular path via sin/cos of the angle at a fixed radius. Not so easy but only really involves a little geometric math.
A combination of the two above processes could allow smooth movement and fixed point snaps.
If you want to look at some code showing how to do this then take a look at Scott Rossi's site Tutorials - at Tactile Media:
http://www.tactilemedia.com/index.html? ... rials.html
Look for the one called 'Fun Sliders' - I'm pretty sure that will do what you need.
Cheers,
Dave
Are the points that are to be dragged to (as shown in your example image) discrete locations on the circumference of the circle (or half circle) ?
If so then the easiest way to do this is to initially create a small list of the centre points of those circles, then initiate the drag (however you want to do that) and then check the location of the dragged item and compare it to the list of fixed points. If it is closer to one of them than another then snap the drag item to that point. This would give you a non-smooth snapped movement.
If you require a more fine movement then you will need to work with calculating the angle of the current drag location compared to a centre point and then re-mapping it to the circular path via sin/cos of the angle at a fixed radius. Not so easy but only really involves a little geometric math.
A combination of the two above processes could allow smooth movement and fixed point snaps.
If you want to look at some code showing how to do this then take a look at Scott Rossi's site Tutorials - at Tactile Media:
http://www.tactilemedia.com/index.html? ... rials.html
Look for the one called 'Fun Sliders' - I'm pretty sure that will do what you need.
Cheers,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.
Visit http://electronic-apps.info for released App information.
Re: dragcurve
i will going to try this,thank you for your reply