# Lets make some (perlin) noise!

**URL:** <https://forum.kirupa.com/t/lets-make-some-perlin-noise/174807>\
**Category:** open source\
**Created:** [January 9, 2006, 2:25pm UTC](https://forum.kirupa.com/t/lets-make-some-perlin-noise/174807 "2006-01-09T14:25:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ordinathorreur](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ordinathorreur/32/536_2.png) [@Ordinathorreur](https://forum.kirupa.com/u/Ordinathorreur)\
**Post date:** [January 9, 2006, 2:25pm UTC](https://forum.kirupa.com/t/lets-make-some-perlin-noise/174807/1 "2006-01-09T14:25:17Z")

</div>

This thread sort of continues from [this one](http://www.kirupa.com/forum/showthread.php?t=204054) but concentrates on some of the funky stuff we can do with the new Flash 8 perlin noise function, like create clouds, wood, water and other cool new things.

Edit: Please experiment and add your creation! You can find a playground .fla a couple of posts down…

Here’s a perlin noise generated displacement map warping an image:

```auto
import flash.display.BitmapData;
import flash.geom.Point;
import flash.filters.DisplacementMapFilter;
import flash.filters.DropShadowFilter;
Stage.scaleMode="noScale";
// Perlin noise variables, I encourage you to play around with these...
var baseX :Number = 200;
var baseY :Number = 200;    
var nOctaves :Number = 1; 
var randomSeed :Number = Math.random()*10;
var bStitch :Boolean = false;
var bFractalNoise :Boolean = true;
var nChannels :Number = 1;
var bGreyScale :Boolean= false;
// Offset array for perlin function
var p1 = new Point(45, 34);
var p2 = new Point(50, 60);
perlinOffset = new Array(p1, p2);
// Create the bitmapdata we are going to change with the perinNoise function        
bmp = new flash.display.BitmapData(400,300,true,0x00000000);

onEnterFrame = function (){
    // change the values in the perlinOffset to animate each perlin layer
    perlinOffset[0].y-=2;
    perlinOffset[0].x-=2;
    perlinOffset[1].x+=1;
    perlinOffset[1].y+=1;
    // apply perlin noise to our bitmapdata
    bmp.perlinNoise(baseX, baseY, nOctaves, randomSeed, bStitch, bFractalNoise, nChannels, bGreyScale, perlinOffset);
    //
    // Uncomment the following line to see the generated perlin noise
    //_root.attachBitmap(bmp, 1, "auto", true);
    //
    // Now use the bitmapdata in bmp as a base for the distortion
    dmf = new DisplacementMapFilter(bmp, new Point(0, 0), 1, 1, 20, 20, "color");
    // and apply it to our pic (instance name sourcePic)
    sourcePic.filters = [dmf];
}

```
