Home page

Shape Packer

Shape packing

This application searches for the best way to arrange a number of shapes (circles and polygons) within another shape. It does this by maximising the radius of the inner shapes with respect to the radius of the outer shape. For polygons the radius is the distance from the centre to one of the vertices.



Circles: Temperature:
Triangles: Per second:
Squares: Outer Shape:


Choose chart:  

Computer generated image


Start Will start a new simulation using the shape counts and attributes specified in the table above.
Pause Pauses the current simulation.
Resume Resumes a paused simulation.
Update Updates the attributes of the current simulation but leaves the shapes unchanged.
Best Shows the best fit achieved since the simulation started. The simulation will also pause, but can be resumed.
Reset Best Clears the best so far value and saved state.
T-Cycle Starts a temperature cycling mode to help find solutions. This will keep decreasing the temperature until a minimum is reached, at which point it resets to a high temperature and starts again. This mode can be cancelled using "Start" or "Update".
Shapes Determines how many of each shape type are used in the simulation.
Temperature Determines how much freedom of movement the shapes have. Low temperatures tend to freeze in a configuration, larger temperatures allow the shapes to explore a larger range of sizes. If your simulation seems to be trapped in a sub-optimal configuration you can raise the temperature for a bit to try to shake it out.
Move step The size of the random moves that will be generated.
Angle step The size of the random rotations that will be generated (radians).
Per second The number of iterations that will be attempted in one second. The actual number may be smaller if your computer isn't up to it.


To find good packing solutions:

Best Text

Cut and past this text to preserve your best packings. That's how I've encoded the images on the results page. One day I might implement a viewer. Or you could create your own results page by copying and editing mine.

Java Version

The original Java applet that this javascript application is based on can be found here. It no longer workds with the latest versions of Java.

Other pages

(c) John Whitehouse 2014 - 2020