Page 1 of 1
Constrain Graphic dimensions
Posted: Fri May 08, 2020 9:08 am
by richmond62
-
I should like to set up a series of graphics that can be resized by end-users but in a constrained way.
-
Re: Constrain Graphic dimensions
Posted: Fri May 08, 2020 1:29 pm
by Xero
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
Re: Constrain Graphic dimensions
Posted: Fri May 08, 2020 2:32 pm
by richmond62
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.
Re: Constrain Graphic dimensions
Posted: Fri May 08, 2020 3:00 pm
by Xero
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