In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: しましまフィルター 要ウェブカム

要ウェブカム
/**
 * Copyright watanabe ( http://wonderfl.net/user/watanabe )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7TJa
 */

// forked from watanabe's しましまフィルター 要ウェブカム
//要ウェブカム

// forked from watanabe's forked from: forked from: 使徒襲来
// forked from watanabe's forked from: 使徒襲来
// forked from watanabe's 使徒襲来
// forked from hacker_n96o8lrr's forked from: BitmapDataSample9
// forked from nutsu's BitmapDataSample9
package {
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.text.TextField;
    import flash.filters.BlurFilter;
    import flash.filters.ColorMatrixFilter;
    import flash.media.Camera;
    
    import flash.display.Sprite;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.display.BitmapDataChannel;
    import flash.geom.Point;
    import flash.events.Event;
    import flash.media.*;
    
    [SWF(width=465,height=465,backgroundColor=0)]
    public class BitmapDataSample9 extends Sprite {
        
        private var bmpdata:BitmapData;
        private var out:BitmapData        
        
        private var mapR:Array=[]
        private var mapG:Array=[]
        private var mapB:Array=[]

        private var camera:Camera
        private var video:Video
        
        private var count:int=0;
        private var loader:Loader=new Loader();
        public function BitmapDataSample9() {
            //BitmapDataを作成して表示リストに追加
            bmpdata = new BitmapData( 465, 465, false, 0 );
            out = bmpdata.clone();
            stage.quality="low";
            
  
                        
            var bmp:Bitmap = new Bitmap(out);
            
            camera=Camera.getCamera();
            if(!camera){
                //loader.load(new URLRequest("http://wonderfl.net/images/icon/0/0e/0e94/0e94f26b44267ee246d4544f6e7580a8651d91e2m"));
            }


          
            
            video=new Video(465,465);
            video.attachCamera(camera);
            
            addChild( bmp );
            //イベント
            addEventListener( Event.ENTER_FRAME, enterframe );
        }
        
        private var baseX:Number         = 240;
        private var baseY:Number         = 240;
        private var octaves:uint         = 2;
        private var randomSeed:int       = Math.random()*0xffffffff;
        private var stitch:Boolean       = false;
        private var fractalNoise:Boolean = true;
        private var channelOptions:int   = BitmapDataChannel.RED|BitmapDataChannel.BLUE;
        private var grayScale:Boolean    = true;
        private var offset:Array         = [new Point(),new Point(),new Point()];
        private var a:Array=[
                1/3,1/3,1/3,0,0,
                1/3,1/3,1/3,0,0,
                1/3,1/3,1/3,0,0,
                1/3,1/3,1/3,0,0
            ]
        private var colFilt:ColorMatrixFilter=new ColorMatrixFilter(a)
        
        private function enterframe(e:Event):void {
            //PerlinNoise
          
          var tobashi:int=150
                                  count+=tobashi
            for(var i:int = 0; i < 0x100; i++) {
                    mapB[i] = (count+(i*tobashi))%0x100;
                    mapG[i] = mapB[i]*1.5 << 8;
                    mapR[i] = mapB[i]*2.5 << 16;
            }               
            

            
            
            if(camera)bmpdata.draw(video);
           // else bmpdata.draw(loader)
            bmpdata.applyFilter(bmpdata,bmpdata.rect,new Point(),colFilt);
            bmpdata.applyFilter(bmpdata,bmpdata.rect,new Point(),new BlurFilter(8,8));
            
            /*
            bmpdata.perlinNoise( baseX, baseY, octaves, randomSeed, 
                                 stitch, fractalNoise, channelOptions, grayScale, offset );
            offset[0].y += 3;
            offset[1].y += 2;
            offset[2].y += 1;
            */
            out.paletteMap(bmpdata,bmpdata.rect,new Point(),mapR,mapG,mapB);
        }
        

        
        
    }
}