Scale to fit
Ken Ray
kray at sonsothunder.com
Tue Oct 11 02:09:44 EDT 2005
On 10/11/05 12:32 AM, "MisterX" <b.xavier at internet.lu> wrote:
> grab the maximum of the images's width or height.
>
> Get the ratio of W/H
Here you go:
function stsScaleObject pOrigW,pOrigH,pMaxW,pMaxH
put pMaxW/pOrigW into tPctW
put pMaxH/pOrigH into tPctH
if tPctH < tPctW then
put pOrigH * tPctH into tNewH
put pOrigW * tPctH into tNewW
else
put pOrigH * tPctW into tNewH
put pOrigW * tPctW into tNewW
end if
return round(tNewW),round(tNewH)
end stsScaleObject
Pass in the current width and height, along with the maximum width/height
you want it to scale to, and it will return the new width and height.
HTH,
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
More information about the use-livecode
mailing list