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: BitmapData Threshold Test

のんびり。ジュースとか飲みながらつれずれな感じで
つれずれすぎてどこにもいってない
Get Adobe Flash player
by nutsu 06 Mar 2010
/**
 * Copyright nutsu ( http://wonderfl.net/user/nutsu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/izo6
 */

// forked from nutsu's BitmapData Threshold Test
package {
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.events.Event;
    import flash.geom.ColorTransform;
    import flash.geom.Matrix;
    import frocessing.geom.FGradientMatrix;
    
    //のんびり。ジュースとか飲みながらつれずれな感じで
    //つれずれすぎてどこにもいってない
    //
    
    import flash.display.Graphics;
    public class ThresholdTest extends Sprite {
    		private var w:int = 465;
        private var h:int = 465;
        private var bd3:BitmapData;
    		private var bd2:BitmapData;
    		private var bd:BitmapData;
    		private var sp:Shape;
    		private var mat:FGradientMatrix;
    		
    		private var ct0:ColorTransform = new ColorTransform( 0.96,0.96,0.96);
    		private var ct:ColorTransform = new ColorTransform( 0,0,0,0,0,0,0,255);
    		
        public function ThresholdTest() 
        {
            bd = new BitmapData( w ,h, false, 0x0 );
            bd2 = new BitmapData(w,h,true,0);
            bd3 = new BitmapData(w,h,false,0x000080)
            sp = new Shape();
            mat = new FGradientMatrix();
           addChild( new Bitmap(bd3) );
            
            
            //threshold test するす。
            addEventListener( Event.ENTER_FRAME, onenter );
        }
        
        private var a:Number = 0;
        private function update():void{
        		
        		var g:Graphics = sp.graphics;
        		mat.createLinear( 0, 0, w, 0 );
        		mat.translate( -w/2, -h/2 );
        		mat.rotate( a );
        		mat.translate( w/2, h/2 );
            g.beginGradientFill( "linear",[0,0x00ff00],[1,1],[0,255],mat);
            g.drawRect( 0, 0, w, h );
            g.endFill();
            bd.draw( sp );
            
            g.clear();
            mat.createLinear( 0, 0, 0, h );
            mat.translate( -w/2, -h/2 );
        		mat.rotate( a );
        		mat.translate( w/2, h/2 );
            g.beginGradientFill( "linear",[0,0x0000ff],[1,1],[0,255],mat);
            g.drawRect( 0, 0, w, h );
            g.endFill();
            bd.draw( sp, null, null, "add" );
            a += 0.02;
        }
        
        private var flg:Boolean = true;
        
        private function onenter( e:Event ):void
        {
        		update();
        		if( flg ){
        			//
        			var c:uint = 0x80000000 | bd.getPixel( mouseX, mouseY/2 + h/2 );
	        		var m:uint = ( mouseX&0xff )<<8 | (mouseY&0xff );
	        		 bd2.fillRect( bd2.rect, 0 );
	        		 bd2.threshold( 
	            		bd, bd.rect, bd.rect.topLeft,
	            		">=",
	            		0xffffffff,
	            		c,
	            		m,
	            		false
	            	);
	            //bd3.colorTransform( bd3.rect, ct0 );
	            //いまいち、、のんびししすぎ
	            bd3.draw( bd2, new Matrix(1,0,0,1,-1-1), ct );
	            bd3.draw( bd2, null, null, "normal" );
	            		
        		}else{
        			bd3.draw( bd );
        		}
        }
    }
}