Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
richardmac
- Livecode Opensource Backer

- Posts: 211
- Joined: Sun Oct 24, 2010 12:13 am
Post
by richardmac » Thu Dec 08, 2011 3:56 pm
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
-
bn
- VIP Livecode Opensource Backer

- Posts: 4174
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Thu Dec 08, 2011 5:48 pm
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
-
richardmac
- Livecode Opensource Backer

- Posts: 211
- Joined: Sun Oct 24, 2010 12:13 am
Post
by richardmac » Thu Dec 08, 2011 8:39 pm
Works PERFECT! If you're ever in Florida in the US, I owe you a beer. Thanks for the fix.