/scale-to-fit

small actionscript library which scales an object in order to fit another object's size.

Primary LanguageActionScript

About:

This is just a very simple class which does scaling objects keeping their proportion.

The good stuff is that this class can scale properly your object by cropping (using the lower value) it or just fitting by the highest dimension.

The class API was designed to be ease and intuitive.

##Simple fit:##

resize(a).toFitIn(b);

##Crop:##

Resize by the lower dimension:

resize(a).toFitIn(b, true);

##Multipliers##

In case of resizing videos this link has a good explanation about how important is keeping the proper dimension in videos:

resize(a).multipleOf( 16 ).toFitIn(b);

##Tweening##

If you are that guy who loves doing this scale using "tween", I did a method for you:

var r : Rectangle = resize(a).simulate().toFitIn(b).bounds;
Tweener.addTween( a, {width:r.width, height:r.height, time:0.5} );