I’m trying to break up a square or rectangle into a large number of randomly sized squares or rectangles so that none are overlapping.
Ok of course others have asked this the best thread I found is
How to fill a square with smaller squares/rectangles?
The solution seems to be either through bin packing or some sort of tree map.
But what I’m looking for is the actual algorithm in Java, Javacript , actionscript or even C.
The provided code creates a k-d tree. You can use this to draw lines on your rectangle that will divide it into smaller rectangles. After you’ve got your tree you can use it as follows to divide your region up into these rectangles:
Code: