Packing Squares

Working on a new idea codename ‘Stimuli’…

As a part of that i wanted to experiment with fitting a variable number of tiles into a dynamically resizeable container.

Square Packing v1 Demo

This demo will give a random number of tiles each time you refresh the page between 0-500 and will lay them out in the best possible fit leaving padding as required. I tried between 0-10000 but higher numbers take a long time to process. I’ll do some optimization on the layout code for v2. There’s also a 100ms timer running in response to a stage resize, basically to prevent multiple requests to draw the ui from occuring.

This demo uses drawing api and a single container sprite – maybe a BitmapData will be faster??? Lots to experiment with so i’d better get busy…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: