gravity index
  the good source
click to launch  fullscreen in new window
arbitrary box fitting

Another approach to filling a space with boxes uses exhaustive random sampling.

With a specially constructed Movieclip called the auto-expanding box, we can automatically fill a space up by randomly placing instances of the box onto the stage.

Click anywhere to create an auto-expanding box. Other boxes will be created automatically until the stage is near full.

The auto-expanding box increases it's size by precisely 2 pixels each frame. It also checks for collisions with any of the other already expanded boxes by sampling points along its perimeter. If a collision is detected, the box reduces it's size slightly (so as to no longer be in collision) and gives itself a small rotation (for a nice irregular quality).

The color of each box is selected according to its vertical position. There are 16 unique colors available and were taken from a palette photographed in Terlingua Ghost Town, Texas.

A known problem with this system exists in the way collisions are detected. Since only incremental points along the edges of the boxes are checked for collisions, it is sometimes possible for a box to expand beyond an obstacle. This is especially true for larger boxes. Also, two expanding boxes will not collide with each other because at that stage, they are not actually considered to be part of the 'collision construct'.

Obviously this is not a very efficient way to fill up a region with squares. It does however create an interesting generative pattern and is fun to watch. This recursive space filling algorithm is probably a better approach if speed and accuracy is important.

  jtarbell, april 2003  

open source Flash
commercial free open source since 2012 human generator download Flash source