Cosma, Thanks for the reply. I'm think I'm going to attempt to re-produce the C# logic in AS3. I already have a "canvas" and a bunch of logic for adding/moving sprites around, all I need is the auto-align logic. Time to start hacking :)
Thanks! -Jake On Fri, Nov 22, 2013 at 1:40 PM, Cosma Colanicchia <[email protected]>wrote: > Yep, it looks like a problem that can be solved by dynamic programming > techniques (something like the classic knapsack problem [1], and very > similar to the packing problem [2]). > > There is a very interesting article about your specific problem at [3], as > already mentioned by Lee Burrows. The proposed implementation is coded in > C#, but there is a good step-by-step description of the algorithm, along > with sample images. The algo is not among the simplest ones, but this kind > of problems are usually tough, thats the fun :) > > > [1] http://en.wikipedia.org/wiki/Knapsack_problem > [2] http://en.wikipedia.org/wiki/Packing_problem > [3] > > http://www.codeproject.com/Articles/210979/Fast-optimizing-rectangle-packing-algorithm-for-bu > > > 2013/11/22 Alex Harui <[email protected]> > > > It isn't clear that the "fast" algorithm will always return the best > > possible result. You may have to make some trade-offs of algorithm > > complexity, compute time, and quality of the results. > > > > Are there other constraints on the problem-space that might make it > easier? > > > > Is this a web app? If so, you might be able to run the C# code via > > ExternalInterface. > > > > -Alex > > > > On 11/22/13 11:06 AM, "Jake Churchill" <[email protected]> wrote: > > > > >The problem with a treemap is it fills up the entire space. I need it > to > > >not do that. The problem with the codeproject that Lee mentioned is > it's > > >all C# and while I'm sure I can re-write it to AS3, I'd prefer not to > have > > >to. > > > > > >-Jake > > > > > > > > >On Fri, Nov 22, 2013 at 11:55 AM, Jesse Ward-Karet <[email protected]> > > wrote: > > > > > >> Consider treemap algorithms. There are a couple links to academic > papers > > >> on the subject and a cool real world implementation here: > > >> > > >> http://windirstat.info/background.html > > >> > > >> > > >> > On Nov 22, 2013, at 9:40 AM, Lee Burrows > > >><[email protected]> > > >> wrote: > > >> > > > >> > isnt google amazing! > > >> > > > >> > > > >> > > >> > > > http://www.codeproject.com/Articles/210979/Fast-optimizing-rectangle-pack > > >>ing-algorithm-for-bu > > >> > > > >> >> On 22/11/2013 17:35, Jake Churchill wrote: > > >> >> Guys, > > >> >> > > >> >> I'm working on a project with a component that displays child > sprites > > >> of different sites and allows the user to arrange them. The sprites > are > > >> all rectangles of different sizes. > > >> >> > > >> >> What I'm trying to do is create an auto-align which will crunch the > > >> children down into the smallest possible arrangement. > > >> >> > > >> >> I'm wondering if anyone has heard of or has some kind of logic that > > >> would help with this. FYI, I'm not looking for a handout. I've > already > > >> gone through 2 different iterations of the logic and each has a bug > > >>once in > > >> a while. > > >> >> > > >> >> Where I run into issues is when I have one really tall sprite and a > > >> bunch of shorter ones. I get things aligned in a single row and then > > >> create another row on top and start lining up the additional ones, but > > >> really what should happen is I should have the larger sprite have a > > >> "rowspan" like you can with html tables. > > >> >> > > >> >> I've attached an illustration from the app. The top 2 images is > > >>start > > >> and after the auto align. This works well when the sprites are about > > >>the > > >> same size. The 2nd row is what happens with a taller sprite and much > > >> smaller sprites, and finally below is what I would like to have happen > > >>but > > >> am having issues getting there. > > >> >> > > >> >> Any help would be awesome. > > >> >> > > >> >> Thanks! > > >> >> > > >> >> -Jake > > >> > > > >> > > > >> > -- > > >> > Lee Burrows > > >> > ActionScripter > > >> > > > >> > > > > >
