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

ink blot

Get Adobe Flash player
by bradsedito 26 Sep 2011
    Embed
/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qwcU
 */

// forked from halfmile's ink blot? for better performance
// forked from nitoyon's Hello World!!!
package{
    import flash.display.*;
    import flash.events.Event;
    import flash.filters.*;
    import flash.geom.*;
    import flash.text.*;
    import flash.utils.*;
    
    public class InkBlot extends Sprite{
        
        /**
         * a bit map data container to get font presentation
         */
        private var bd:BitmapData;
        
        /**
         * a container for dots 
         */
//        private var container:Sprite;
        
        private static const DOT_SIZE:int = 5;
        
        public function InkBlot():void{
            if(this.stage) init()
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init():void{
            removeEventListener(Event.ADDED_TO_STAGE,init);
            var _gradient:Gradient 
            addChild(new Gradient(stage.width, stage.height));
            
            
            var container:Sprite = new Sprite();
            
            
            var tf:TextField = new TextField();
            tf.defaultTextFormat=new TextFormat('_sans',DOT_SIZE*15,0,true);
            tf.textColor = 0x000000;
            tf.text = "BRADSEDITO";
            tf.autoSize = "left";
            
            bd = new BitmapData(tf.width, tf.height, false, 0xffffff);
            bd.draw(tf);
            bd.applyFilter(bd, bd.rect, new Point(), new BlurFilter());
            bd.draw(tf);
            
            for(var i:int = 0; i < bd.width; i++){
                for(var j:int = 0; j < bd.height; j++){
                    
                    // bypadd empty area 
                    if (bd.getPixel(i,j)!==0 || Math.random() < .8) continue;
                    
                    var radius:Number = Math.pow(Math.random(),4)*DOT_SIZE+1;
                    
                    var c:Sprite=new Circle(bd.getPixel(i, j),radius);
                    
                    if (radius >= DOT_SIZE){
                        c.filters = [
                            new BlurFilter(2, 2, BitmapFilterQuality.MEDIUM)
                        ];
                    }
                    
                    container.addChild(c);
//                    c.x=i*DOT_SIZE-DOT_SIZE;
//                    c.y=j*DOT_SIZE-DOT_SIZE;
                    c.x =i; c.y =j;
                    c.scaleX=c.scaleY=1;
                    
                }
            }
            
           container.filters = 
           [
               new BlurFilter(14, 14, 3)  // BitmapFilterQuality.MEDIUM)
           ];
            
            bd = new BitmapData(container.width * 1.5, container.height * 1.5, true, 0xffffff);
            bd.draw(container);
            
//            removeChild(container);
//            addChild(new Bitmap(bd));
            addChild(container);
//            delete container;
            
        }
    }
}


import flash.display.*;
import flash.geom.*;

class Circle extends Sprite{
    public function Circle(color:uint,s:Number):void{
        graphics.beginFill(color);
        graphics.drawCircle(0, 0, s);
        graphics.endFill();        
    }
}

class Gradient extends Sprite{
    public function Gradient(w:int, h:int):void{
        
//        trace("w:"+w+"; h:"+h)
        
        //Type of Gradient we will be using
        var fType:String = GradientType.LINEAR;
        //Colors of our gradient in the form of an array
        var colors:Array = [ 0xff00dd, 0x33ff55 ];
        //Store the Alpha Values in the form of an array
        var alphas:Array = [ 1, 1 ];
        //Array of color distribution ratios.  
        //The value defines percentage of the width where the color is sampled at 100%
        var ratios:Array = [ 0, 255 ];
        //Create a Matrix instance and assign the Gradient Box
        var matr:Matrix = new Matrix();
        matr.createGradientBox( 200, 20, 0, 0, 0 );
        //SpreadMethod will define how the gradient is spread. Note!!! Flash uses CONSTANTS to represent String literals
        var sprMethod:String = SpreadMethod.PAD;
        //Start the Gradietn and pass our variables to it
        var sprite:Sprite = new Sprite();
        //Save typing + increase performance through local reference to a Graphics object
        var g:Graphics = sprite.graphics;
        graphics.beginGradientFill( fType, colors, alphas, ratios, matr, sprMethod );
//        g.beginGradientFill( fType, colors, alphas, ratios, matr, sprMethod );
        graphics.drawRect( 0, 0, 800, 600);
//        g.drawRect( 0, 0, 800, 600);
        graphics.endFill();    

    }
}