Page 1 of 1

resize then change angle question

Posted: Thu Dec 08, 2011 3:56 pm
by richardmac
I'm trying to manipulate an image in a card to:
1. Resize itself slightly larger
2. Wiggle back and forth (using set angle)
3. Reset back to original size

I can resize the image, but as soon as I issue the angle command the image reverts back to its original size. Below is the script I'm using - any suggestions? Thanks in advance!

Code: Select all

on mouseUp
   wait 0 with messages
   --grab the original size, place in variable, resize
   put the height of image "Forklift_lil.jpg" into daOriginalHeight
   put the width of image "Forklift_lil.jpg" into daOriginalWidth
   set the height of image "Forklift_lil.jpg" to daOriginalHeight + 20
   set the width of image "Forklift_lil.jpg" to daOriginalWidth + 20
   repeat 3 times
      wait 0 with messages
      set the angle of image "Forklift_lil.jpg" to -10
      wait 5 ticks
      set the angle of image "Forklift_lil.jpg" to 10
      wait 5 ticks
   end repeat
   set the angle of image "Forklift_lil.jpg" to 0
   set the height of image "Forklift_lil.jpg" to daOriginalHeight
   set the width of image "Forklift_lil.jpg" to daOriginalWidth
end mouseUp

Re: resize then change angle question

Posted: Thu Dec 08, 2011 5:48 pm
by bn
Hi Richard,

try this:

Code: Select all

on mouseUp
   wait 0 with messages
   --grab the original size, place in variable, resize
   put 160 into tIncrease -- change to suit, values below 60 will not increase the image in my experience
   put the height of image "Forklift_lil.jpg" into daOriginalHeight
   put the width of image "Forklift_lil.jpg" into daOriginalWidth
   
   put the loc of image "Forklift_lil.jpg" into tLoc
   
   set the height of image "Forklift_lil.jpg" to daOriginalHeight + tIncrease
   set the width of image "Forklift_lil.jpg" to daOriginalWidth + tIncrease
   
   set the lockLoc of image "Forklift_lil.jpg" to true
   
   repeat 3 times
      wait 0 with messages
      lock messages
      lock screen
      set the angle of image "Forklift_lil.jpg" to -10
      set the loc of image "Forklift_lil.jpg" to tLoc
      unlock screen
      wait 5 ticks
      lock screen
      set the angle of image "Forklift_lil.jpg" to 10
      set the loc of image "Forklift_lil.jpg" to tLoc
      unlock screen
      wait 5 ticks
   end repeat
   lock screen
   set the angle of image "Forklift_lil.jpg" to 0
   set the height of image "Forklift_lil.jpg" to daOriginalHeight
   set the width of image "Forklift_lil.jpg" to daOriginalWidth
   set the loc of image "Forklift_lil.jpg" to tLoc
   set the lockLoc of image "Forklift_lil.jpg" to false
end mouseUp
I think the problem you run into is that angle and resize of an image preserve the original imageData, otherwise distortion would occur with angle. Angle will operate on the original image, not the resized image. It seems that setting the lockLoc enforces the new rect.

I used values higher then 20 because if you set the lockLoc of the image the angle will only use this rect for the image. I.e. the slanted image has to be reduced in size to fit into the rect of the unslanted image. Adjust values of tIncrement to your needs.

Kind regards

Bernd

Re: resize then change angle question

Posted: Thu Dec 08, 2011 8:39 pm
by richardmac
Works PERFECT! If you're ever in Florida in the US, I owe you a beer. Thanks for the fix.