最优布局算法

发布于 2024-07-16 11:38:15 字数 507 浏览 2 评论 0原文

我正在基于本文在 ASP.NET 应用程序中实现 CSS Sprites 设置。

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

“已经获得 SPRITE!”...作者说...

“唯一真正的缺点是所有图像都是垂直排列的。我不太确定这很重要,但大多数其他生成器都能够以某种方式将图像垂直和水平排列。”

我确信这一定是一个以前解决过的问题,所以我的问题是,“给定一组矩形,你能以最佳方式有效地布置它们吗?”(我想这取决于我的定义最佳,但最接近正方形作为开始(尽管实际上可能并非如此。))此外,您是否需要提前所有矩形,或者可以逐步完成吗?

I'm implementing a CSS Sprites setup 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 the SPRITE already!"... the author says...

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

I'm sure this must be a previously solved problem so my question is, "Given a collection of rectangles, can you efficiently lay these out in an optimal way?" (I suppose it depends on my definition of optimal, but being the closest possible to a square as a start. (although this may not actually be the case.)) Also, would you need all the rectangles in advance or could this be done progressively?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尴尬癌患者 2024-07-23 11:38:15

这称为矩形填充问题。 即使在非常简单的情况下,找到最佳解决方案也是 NP 困难的,尽管通常有很好的启发式方法。 谷歌搜索矩形包装给出了一些有趣的算法和代码。

This is known as the rectangle packing problem. Even in very simple cases, finding the optimal solution is NP-hard, although often there are good heuristics. Googling rectangle packing gives some interesting algorithms and code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文