I know it's possible and I know it's simple really, but I can't remember 
it/figure it out!

I have a sub-stack that contains an image.  I want the user to be able to drag 
the corners and edges of the sub-stack window to make the window and its image 
larger or smaller, but the window and image must maintain their original aspect 
ratio – no stretching, no empty borders etc.  I've tried the following in the 
card script:

global gImageRatio

on resizeStack pNewWidth, pNewHeight, pOldWidth, pOldHeight
   propSizeImage "coinSet", gImageRatio
   pass resizeStack
end resizeStack

on propSizeImage pImageName, @pImageRatio
   put the width of this stack into propWidth
   set the width of image pImageName to propWidth 
   put propWidth div pImageRatio into propHeight
   put the width of image pImageName into tWidth
   put the height of image pImageName into tHeight
   if propHeight > tHeight then
      put tHeight into propH
      put tHeight * pImageRatio into propW
   else if propHeight < tHeight then
      put propHeight into propH
      put propH * pImageRatio into propW
   else
      put tWidth into propW
      put tHeight into propH
   end if
   set the height of image pImageName to propH 
   set the width of image pImageName to propW 
   set the height of this stack to propH 
   set the width of this stack to propW
   set the topLeft of image pImageName to 0,0
end propSizeImage

with the following initialisation in the stack script:

global gImageRatio

on preOpenStack
   put the width of image "CoinSet" / the height of image "CoinSet" into 
gImageRatio
end preOpenStack

I'm probably missing something obvious, but can anyone help please?!

Thanks

Peter
--
Peter Reid
Loughborough, UK



_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to