Pixel Manipulation two

by jamasian
_                           _             
| |                         (_)            
| | __ _ _ __ ___   __ _ ___ _  __ _ _ __  
_   | |/ _` | '_ ` _ \ / _` / __| |/ _` | '_ \ 
| |__| | (_| | | | | | | (_| \__ \ | (_| | | | |
\____/ \__,_|_| |_| |_|\__,_|___/_|\__,_|_| |_|

Copyright 2010, Kaiyi Chan
♥0 | Line 72 | Modified 2010-10-26 00:16:55 | MIT License
play

ActionScript3 source code

/**
 * Copyright jamasian ( http://wonderfl.net/user/jamasian )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/2X97
 */

/*
      _                           _             
     | |                         (_)            
     | | __ _ _ __ ___   __ _ ___ _  __ _ _ __  
 _   | |/ _` | '_ ` _ \ / _` / __| |/ _` | '_ \ 
| |__| | (_| | | | | | | (_| \__ \ | (_| | | | |
 \____/ \__,_|_| |_| |_|\__,_|___/_|\__,_|_| |_|

Copyright 2010, Kaiyi Chan
*/

package
{
    import flash.filters.BlurFilter;
    import flash.utils.Proxy;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.display.Sprite;

    import flash.geom.Point;
    import flash.geom.Rectangle;
    
    
    
[SWF(frameRate=300)]

public class pixel extends Sprite
{
    /*----------  VARIABLES  ----------*/
    public var bmd:BitmapData;
    public var bm:Bitmap;
    public var debug:TextField;
    
    public var getPixel:Array=new Array();
    public var COLOR:uint    =    0xBBBB00;
    
    /*---------- CONSTRUCTOR ----------*/
    public function pixel()
    {
        //create Bitmap
        bmd    =    new BitmapData(464, 464, false, 0x000000);
        bm     =    new Bitmap(bmd);
        
        addChild(bm);
        
        //create debug text
        debug              =    new TextField();
        debug.textColor    =    0xFFFFFF;
        debug.selectable   =    false;
        addChild(debug);
        
        stage.addEventListener(Event.ENTER_FRAME, update);
        stage.addEventListener(MouseEvent.CLICK,  function():void { getPixel.push(new Entity()); });
    }
    
    private function update(e:Event):void
    {
        getPixel.push(new Entity());
        bmd.fillRect(bmd.rect, 0x000000);
       
        for (var i:int = 0; i <= getPixel.length; i++)
        {
            if (getPixel[i])
            {
            var x:int        =    230 - getPixel[i].X;
            var y:int        =    230 - getPixel[i].Y;
            var s:int        =    Math.sqrt( (x)^2 + (y)^2);
            
            
            getPixel[i].X    +=   x/(i/100);
            getPixel[i].Y    +=   y/(i/100);
            
            getPixel[i].Y = (getPixel[i].Y >= 460) ? 460 : (getPixel[i].Y < 5) ? 1 : getPixel[i].Y;
            getPixel[i].X = (getPixel[i].X >= 460) ? 460 : (getPixel[i].X < 5) ? 1 : getPixel[i].X;
            
            bmd.setPixel(getPixel[i].X, getPixel[i].Y, getPixel[i].COLOR);
            
            }
        }
        
        Debug("Coordinates: " + mouseX + ", " + mouseY + "\nCount: "+getPixel.length);
    }
    
    private function Debug(text:String, override:Boolean=true):void
    {
        if (override) { this.debug.text    =    text; }else{ this.debug.appendText(text); }

        this.debug.width   =    50 + (this.debug.text.length * 3);
        this.debug.height  =    50;
        this.debug.autoSize=    "Left";
    }
    
    private function _Random(_int:int=1):int { return Math.random()*_int - Math.random()*_int; }
}
}

dynamic class Entity
{
    public var X:int         =    Math.random()*464;
    public var Y:int         =    Math.random()*464;
    public var GRAVITY:int   =    1;
    public var COLOR:uint    =    Math.random()*0xFFFFFF;
    
    public function Entity()
    {
        
    }
}