Perlin Wave
/**
* Copyright alpicola ( http://wonderfl.net/user/alpicola )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/6Dk9
*/
package {
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.events.Event;
[SWF(backgroundColor="#ffffff", frameRate="30")]
public class PerlinWave extends Sprite {
private var bitmap:BitmapData;
private var pos:uint = 0;
public function PerlinWave() {
stage.align = "TL";
stage.scaleMode = "noScale";
x = stage.stageWidth / 2;
y = stage.stageHeight / 2;
bitmap = new BitmapData(500, 500, false);
bitmap.perlinNoise(80, 80, 3, Math.random() * 100, true, true);
addEventListener(Event.ENTER_FRAME, loop);
}
public function loop(e:Event):void {
graphics.clear();
pos++;
pos %= 484;
for (var i:int = 0; i < 16; i++) {
for (var j:int = 0; j < 16; j++) {
var color:uint = bitmap.getPixel(pos + i, pos + j);
var r:Number = 240000000 / color - 24;
graphics.beginFill(color, 0.7);
graphics.drawCircle((i-7.5) * 25, (j-7.5) * 25, r);
}
}
}
}
}