Page 1 of 1
Resize rectangle but pin its left-top corner
Posted: Wed Apr 17, 2013 11:26 pm
by makeshyft
Hi all of you Livecode geniuses....
I have 2 questions:
1. How do I resize a rectangle with a button BUT pin its top-left corner so that it remains where it is?
2. Can I resize this rectangle using an animation (visual effect)?
Thanks for any help.
Tom
Re: Resize rectangle but pin its left-top corner
Posted: Wed Apr 17, 2013 11:47 pm
by jmburnod
Hi makeshyft,
Can I resize this rectangle using an animation (visual effect)?
Yes. Visual effect of your own playing with the rect
How do I resize a rectangle with a button BUT pin its top-left corner so that it remains where it is
An exemple of square resizing
Code: Select all
on mouseUp
put the topleft of img 1 into tTL
put the width of img 1 into tWidth
put the height of img 1 into tHeight
lock screen
set the width of img 1 to round(tWidth/2)
set the height of img 1 to round(tHeight/2)
set the topleft of img 1 to tTL
unlock screen
wait 1 second
--playing with the rect
put the rect of img 1 into tRect
repeat 250
add 1 to item 3 of tRect
add 1 to item 4 of tRect
set the rect of img 1 to tRect
wait 10 milliseconds
end repeat
end mouseUp
Best regards
Jean-Marc
Re: Resize rectangle but pin its left-top corner
Posted: Thu Apr 18, 2013 12:00 am
by Simon
another way:
Code: Select all
local tLoc
on mouseDown
put the topLeft of grc 1 into tLoc
end mouseDown
on mouseStillDown
set the height of grc 1 to the height of grc 1 + 1
set the width of grc 1 to the width of grc 1 + 1
set the topLeft of grc 1 to tLoc
end mouseStillDown
Simon
Re: Resize rectangle but pin its left-top corner
Posted: Thu Apr 18, 2013 12:13 am
by makeshyft
Thank you so much guys!!! Haven't tried it yet, but you guys seem uber-confident.
Re: Resize rectangle but pin its left-top corner
Posted: Thu Apr 18, 2013 12:18 am
by Simon
one change to mine:
Code: Select all
on mouseDown
set the idleTicks to 1
put the topLeft of grc 1 into tLoc
end mouseDown
Setting the idleTicks to 1 makes the animation smoother.
Simon
Re: Resize rectangle but pin its left-top corner
Posted: Thu Apr 18, 2013 5:53 am
by jacque
And yet another way:
Code: Select all
get the rect of grc 1
add 100 to item 3 of it
add 100 to item 4 of it
set the rect of grc 1 to it
Re: Resize rectangle but pin its left-top corner
Posted: Fri Apr 19, 2013 6:23 am
by makeshyft
Thank you everyone for your replies. I ended up finding a better solution to what I wanted to do .... open stack from an options menu...GENIUS!!!. I LOVE LIVECODE!!!!