Poisson Disk Sampling in Flash
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
![[del.icio.us]](http://www.bigsource.de/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.bigsource.de/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://www.bigsource.de/wp-content/plugins/bookmarkify/facebook.png)
![[Google]](http://www.bigsource.de/wp-content/plugins/bookmarkify/google.png)
![[Mixx]](http://www.bigsource.de/wp-content/plugins/bookmarkify/mixx.png)
![[MySpace]](http://www.bigsource.de/wp-content/plugins/bookmarkify/myspace.png)
![[StumbleUpon]](http://www.bigsource.de/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Twitter]](http://www.bigsource.de/wp-content/plugins/bookmarkify/twitter.png)


September 4th, 2009 at 1:05 pm
Nice one! I really like the idea.
Cheers
Jens
September 4th, 2009 at 1:14 pm
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
September 4th, 2009 at 5:38 pm
[...] Poisson Disk Sampling in Flash by Kim Christiansen [...]
September 4th, 2009 at 5:55 pm
might prove really useful.
thanks for sharing
September 10th, 2009 at 12:54 pm
That looks like the same technique I am using in my Image Foam pieces: http://www.flickr.com/photos/quasimondo/sets/72157600012142566/
September 10th, 2009 at 2:27 pm
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.
September 10th, 2009 at 6:52 pm
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.
September 10th, 2009 at 8:07 pm
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.
January 30th, 2011 at 12:56 am
Very nice, the interactive demo is very informative
March 17th, 2011 at 10:50 am
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.