rotating an image at the center point of the stack

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
magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

rotating an image at the center point of the stack

Post by magice » Wed Mar 11, 2015 2:09 pm

Apparently my brain is to twisted by this problem to create a mathematical solution as I have now spent close to 4 hours coding and recoding. I have a referenced image in a stack that is larger than the stack. It can be dragged around as needed to view any part of the image. I want to rotate the image with the portion of the image at stack center staying at stack center. The following code seems like it should work but it doesn't

Code: Select all

on mouseUp
   put (the width of this stack/2) into tHCen
   put (the height of this stack/2) into tVCen
   
   put (the bottom of img "image"- tVCen) into tVOff
   put (the right of img "Image" - tHCen) into tHOff
   
   set the angle of img "image" to (the angle of img "image"+90)
   
   set the top of img "image" to tVCen - tHOff
   set the right of img "image" to tHCen + tVOff
end mouseUp
What am I missing?

Agnar Tonheim
Posts: 10
Joined: Sun Jan 25, 2009 3:27 pm

Re: rotating an image at the center point of the stack

Post by Agnar Tonheim » Wed Mar 11, 2015 3:37 pm

look at screenLoc ...

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: rotating an image at the center point of the stack

Post by magice » Wed Mar 11, 2015 3:45 pm

Agnar Tonheim wrote:look at screenLoc ...
screenLoc does not seem to work well when using a dual monitor setup. This app requires two monitors with a control stack on the main screen and a display stack on a remote screen in full screen mode. That is why I used ..

Code: Select all

 put (the width of this stack/2) into tHCen
   put (the height of this stack/2) into tVCen
to find the center. That is not the problem. The problem seems to be with the positioning of the stack after it is rotated so that that same point of the image is still at stack center.

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: rotating an image at the center point of the stack

Post by MaxV » Wed Mar 11, 2015 6:07 pm

Probably you need to read this post: http://livecodeitalia.blogspot.it/2015/ ... -allo.html
There is the google translate button in the top right angle of the post page.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: rotating an image at the center point of the stack

Post by magice » Wed Mar 11, 2015 7:12 pm

Problem solved. It turns out that my script does work the way I expected. The problem comes in from starting with a zoomed in image. Since images with an angle of other than 0 can't change dimensions it was resizing to it's original state and so the offset numbers no longer matched

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”