Re: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mick G
Handy TILE component... http://chq.emehmedovic.com/?id=2 On 5/9/06, Bernard Poulin [EMAIL PROTECTED] wrote: Wow! I just tried your algorithm with my previous example numbers and it does output the correct square size (100) - also, internally it has the right number of columns/lines: e.g. 3x4

Re: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Danny Kodicek
For N = 100, the number of iteration depends on the ratio: it could be anywhere from 19 (10x10-1) to 100 iterations (worst case happens if the output is a single line or a single column). So that would make N iterations (in worst cases) and ~2*SQRT(N)-1 best case. It occurs to me that these

Re: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mick G
Sorry wrong link, I'm sure there is a component on the site somewhere that does what you need (I think) ;) On 5/9/06, Mick G [EMAIL PROTECTED] wrote: Handy TILE component... http://chq.emehmedovic.com/?id=2 On 5/9/06, Bernard Poulin [EMAIL PROTECTED] wrote: Wow! I just tried your

RE: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mike Mountain
] Fitting squares into an area For N = 100, the number of iteration depends on the ratio: it could be anywhere from 19 (10x10-1) to 100 iterations (worst case happens if the output is a single line or a single column). So that would make N iterations (in worst cases) and ~2*SQRT(N)-1 best

RE: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mike Mountain
One last addition: [as] /** * computes the largest N square size (and layout) that can fit an area (width,height). * * @return an Object containing 'squareSize' and the number of 'cols' and 'rows' * and a layout array for drawing the squares on screen. * * 96% of the credits goes to Danny

RE: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mike Mountain
; next_sheight = height/(rows+1); } } } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Mountain Sent: 09 May 2006 10:41 To: Flashcoders mailing list Subject: RE: [Flashcoders] Fitting squares into an area One last addition

RE: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mike Mountain
OK this is cool, create an MC in the library 100px w h, linkage square, create a smaller different colour square inside it just so you can see what's going on - Then run this: [as] /** * computes the largest N square size (and layout) that can fit an area (width,height). * * @return an

RE: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mike Mountain
Hmmm it has problems - try 8 at 640x480 M -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Mountain Sent: 09 May 2006 11:11 To: Flashcoders mailing list Subject: RE: [Flashcoders] Fitting squares into an area OK this is cool, create

Re: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Danny Kodicek
complex calculations Danny -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Mountain Sent: 09 May 2006 11:11 To: Flashcoders mailing list Subject: RE: [Flashcoders] Fitting squares into an area OK this is cool, create an MC in the library 100px w h

Re: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Danny Kodicek
, 2006 11:21 AM Subject: RE: [Flashcoders] Fitting squares into an area Hmmm it has problems - try 8 at 640x480 M -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Mountain Sent: 09 May 2006 11:11 To: Flashcoders mailing list Subject: RE

RE: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mike Mountain
@chattyfig.figleaf.com Sent: Tuesday, May 09, 2006 11:21 AM Subject: RE: [Flashcoders] Fitting squares into an area Hmmm it has problems - try 8 at 640x480 M ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search

Re: [Flashcoders] Fitting squares into an area

2006-05-09 Thread eric dolecki
PROTECTED] On Behalf Of Danny Kodicek Sent: 09 May 2006 11:37 To: Flashcoders mailing list Subject: Re: [Flashcoders] Fitting squares into an area Not that complex, it turns out... Change the line if (next_swidthnext_sheight) { to if (next_swidth=next_sheight) { Better? :) Danny

Re: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Éric Thibault
I've shown the resulting SWF to our graphist and she's thinking where to implement this in our projects and the transitions/rollover/onclick events ... totaly inspiring! Thanks all! -- === Éric Thibault Programmeur analyste Réseau

RE: [Flashcoders] Fitting squares into an area

2006-05-08 Thread Mike Mountain
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. M -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL

Re: [Flashcoders] Fitting squares into an area

2006-05-08 Thread Bernard Poulin
Probably this is not what you are looking for but: If your maximum square count is relatively low then you could use some kind of brute-force technique where you could try different cases. This might be the only way if the squares are actually rectangles (i.e. images) with varying ratios: that

Re: [Flashcoders] Fitting squares into an area

2006-05-08 Thread Danny Kodicek
@chattyfig.figleaf.com Sent: Monday, May 08, 2006 2:02 PM Subject: RE: [Flashcoders] Fitting squares into an area 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

Re: [Flashcoders] Fitting squares into an area

2006-05-08 Thread Danny Kodicek
list flashcoders@chattyfig.figleaf.com Sent: Monday, May 08, 2006 2:02 PM Subject: RE: [Flashcoders] Fitting squares into an area 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

Re: [Flashcoders] Fitting squares into an area

2006-05-08 Thread Danny Kodicek
Just some stupid typos. Revised is: function squareWidth (x, y, N) { var p = 1 var q = 1 var w1 = x var w2 = y var nextW1 = x/2 var nextW2 = y/2 while (true) { var numSquares = p*q var currWidth = Math.min(w1,w2) if (numSquares = N) {return currWidth}

Re: [Flashcoders] Fitting squares into an area

2006-05-08 Thread Steve Webster
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

Re: [Flashcoders] Fitting squares into an area

2006-05-08 Thread Bernard Poulin
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

Re: [Flashcoders] Fitting squares into an area

2006-05-08 Thread Danny Kodicek
Danny: I do not understand your algorithm - could you shed some more (high-level) light on what it is doing? Sure. The idea is that the optimal size will always be an exact fraction of either the width or the height. So what we do is drop down by multiples of these until we get to the first size

Re: [Flashcoders] Fitting squares into an area

2006-05-08 Thread Bernard Poulin
Wow! I just tried your algorithm with my previous example numbers and it does output the correct square size (100) - also, internally it has the right number of columns/lines: e.g. 3x4 (p=3, q=4) As for performance, it took 6 iterations: Since the output was 3x4, the number of iterations was (3