Hi Roy

I'm exceptionally tired and rather brain dead but I did some playing around
with the script so laugh if you wish, I'm no mathematician, but this might
do the trick, at present you tell it how many steps in it grows to fit the
size requested. Really it doesn't matter about the target rect as the math
is based on the new width.

on mResizeRect vSprite, vTargetRect, step
  vStartRect = sprite(vSprite).rect
  theScale = float(vStartRect.width) / vStartRect.height
  vFactor = ((Float(vTargetRect.width) - vStartRect.width)/2) / step
  if vStartRect.width >= vStartRect.height then
    vScale = float(vStartRect.width) / vStartRect.height
    vScaleRect = rect(-1.0 * vScale,-1.0,1.0 * vScale,1.0) *
(vFactor/vScale)
  else
    vScale = float(vStartRect.height) / vStartRect.width
    vScaleRect = rect(-1.0,-1.0 * vScale,1.0,1.0 * vScale) *
(vFactor/vScale)
  end if
  vNewRect = vStartRect
  repeat with i = 1 to step
    vNewRect = vNewRect + vScaleRect
    sprite(vSprite).rect = vNewRect
    updateStage
  end repeat
  put theScale && float(sprite(vSprite).rect.width) /
sprite(vSprite).rect.height
  put sprite(vSprite).rect && vTargetRect
end mResizeRect

It will work in steps to give it a sort of growing perspective.  The code is
ugly but what the heck it should do the trick, you can tear it apart and
make it cleaner. I'm sure there is some redundancy.

Sincerely

Mark

--------------------------------------------
Mark R. Jonkman
Mark R. Jonkman Consulting
ADDRESS: 20 Windermere Crt., Guelph, ON, CANADA N1E 3L4
PHONE: 519-837-8509
EMAIL: [EMAIL PROTECTED]
--------------------------------------------

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Roy Pardi
> Sent: Tuesday, November 28, 2000 2:24 AM
> To: [EMAIL PROTECTED]
> Subject: RE: <lingo-l> function to scale a rect
>
>
> Hi Mark-
>
> thanks~! I think I need to be able to figure out the vFactor though-
> to make the resulting rect fit my target rect.
>
> For want of a math gene. . .
>
> /r
>
>
>
> At 1:47 AM -0500 11/28/2000, Mark R. Jonkman wrote:
> >Hi Roy
> >
> >Try something like this:
> >
> >on mResizeRect vSprite, vFactor
> >   vStartRect = sprite(vSprite).rect
> >   theScale = float(vStartRect.width) / vStartRect.height
> >   if vStartRect.width >= vStartRect.height then
> >     vScale = float(vStartRect.width) / vStartRect.height
> >     vScaleRect = rect(-1.0 * vScale,-1.0,1.0 * vScale,1.0) * vFactor
> >   else
> >     vScale = float(vStartRect.height) / vStartRect.width
> >     vScaleRect = rect(-1.0,-1.0 * vScale,1.0,1.0 * vScale) * vFactor
> >   end if
> >   vNewRect = vStartRect + vScaleRect
> >   sprite(vSprite).rect = vNewRect
> >end mResizeRect
> >
> >its not perfect, there is a slight loss in the proportionality,
> but unless
> >this is a severe mission critical piece this should get it working.
> --
>
>
>
>
> Roy Pardi
>
>
>
> [To remove yourself from this list, or to change to digest mode, go to
> http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
> email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
> Lingo-L is for learning and helping with programming Lingo.  Thanks!]
>


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to