|
-
Fit many display objects of different sizes within a boundary?
I am currently working on an AS3 where I need to fit many differently sized display objects within a rectangular boundary without them overlapping. If you take a look at this link, http://wiffiti.com/ and take note of how the speech bubbles are able to align themselves in the swf without overlapping, this is pretty much exactly what I hope to achieve.
Can someone please point me in the right direction of an algorithm (doesn't have to be AS3) or solution to be able to achieve this, or able to explain the process that I would need to implement.
Thanks.
-
You have stumbled upon an NP-hard problem. It's a packing problem related to the Knapsack problem.
The best you'll be able to do is probably use a physics simulator to iteratively reposition the items. Have each item repel the others and let them find the most stable arrangement over some iteration/time limit.
-
 Originally Posted by 5TonsOfFlax
You have stumbled upon an NP-hard problem. It's a packing problem related to the Knapsack problem.
The best you'll be able to do is probably use a physics simulator to iteratively reposition the items. Have each item repel the others and let them find the most stable arrangement over some iteration/time limit.
Thanks 5Tons, your post is very helpful. I'll give it a crack.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|