revImageScale
Moderator: Klaus
-
- Posts: 90
- Joined: Mon Jan 18, 2010 10:53 am
revImageScale
During the 09 Developers Conference, Ben Beaumont mentioned a new function that would be available in *the next release* that would be called revImageScale that will automatically scale image files to the selected container size for you. (disk 5/12 Intoduction to revWeb Plugin & revlets. I have had no luck with locating it in the Live Code release. Perhaps under a different name. Anybody know??
Re: revImageScale
Hi MikeinHawaii,
Maybe Ben was making a joke?
Here's a function that takes the dimensions of an image object and returns a new width and height of the object that will make it fit inside a second object.
theImgWidth and theImgHeight are the width and height of the image object. TheCdWidth and theCdHeight are the width and height of the destination object (or card or stack).
Best regards,
Mark
Maybe Ben was making a joke?
Here's a function that takes the dimensions of an image object and returns a new width and height of the object that will make it fit inside a second object.
Code: Select all
function rescale theImgWidth,theImgHeight,theCdWidth,theCdHeight
if theCdWidth/theImgWidth < theCdHeight/theImgHeight then
put theCdWidth / theImgWidth into myRatio
else
put theCdHeight / theImgHeight into myRatio
end if
put theImgWidth * myRatio into myNewWidth
put theImgHeight * myRatio into myNewHeight
return myNewWidth,myNewHeight
end rescale
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode