Using AS3 Perlin noise to generate nice bitmap

If you are always on the look out for ways to optimize the file size of a flash movie, why not consider using Actionscript to programmatically render the elements in your flash movie. I’m fascinated when I learned that you can even generate natural texture like clouds or smoke using Actionscript. To get start, try the little code below which make use of the Perlin Noise function to generate a nice bitmap. I added in a random number to the function so that the bitmap  is different everytime it runs. The Perlin Noise function accepts many parameters. If you experiment with the function further you can even simulate an animation effect like a moving background.

Hope this will get you interested to learn more.

var myBitmapDataObject:BitmapData = new BitmapData(640, 480);
var seed:Number = Math.floor(Math.random()*100);
myBitmapDataObject.perlinNoise(320, 240, 8, seed, true, true, 7, false, null);
var myBitmap:Bitmap = new Bitmap(myBitmapDataObject);
addChildAt(myBitmap, 0);

Advertisements

~ by brianchau on January 28, 2010.

2 Responses to “Using AS3 Perlin noise to generate nice bitmap”

  1. Thats great Brian – I will give the code to my miniMasters
    to play with – Can you explain the parameters a little more please
    – Best Wishes Solly

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: