A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Fit many display objects of different sizes within a boundary?

  1. #1
    Junior Member
    Join Date
    Aug 2002
    Posts
    2

    Question 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.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    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.

  3. #3
    Junior Member
    Join Date
    Aug 2002
    Posts
    2
    Quote Originally Posted by 5TonsOfFlax View Post
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center