Poisson Disk Sampling in Flash

Kim Christiansen @ Sep 04 2009 12:53 pm

The Dev.Mag article inspired me programming a poisson disk sampler in ActionScript 3. The ActionScript version is based on the Bitmap.hitTest method. This allows the additional feature adding predefined seeding areas.
Another feature is the ability to add a image wich describes the size of the poisson points. The radius of the poissonpoint is defined out of the color of the image. A PerlinNoise image is a good example for a distance map.

This is an example with random sized drips. It has no hitmap and no distance map. If no distance map is added, the radius size will be a random value between radiusMin and radiusMax.

Here is an example with a hitmap and a uniform distance map. All poisson points have the same radius.

I made an editor where you can change the settings and different kind of hitmaps:

Feel free to download and play around with the source.
poissondisksampler.zip

10 comments zu “Poisson Disk Sampling in Flash”

  1. Jens Franke says:

    Nice one! I really like the idea.

    Cheers
    Jens

  2. Tizzle says:

    I likes. I did a painterly render algorithm in Processing a while ago and thought about integrating Poisson Disk Sampling as a possibility to place the brush strokes. I decided it’s too much effort so i ended up with a randomized jittered Grid which does the job quite well. I’ll take a look at your sources, maybe i can steal your Sampling ;)

  3. localToGlobal » news review -> 36th week of 2009 says:

    [...] Poisson Disk Sampling in Flash by Kim Christiansen [...]

  4. nicoptere says:

    might prove really useful.
    thanks for sharing :)

  5. Mario Klingemann says:

    That looks like the same technique I am using in my Image Foam pieces: http://www.flickr.com/photos/quasimondo/sets/72157600012142566/

  6. Kim Christiansen says:

    I really like the idea of adding and hittesting shapes instead of circles. And the results are awesome!
    But i think the image foam algorithm is a bit different. The image foam lets the shapes “grow” until it hits an shape, right? In the poisson disk algorithm the shape already have an size on a given coordinate (defined out of an image). If the shape hits an other shape, it will not be added to the list and a new random point will be selected. The coordinates of the new point is calculated out of the position of the previous point and its radius. The new point will be near the previous point.

  7. Mario Klingemann says:

    Yes it’s a bit different but I also use several control maps that define the size, rotation and other properties of an object at a certain position of the image. So in theory I could limit it in a way that there is no growing at all but a fixed size and only an “either it fits or it gets thrown away” condition. In that case it would take a bit longer to fill the whole image and some areas might not get filled at all.

    Your method of finding a new point sounds very good. Since with this space filling algos the biggest problem is to find empty spots once the image has becomes crowded.

  8. Kim Christiansen says:

    Mario, this sounds very interesting! Is your image foam algorithm open source?
    Another nice effect of the poisson disk method of finding a new point is the way it looks when you decrease the number of points: they are placed in groups, like f.x. mold.

  9. Herman Tulleken says:

    Very nice, the interactive demo is very informative :)

  10. ranjian says:

    hi, what a nice work, could I ask for a source code for studying?
    I am a student , hope you send me :ranjian_0307@126.com or
    menglixiaoyi@hotmail.com , thank you very much ,just for studying not for business.

Your comment