forked from: Pixel Bender Test 3
Pixel Bender Test3 - fork
5iveさんのブログを見て、楕円に変更。でも中心がずれているので中心座標数値固定。。。。
// forked from northprint's Pixel Bender Test 3
// forked from northprint's Pixel Bender Test 2
// forked from northprint's Pixel Bender Test
// write as3 code here..
//Pixel Bender Test3 - fork
//5iveさんのブログを見て、楕円に変更。でも中心がずれているので中心座標数値固定。。。。
package {
import flash.display.*;
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLLoaderDataFormat;
import flash.system.Security;
import flash.filters.ShaderFilter;
import flash.system.LoaderContext;
[SWF(backgroundColor="#ffffff")]
public class PixelBenderTest extends MovieClip{
private var _pbloader:URLLoader;
private var _pbloader2:URLLoader;
private var _pbloader3:URLLoader;
private var _imgloader:Loader;
private var _testShader:Shader;
private var _testShader2:Shader;
private var _testShader3:Shader;
private var _filter:ShaderFilter;
private var _filter2:ShaderFilter;
private var _filter3:ShaderFilter;
private var _bmp:Bitmap;
private var _round:int = 250;
public function PixelBenderTest(){
Security.loadPolicyFile("http://narayama.heteml.jp/crossdomain.xml");
_pbloader = new URLLoader();
_pbloader.dataFormat = URLLoaderDataFormat.BINARY;
_pbloader.addEventListener(Event.COMPLETE,PbLoadHandler);
_pbloader.load(new URLRequest("http://narayama.heteml.jp/test/pixelbender/HorizontalGaussianBlurEllipse.pbj"));
}
private function PbLoadHandler(e:Event):void{
_pbloader2 = new URLLoader();
_pbloader2.dataFormat = URLLoaderDataFormat.BINARY;
_pbloader2.addEventListener(Event.COMPLETE,PbLoadHandler2);
_pbloader2.load(new URLRequest("http://narayama.heteml.jp/test/pixelbender/VerticalGaussianBlurEllipse.pbj"));
}
private function PbLoadHandler2(e:Event):void{
_pbloader3 = new URLLoader();
_pbloader3.dataFormat = URLLoaderDataFormat.BINARY;
_pbloader3.addEventListener(Event.COMPLETE,PbLoadHandler3);
_pbloader3.load(new URLRequest("http://narayama.heteml.jp/test/pixelbender/TestEffect.pbj"));
}
private function PbLoadHandler3(e:Event):void{
_imgloader = new Loader();
_imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,ImgLoadHandler);
_imgloader.load(new URLRequest("http://narayama.heteml.jp/test/pixelbender/tokyo.jpg"), new LoaderContext(true));
}
private function ImgLoadHandler(e:Event):void{
var loaderInfo:LoaderInfo = LoaderInfo(e.currentTarget);
var loader:Loader = loaderInfo.loader;
var bmd:BitmapData = new BitmapData(loader.width, loader.height, true);
bmd.draw(loader);
_bmp = new Bitmap(bmd);
_bmp.x = (stage.stageWidth/2) - (loader.width/2);
_bmp.y = (stage.stageHeight/2) - (loader.height/2);
_testShader = new Shader(_pbloader.data);
_testShader2 = new Shader(_pbloader2.data);
_testShader3 = new Shader(_pbloader3.data);
_testShader.data.blurradius.value = _testShader2.data.blurradius.value = [4];
_testShader.data.radius.value = _testShader2.data.radius.value = _testShader3.data.radius.value = [100.0];
_testShader.data.centerpoint.value = _testShader2.data.centerpoint.value = _testShader3.data.center.value = [125,200];
_testShader3.data.amount.value = [-0.5];
_testShader3.data.radius.value = [0];
_filter = new ShaderFilter(_testShader);
_filter2 = new ShaderFilter(_testShader2);
_filter3 = new ShaderFilter(_testShader3);
_bmp.filters = [_filter,_filter2,_filter3];
addChild(_bmp);
}
}
}