Grab an graphic along a circular path

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andrewferguson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 184
Joined: Wed Apr 10, 2013 5:09 pm

Grab an graphic along a circular path

Post by andrewferguson » Thu Oct 23, 2014 8:39 am

Hi,
I have an small circular graphic that sits on the border of a larger circular graphic. I would like to be able to move the smaller graphic around by the mouse, but only move it along the points of the larger graphic. Does anyone know how to do this?
Thanks,
Andrew

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grab an graphic along a circular path

Post by bn » Thu Oct 23, 2014 8:55 am

Hi Andrew,

look here

http://forums.livecode.com/phpBB2/viewt ... pse#p23350

it is a stack from Jim Hurley that I modified a bit. It lets you make a circle with two circle on top and restricts to movement of the top circles to the points of the underlying circle.

See if this works for you.

Kind regards
Bernd

andrewferguson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 184
Joined: Wed Apr 10, 2013 5:09 pm

Re: Grab an graphic along a circular path

Post by andrewferguson » Thu Oct 23, 2014 10:30 am

Hi Bernd,
Thanks for the stack, it is almost what I am looking for. However, I tried to resize to elipse to a circle and the smaller graphic did not adjust to the new path.
Any ideas?
Thanks,
Andrew

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grab an graphic along a circular path

Post by bn » Thu Oct 23, 2014 11:07 am

Hi Andrew,

change the parameters here in the script of button "Draw ellipse":

Code: Select all

 put the loc of grc 1 into tLoc
   put item 1 of tLoc into x0
   put item 2 of tLoc into y0
   put 70 into semiMajorAxis -- change diameter here
   put 70 into semiMinorAxis -- change diameter here
   put 66 into tiltAngle -- change axis here, only needed if ellipse
then click on button "Draw Ellipse"

then move the red dot, the red dot and the blue dot should follow the newly drawn ellipse. The blue dot always opposite to the red dot.

Axi

Kind regards
Bernd

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Re: Grab an graphic along a circular path

Post by malte » Thu Oct 23, 2014 2:15 pm

Hate to blow my own horn, but *toot toot*...

If you like, you can take a look at animationEngine, which has quite a few methods for constrained dragging.

All the best,

Malte

SparkOut
Posts: 2949
Joined: Sun Sep 23, 2007 4:58 pm

Re: Grab an graphic along a circular path

Post by SparkOut » Thu Oct 23, 2014 2:32 pm

I'll blow the horn for Malte. Animation Engine will make this task a breeze and lots more besides. A highly valuable library of extremely well written and documented code with great demos. Really, take a look. (No association with Malte beyond being a fan)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grab an graphic along a circular path

Post by bn » Thu Oct 23, 2014 3:52 pm

I would like to chime in :)

Toot, toot

Malte does a wonderful job making animation easy.

Kind regards

Bernd

Post Reply