Scaling an Image to a Rect

Dan Friedman dan at clearvisiontech.com
Tue Oct 15 16:10:31 EDT 2013


Greetings!

I have been piddling around with this for weeks and still can't get it right.  I kinda got it working... but it's still not always 100% correct.  So, I thought I would ask this list for assistance since most of the people here are far smarter than I!

You have a rect and an image.  The goal is to completely fill the rect with the image.  But, we don't want to distort the image.  So, you need to proportionally scale the image up (if the image is smaller than the rect) or down (if the image is larger than the rect).   Remember that we want to completely fill rect.  It's ok (and expected) that some of the image will be cropped.

Think of this as setting the background of a stack with an image.  You want to fill the entire background of the stack (regardless of the size of the stack), with the image (regardless of the rect of the image).  But we don't want to distort the image.

Any thoughts?

-Dan



More information about the use-livecode mailing list