Proportional resizing of stack

Devin Asay devin_asay at byu.edu
Tue Apr 4 19:34:32 EDT 2006


Thanks, Scott, for your ideas. After some experimentation, I came up  
with a solution that works smoothly:

Set the liveResizing of the stack to true. Include in the stack script:

on resizeStack pOldWdth,pOldHgt,pNewWdth,pNewHgt
   # maintain 4:3 ratio
   put the topLeft of this stack into tAnchorPnt
   if abs(pNewWdth - pOldWdth) > abs(pNewHgt - pOldHgt) then
     set the width of this stack to (pNewHgt * 4) div 3
   else
     set the height of this stack to (pNewWdth * 3) div 4
   end if
   set the topLeft of this stack to tAnchorPnt
end resizeStack

Devin

On Apr 4, 2006, at 9:23 AM, Devin Asay wrote:

> I have a stack that I want to constrain to a 4:3 ratio when  
> resizing, with a minimum stack size of 800 X 600. A search of the  
> archives didn't yield any relevant results.
>
> If I do this (in the resizeStack handler):
>
>   put the topLeft of this stack into tAnchorPnt
>   set the height of this stack to (pNewWdth * 3) div 4
>   set the topLeft of this stack to tAnchorPnt
>
> it works as long as my drag on the resize gadget has a horizontal  
> component.
>
> Likewise, this works:
>
>   put the topLeft of this stack into tAnchorPnt
>   set the width of this stack to (pNewHgt * 4) div 3
>   set the topLeft of this stack to tAnchorPnt
>
> as long as there is a vertical component to the drag.
>
> This:
>
>   put the topLeft of this stack into tAnchorPnt
>   if pNewWdth <> pOldWdth then
>     set the height of this stack to (pNewWdth * 3) div 4
>   else
>     set the width of this stack to (pNewHgt * 4) div 3
>   end if
>   set the topLeft of this stack to tAnchorPnt
>
> Just produces bizarre results.
>
> Any suggestions for my humanities-addled, math-challenged brain?

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list