Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hankpillow/scale-to-fit

small actionscript library which scales an object in order to fit another object's size.
https://github.com/hankpillow/scale-to-fit

Last synced: 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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](http://labs.influxis.com/?p=6)
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} );