3402 posts
    Has been part of the Envato Community for over 7 years Has referred 500+ members Has sold $125,000+ on Envato Market Has been a beta tester for an Envato feature
+6 more
bobocel says

Do you guys know any math theory that allows you to fill a space with random objects, so that they don’t overlap?

8229 posts Community Moderator
    Has referred 10+ members Has sold $1,000+ on Envato Market Has collected 50+ items on Envato Market Attended one of our Meetups around the world
+9 more
MSFX Envato team says

fill the space entirely or?

1677 posts Envato Elite Author
    Has referred 10+ members Has sold $125,000+ on Envato Market Has collected 1+ items on Envato Market Elite Author: Sold more than $75,000 on Envato Market
+6 more
Tean says

I remember 2 threads on kirupa recently, however I only managed to find one:

http://www.kirupa.com/forum/showthread.php?t=331645&highlight=AS3+Random+Grid+sized+tiles

1633 posts fueledweb.com
    Has referred 10+ members Has sold $125,000+ on Envato Market Has collected 10+ items on Envato Market Elite Author: Sold more than $75,000 on Envato Market
+6 more
RimmonTrieu says

What kind of shape ? It’s quite impossible if you place object with random shape …

1677 posts Envato Elite Author
    Has referred 10+ members Has sold $125,000+ on Envato Market Has collected 1+ items on Envato Market Elite Author: Sold more than $75,000 on Envato Market
+6 more
Tean says
3402 posts
    Has been part of the Envato Community for over 7 years Has referred 500+ members Has sold $125,000+ on Envato Market Has been a beta tester for an Envato feature
+6 more
bobocel says

On a rectangle. Not fill it, but place the objects so that they don’t overlap, and so that it looks organic (not all put evenly, nor in a corner).

1955 posts
    Has been part of the Envato Community for over 6 years Has referred 10+ members Has sold $5,000+ on Envato Market Has collected 10+ items on Envato Market
+3 more
Emroni says

I did that once, a long time ago. What I did was create a grid to place the items on, mathematically.

First you get the square root of the number of items you have, and Math.ceil() that. That number you have now is the number of rows as well as number of columns.

This means you have created yourself a grid with those rows and columns, which you can use to place your item in a certain cell somewhere in that grid.

Using Math.random() you can randomly chose a cell to add a little randomness.

The only problem is when the items are not equal size, then my solution wont really work that well.. But it might help you out a bit :)

2485 posts Premium Scripts, Plugins and Themes
    Has been part of the Envato Community for over 7 years Has referred 200+ members Has sold $125,000+ on Envato Market Has been a beta tester for an Envato feature
+6 more
LucidStudios says

may be http://www.box2dflash.org/?

I did the following project using http://www.box2dflash.org/ in which bubbles collide with each other but they don’t overlap: http://www.luftforalle.no/

Learning box2d flash is a bit pain but its a nice library.

Following website has one of the best tutorials/articles on box2dflash: http://www.emanueleferonato.com/

3402 posts
    Has been part of the Envato Community for over 7 years Has referred 500+ members Has sold $125,000+ on Envato Market Has been a beta tester for an Envato feature
+6 more
bobocel says
I did that once, a long time ago. What I did was create a grid to place the items on, mathematically.

First you get the square root of the number of items you have, and Math.ceil() that. That number you have now is the number of rows as well as number of columns.

This means you have created yourself a grid with those rows and columns, which you can use to place your item in a certain cell somewhere in that grid.

Using Math.random() you can randomly chose a cell to add a little randomness.

The only problem is when the items are not equal size, then my solution wont really work that well.. But it might help you out a bit :)

Yep, I know I can use a grid, but I want a more organic solution, not evenly positioned elements. There must be some math theories to do that. :(

8229 posts Community Moderator
    Has referred 10+ members Has sold $1,000+ on Envato Market Has collected 50+ items on Envato Market Attended one of our Meetups around the world
+9 more
MSFX Envato team says

my guess is you’re building a gallery of some kind so can we assume the objects are of four sides or are they totally random?

by
by
by
by
by
by