Constrain Graphic dimensions

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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Constrain Graphic dimensions

Post by richmond62 » Fri May 08, 2020 9:08 am

Screenshot 2020-05-08 at 11.03.59.png
-
I should like to set up a series of graphics that can be resized by end-users but in a constrained way.
-
Screenshot 2020-05-08 at 11.08.00.png

Xero
Posts: 157
Joined: Sat Jun 23, 2018 2:22 pm

Re: Constrain Graphic dimensions

Post by Xero » Fri May 08, 2020 1:29 pm

Should be a simple maths trick.
How do you want them to be constrained? Do you want the rhombus to resize relative to the text, the text relative to the rhombus, or do you want the rhombus to change shape (be wider) so the text fits in the rhombus?
Xero

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Constrain Graphic dimensions

Post by richmond62 » Fri May 08, 2020 2:32 pm

It probably is a simple maths trick . . .

pseudocode:

on resize
do some mathematics
make sure everything is proportional
end resize


But I was only on my first cup of coffee this morning.

Probably sort out the whole thing in about 3 hours time after my afternoon online teaching.

Xero
Posts: 157
Joined: Sat Jun 23, 2018 2:22 pm

Re: Constrain Graphic dimensions

Post by Xero » Fri May 08, 2020 3:00 pm

on mousedown
Get current size
end mousedown

on resize
Get new size of one thing
Put (new size)/(old size) into scalefactor
Set the new size of the other thing to oldsize * scalefactor
end resize

Just depends on what you want to do with the resizing (i.e. whether you want the text size to dictate the rhombus size)
There is a stack somewhere on the forum about proportional resizing of windows, and that would suffice. I have it in an app that I am working on and can copy and paste if needed.
X

Post Reply