How to move the center point of a graphic ?

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
fpierron
Posts: 56
Joined: Thu Dec 16, 2010 11:12 am
Contact:

How to move the center point of a graphic ?

Post by fpierron » Thu Dec 16, 2010 11:19 am

Hi

I try to make a digital clock. I need to rotate the two hands of the clock. The graphic or image objects have their center point, well..., at the center of the object. If I rotate an object, it will rotate from its center. What I need is to move the center point on the left side to rotate the object from its left side. I can not see any information about how to move this "center" point. Any idea ?

Regards

Frédéric

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

Re: How to move the center point of a graphic ?

Post by bn » Thu Dec 16, 2010 1:49 pm

Hi Frédéric,

I attach a stack that shows how to use the startAngle property of a circle/oval graphic to simulate a minute hand.
You have to set the arcAngle property of the oval graphic to 2 or 3 and the linesize to maybe 2 or 3 also.
There is a slider to make the hand move.
The same can be done for a hour hand.

This is easier than to reset all the points of a graphic. Since rotating around the bottomLeft point of a graphic is not possible. As you found out rotate always rotates around the center.

Kind regards

Bernd
Attachments
clockHand.livecode.zip
(877 Bytes) Downloaded 314 times

fpierron
Posts: 56
Joined: Thu Dec 16, 2010 11:12 am
Contact:

Re: How to move the center point of a graphic ?

Post by fpierron » Thu Dec 16, 2010 5:13 pm

Thanks a lot. I upload the file and make some tests. Thanks again.

Frédéric

fpierron
Posts: 56
Joined: Thu Dec 16, 2010 11:12 am
Contact:

Re: How to move the center point of a graphic ?

Post by fpierron » Thu Dec 16, 2010 5:27 pm

If did not miss anything, the idea is to make a transparent squared graphic with only the minute hand drawn from the center of graphic to the right side. Then use the startAngle command to change the angle of the graphic through one line of code ?

amazing.

Frédéric

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

Re: How to move the center point of a graphic ?

Post by bn » Thu Dec 16, 2010 6:03 pm

Hi Frédéric,
If did not miss anything, the idea is to make a transparent squared graphic with only the minute hand drawn from the center of graphic to the right side. Then use the startAngle command to change the angle of the graphic through one line of code ?
Yes, that is the idea.
Well you will more lines of code to calculate the angle from the minutes/hours and all that stuff but to set the angle it is one line of code. Actually Livecode calls this an oval graphic, which in this case is round. In the property inspector for the oval graphic you see the arcangle and the startangle property. You can set it there manually, or in your case by script.

Kind regards
Bernd

Post Reply