BitmapDataTest
/**
* Copyright com4ek ( http://wonderfl.net/user/com4ek )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zXpY
*/
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.events.Event;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
init();
this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
private var _bmpd:BitmapData;
private var _seed:Number;
private var _channels:uint;
private function init():void{
_bmpd = new BitmapData(stage.stageWidth, 200, false, 0x00CCCCCC);
_seed = Math.floor(Math.random() * 10 );
_channels = BitmapDataChannel.RED | BitmapDataChannel.BLUE | BitmapDataChannel.GREEN;
_bmpd.perlinNoise(100, 80, 6, _seed, false, true, _channels, false, null);
var bmp:Bitmap = new Bitmap(_bmpd);
addChild(bmp);
}
private function enterFrameHandler(event:Event):void {
var bmpd2:BitmapData = _bmpd.clone();
var _color:Number = Math.floor(Math.random() * 256);
for ( var i:int = 0; i < _bmpd.width; i++ ) {
for( var j:int = 0; j < _bmpd.height; j++ ) {
_bmpd.setPixel(i, j, (Math.abs(bmpd2.getPixel(i, j) + _color)) );
}
}
}
}
}