bitmapdatatest1
♥0 |
Line 42 |
Modified 2011-02-19 19:08:32 |
MIT License
archived:2017-03-20 19:29:24
ActionScript3 source code
/**
* Copyright k2syndrome_g ( http://wonderfl.net/user/k2syndrome_g )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/vLmz
*/
package {
import flash.geom.Point;
import flash.events.Event;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
public class FlashTest extends Sprite {
private var bitmapdata:BitmapData;
public function FlashTest() {
// write as3 code here..
var tf:TextField=new TextField;
tf.border=true;
tf.autoSize="left";
addChild(tf);
bitmapdata=new BitmapData(100,100,true,0xFF0000FF);
var bitmap:Bitmap=new Bitmap(bitmapdata);
bitmap.y=100;
addChild(bitmap);
for(var i:int=0;i<bitmapdata.width;i++){
bitmapdata.setPixel32(i,i,0xFFFFFFFF);
}
bitmapdata.fillRect(new Rectangle(0,0,50,50),0xFF00FF00);
bitmapdata.floodFill(70,0,0xFFFF0000);
tf.text=String(bitmapdata.getPixel32(4,5));
//
var bd:BitmapData=new BitmapData(tf.width/2,tf.height);
bd.draw(tf);
var matrix:Matrix=new Matrix();
matrix.scale(-1,1);
matrix.rotate(45*Math.PI/180);
matrix.translate(40,40);
bitmapdata.draw(bd,matrix);
//addEventListener(Event.ENTER_FRAME,onEnterFrameListener)
}
private function onEnterFrameListener(event:Event):void{
var copyBitmapdata:BitmapData=bitmapdata.clone();;
bitmapdata.scroll(1,0);
bitmapdata.copyPixels(copyBitmapdata,new Rectangle(bitmapdata.width-2,0,2,bitmapdata.height),new Point());
//bitmapdata.perlinNoise(bitmapdata.width,bitmapdata.height,5,Math.random()*20,true,true);
bitmapdata.noise(Math.random()*int.MAX_VALUE);
}
}
}