analogueTV
/**
* Copyright 0xABCDEF ( http://wonderfl.net/user/0xABCDEF )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jSGY
*/
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.geom.Point;
[SWF(width=300,height=300,backgroundColor=0x000000,frameRate=60)]
public class analogue extends Sprite {
public function analogue() {
var flashDate:Date = new Date();
var oArray:Array = new Array();
oArray = [new Point()];
var sourceDta:BitmapData = new BitmapData(100,100,false);
sourceDta.perlinNoise(100, 100, 10,int(flashDate), false, true,7, false, oArray);
var traceDta:BitmapData = analogueTV(sourceDta);
var traceBmp:Bitmap = new Bitmap(traceDta);
stage.addChild(traceBmp);
//아날로그TV 필터(가로 3배 세로 3배로 늘려서 나오므로 주의)
function analogueTV(sourceBitmapData:BitmapData):BitmapData {
var i:int;
var j:int;
var dummyColor:uint;
var processColor:uint;
var traceData:BitmapData = new BitmapData(sourceBitmapData.width * 3,sourceBitmapData.height * 3,false,0x000000);
for (i=0; i<=sourceBitmapData.width; i++) {
for (j=0; j<=sourceBitmapData.height; j++) {
dummyColor = sourceBitmapData.getPixel(i,j) >> 16;
processColor = (dummyColor << 16)+(0x00 << 8)+0x00;
traceData.setPixel((i*3),(j*3),processColor);
traceData.setPixel((i*3),(j*3)+1,processColor);
traceData.setPixel((i*3),(j*3)+2,processColor);
dummyColor = sourceBitmapData.getPixel(i,j) >> 8 & 0xFF;
processColor = (0x00 << 16)+(dummyColor << 8)+0x00;
traceData.setPixel((i*3)+1,(j*3),processColor);
traceData.setPixel((i*3)+1,(j*3)+1,processColor);
traceData.setPixel((i*3)+1,(j*3)+2,processColor);
dummyColor = sourceBitmapData.getPixel(i,j) & 0xFF;
processColor = (0x00 << 16)+(0x00 << 8)+dummyColor;
traceData.setPixel((i*3)+2,(j*3),processColor);
traceData.setPixel((i*3)+2,(j*3)+1,processColor);
traceData.setPixel((i*3)+2,(j*3)+2,processColor);
}
}
return traceData;
}
function ef(e:Event):void {
stage.removeChild(traceBmp);
(oArray[0] as Point).x -= 5;
sourceDta.perlinNoise(100, 100, 10,int(flashDate), false, true,7, false, oArray);
traceDta=analogueTV(sourceDta);
traceBmp=new Bitmap(traceDta);
stage.addChild(traceBmp);
}
stage.addEventListener(Event.ENTER_FRAME,ef);
}
}
}