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 de

Re: [Flashcoders] Fitting squares into an area

2006-05-09 Thread eric dolecki
D] > [mailto:[EMAIL 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_swidth>next_she

RE: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mike Mountain
nal Message - > From: "Mike Mountain" <[EMAIL PROTECTED]> > To: "Flashcoders mailing list" > 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

Re: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Danny Kodicek
ay 09, 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: [F

Re: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Danny Kodicek
oing to involve more 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

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

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 Obj

RE: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mike Mountain
> To: Flashcoders mailing list > Subject: RE: [Flashcoders] Fitting squares into an area > > One last addition: > > [as] > /** > * computes the largest N square size (and layout) that can > fit an area (width,height). > * > * @return an Object containing 'squareS

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 K

RE: [Flashcoders] Fitting squares into an area

2006-05-09 Thread Mike Mountain
ling list > Subject: Re: [Flashcoders] 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 wou

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 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 cas

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. 3x

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 +

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
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 wi

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 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 Danny Kodicek
" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" 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

Re: [Flashcoders] Fitting squares into an area

2006-05-08 Thread Danny Kodicek
; To: "Flashcoders mailing list" 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 a

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: t

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 PROTECT