Optimal Layout Algorithm

I am using CSS Sprites customization in my ASP.NET application based on this article.

http://weblogs.asp.net/zowens/archive/2008/03/05/css-sprite-for-asp-net.aspx

In the section "Get SPRITE already!" ... the author says ...

"The only real side to this is that all your images are arranged vertically. I'm not quite sure what matters, but most other generators have the ability to somehow arrange the images vertically and horizontally."

I am sure that this should be a problem that was previously solved, so my question is: "Given the collection of rectangles, can you effectively implement them in an optimal way?" (I suppose it depends on my definition of optimal, but being closest to the square at the beginning. (although this is actually not the case.)) Besides, would you need all the rectangles in advance or could this be done gradually?

+4
source share
1 answer

This is called the rectangle packing problem. Even in very simple cases, the search for the optimal NP-hard solution, although often there is a good heuristic. The density of the GoogleDog rectangle gives some interesting algorithms and code.

+5
source

All Articles