2d-bin-packing Algorithm for placing a rectangle in x, y place?

I implement a 2d-bin packaging algorithm in canvas. My task is to place the rectangles as optimal as on the canvas.

shown how to do this: http://incise.org/2d-bin-packing-with-javascript-and-canvas.html

BUT, it starts from the origin. I would like to say an algorithm where to place the rectangle and that the next one will not be on it.

What needs to be changed in the code?

Is there any other algorithm to use?

+3
source share
1 answer

I know a better algorithm (in terms of compactness rather than speed) than the one you are connected to is called MaxRects.

This was my implementation in C ++. Although it was not fast, it was very effective in compact packaging.

This is a discussion and comparison of all types of algorithms in terms of both time and compactness.

EDIT:

I put together an example image packaged using MaxRects enter image description here .

+11
source

All Articles