Position boxes like in Exposé

拈花ヽ惹草 提交于 2019-12-04 02:29:54

问题


Does anyone know a way to locate rectangles to best fit a certain area? The rectangles can be scaled up to a certain limit, but they should keep their proportions. I basically want to rebuild Mac OS' Exposé: Picture

Thanks, eWolf


回答1:


The problem is NP Hard, but that is only for the optimal solution. What I guess you really want is a solution that just looks good.

So I suggest looking for algorithms that make data look good. Once I wanted to layout pictures for the DeepZoom Composer and I tried to recycle a graph drawing force-interaction based algorithm. http://en.wikipedia.org/wiki/Force-based_algorithms

It worked really well even for 600 hundred rectangles, you just have to play with the details of the simulation.

  • How the distance is calculated?
  • What functions do you use for the attraction and repulsion forces?
  • How much overlap are you going to accept?

The only problem I could not solve entirely, was that the rectangles formed a circle shape, rather then a big rectangle shape, which is natural when you are simulating physics. But you can work around that with carefully placed auxiliary force sources.



来源:https://stackoverflow.com/questions/1810550/position-boxes-like-in-expos%c3%a9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!