在框中分配对象的算法(如 InDesign、Illustrator、Draw!)
我有一组具有相应位置的矩形和一个大矩形,用作这些矩形的“边界框”。
我想知道一种可以在矩形之间均匀“分配可用空间”的算法。有些人可能熟悉 Adobe InDesign 和类似的面向布局的应用程序中的“分布间距”选项。这就是我正在寻找的。
我确实尝试查找它,但我不熟悉“图形”算法术语,并且仅尝试与“分布”相关的术语主要产生有关分布式计算的结果。因此,即使是算法的名称或更好的查找术语也会有很大帮助。
最后,该算法不需要与 InDesign 的算法严格相同:几乎任何在区域内“分布”对象的算法都可以正常工作。事实上,由于我主要追求视觉吸引力,因此建议越多越好。 =D
I have a set of rectangles with their corresponding positions and a big rectangle which serves as the 'bounding box' for these rectangles.
I would like to know of an algorithm that would 'distribute the free space' evenly among the rectangles. Some of you may be familiar with the Distribute Spacing option in Adobe InDesign and similar layout-oriented apps. That would be what I'm looking for.
I did try looking it up, but I'm not familiar with 'graphical' algorithms terminology and trying only terms relating to 'distribute' mainly yields results about Distributed Computing. So, even the names of the algorithms or better terms to look up would be a big help.
Finally, the algorithm doesn't need to be rigorously the same as InDesign's one: pretty much any algorithm that 'distributes' objects inside a region will work fine. In fact, since I'm striving for visual appeal mainly, the more suggestions the better. =D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以查看图形布局算法。 基于力的算法可能适合您。
You could look into graph layout algorithms. A force-based algorithm might work for you.
我认为必须有一种方法可以将其表述为线性规划问题。最大化矩形的总面积,但要确保它们永远不会相交作为限制。我想不出任何非线性的东西,所以应该可以。我唯一不确定的是是否可以生成限制列表以防止矩形重叠。我无法向自己证明这可能或不可能……这是我唯一能想到的。
希望有帮助。
I'm thinking there must be a way to formulate this as a linear programming problem. maximize the total area of the rectangles, but make sure that they never intersect as being the restrictions. I can't think of anything non-linear here, so should work. The only thing I'm not sure about is if it's possible to generate a list of restrictions to prevent rectangles from overlapping. I can't prove to myself that it is either possible or not not possible...that's the only thing I can think of.
Hope it helps.