Li : Dev Actionscript Development Blog

28Oct/09Off

Faster Voronoi Noise

CLICK HERE TO VIEW DEMO

On my last post about this topic I was using a very inefficient triangle filling method; for each triangle joining the center of a Voronoi cell with one of its boundary segments, I was performing a per-pixel distance check and, depending on such distance, the amount of white for the analyzed pixel was determined.

I realized that, since the distance was being checked linearly, a gradient fill would actually do the trick. It works, and a lot faster. Also, since this runs with gradient fills, the method can generate a very large variety of different "Voronoi noises", try playing around with the source and you'll see.

This demo uses Alan Shaw's AS3Delaunay library. It runs just as fast as the one I used previously (Controul's) which is amazingly fast for pure AS3, but it is actually much more comfortable to use. Controul's Voronoi class is kind of encrypted because of all the optimizations it has, and returns only the Voronoi segments data. Shaw's Voronoi class can be asked for just about anything, from Voronoi segments to Delaunay triangles, spanning tree, nearest neighbors, etc. Thanks for this Alan!

I wonder if using drawTriangles() or bitmap fills could make this even faster. Any suggestions would be highly appreciated!

Filed under: General Comments Off
Comments (2) Trackbacks (0)
  1. BlendMode.LIGHTEN ?

  2. I really like your demo. It looks like maggots! And I just noticed I can add points by clicking! Actually I have gotten a similar effect with my discrete Voronoi app, which is based on flooding out from the points in BitmapData: http://www.flickr.com/photos/nodename/sets/72157619841795253/

    Thanks for your comments on the library!

No trackbacks yet.