Resize rectangle but pin its left-top corner

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
makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Resize rectangle but pin its left-top corner

Post by makeshyft » Wed Apr 17, 2013 11:26 pm

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
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Resize rectangle but pin its left-top corner

Post by jmburnod » Wed Apr 17, 2013 11:47 pm

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
https://alternatic.ch

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Resize rectangle but pin its left-top corner

Post by Simon » Thu Apr 18, 2013 12:00 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: Resize rectangle but pin its left-top corner

Post by makeshyft » Thu Apr 18, 2013 12:13 am

Thank you so much guys!!! Haven't tried it yet, but you guys seem uber-confident.
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Resize rectangle but pin its left-top corner

Post by Simon » Thu Apr 18, 2013 12:18 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Resize rectangle but pin its left-top corner

Post by jacque » Thu Apr 18, 2013 5:53 am

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
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: Resize rectangle but pin its left-top corner

Post by makeshyft » Fri Apr 19, 2013 6:23 am

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!!!!
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

Post Reply