Shiny 3d pixel cloud color cube

by phenix.pink
it is shiny. No special 3d libs used. 20000 particles.
♥0 | Line 61 | Modified 2010-12-18 21:53:22 | MIT License
play

ActionScript3 source code

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

package 
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    
    import flash.display.*;

    
     import net.hires.debug.Stats;
     
    [SWF(width = 300,height = 300,frameRate = 30,backgroundColor = 0x00000000)]

    public class FlashTest extends Sprite
    {
        public var bmd:BitmapData = new BitmapData(400,400,true,0x00000000);

        public var xn:Number;
        public var yn:Number;
        public var zn:Number;
        public var norm:Number;
        public var c1:Number;
        public var c2:Number;
        public var c3:Number;
        public var c4:Number;
        public var counter:int;
        public var color:uint;
        public function FlashTest()
        {
             stage.addChild(new Stats({bg:0x00000000, fps:0xFFFFFF})).blendMode = BlendMode.ADD;
             
            while (counter < 12000)
            {
                xn = Math.random() * 400;
                yn = Math.random() * 400;
                zn = Math.random() * 400;
                norm = Math.sqrt(xn * xn + yn * yn + zn * zn);
                c1 = (1 - norm / 200) * 255;
                c2 = (1 - norm / 250) * 255;
                c3 = Math.abs(xn) / norm * 255;
                c4 = Math.abs(yn) / norm * 255;
                color =  (c1 << 24 | c2 << 16 | c3 << 8 | c4);
                counter++;

                var pointGraphicData:BitmapData = new BitmapData(1,1,true,color);
                var pointGraphic:Bitmap = new Bitmap(pointGraphicData);

                pointGraphic.x = xn;
                pointGraphic.y = yn;
                pointGraphic.z = zn;
                pointGraphic.rotationX = Math.tan(Math.random() * 6);
                pointGraphic.rotationY = Math.tan(Math.random() * 6);
                pointGraphic.rotationZ = Math.tan(Math.random() * 6);
                addChild(pointGraphic);
            }
            stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove );

            this.x = 150;
            this.y = 150;
            this.z = 450;

        }



        public function handleMouseMove( event:MouseEvent ):void
        {
            this.rotationX = 0 - event.localX;
            this.rotationY = 0 - event.localY;
            this.rotationZ = 0 - Math.sqrt((event.localX * event.localX + event.localY * event.localY ));
        }

    }
}