Aaaah, the "Monday-effect": Yes, in fact: the problem with Steve's algorithm is that the squares will almost never entirely fill the area. There will always be empty gaps at every line / column and/or the last line will not be filled completely.
If you have 5 squares to fill for example, there will be some space lost somewhere. Unless it exactly fits a 5x1 or 1x5 ratio. Danny: I do not understand your algorithm - could you shed some more (high-level) light on what it is doing? hey! this is actually fun! I love these little algorithms. To compute the square size: I am thinking that we should work with the area ratio somehow. Just to be sure I understand what you want: I am assuming that this is showing "a list of things" and that it is okay that the last line has less items. If the area is width=305 height=400 and N is 10, it will result in square size is 100 -- the first 2 lines will be almost full (5 pixels gap on each line) and the last line is 1/3 full. Visually: 1 2 3 4 5 6 7 8 9 10 - - Here we are showing a 3x4 rectangle which is the best ratio to fit 10 squares in 305x400. ...is this what you are looking for? B. 2006/5/8, Steve Webster <[EMAIL PROTECTED]>:
Mike, > All my squares need to be the same size - so for example what's the > best way of laying out 'n' equal squares in an areas x,y so the > squares are as big as they can be. There must be an algo for this > kind of thing. I might be being a little stupid, but since it's a square, and since width x height = height x width, why not just: // Calculate max area of each square var area:Number = Math.floor((x * y) / n); // Calculate side length from area var sideLength:Number = Math.sqrt(area); PS. It is Monday, so forgive me if the above doesn't work. -- Steve Webster Head of Development Featurecreep Ltd. http://www.featurecreep.com 14 Orchard Street, Bristol, BS1 5EH 0117 905 5047 _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
_______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

