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

3D gasket

実験
Get Adobe Flash player
by Susisu 17 Feb 2011
package {
    import flash.events.Event;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import frocessing.color.ColorHSV;
    import net.hires.debug.Stats;
    [SWF(width="512",height="512",backgroundColor="0x000000",frameRate="30")]
    public class FlashTest extends Sprite {
        private var bmd:BitmapData;
        private var bmp:Bitmap;
        private var points:Vector.<Vector.<Number>>;
        private var t:Number;
        private var now:Vector.<Number>;
        private var color:ColorHSV;
        private const vs:Number=512;
        public function FlashTest() {
            bmd=new BitmapData(512,512,false,0);
            bmp=new Bitmap(bmd);
            addChild(bmp);
            points=new Vector.<Vector.<Number>>(4,true);
            points[0]=new Vector.<Number>(3,true);
            points[0][0]=0;
            points[0][1]=0;
            points[0][2]=0;
            var n:int=1;
            for(var i:Number=0;i<2*Math.PI;i+=2*Math.PI/3){
                points[n]=new Vector.<Number>(3,true);
                points[n][0]=Math.cos(i)*128;
                points[n][1]=128*Math.SQRT2;
                points[n][2]=Math.sin(i)*128;
                n++;
            }
            now=new Vector.<Number>(3,true);
            now[0]=Math.random()*512;
            now[1]=Math.random()*512;
            now[2]=Math.random()*512;
            t=0;
            color=new ColorHSV(0,0.75);
            addChild(new Stats());
            addEventListener(Event.ENTER_FRAME,enterFrame);
        }
        private function enterFrame(e:Event):void{
            bmd.fillRect(bmd.rect,0);
            for(var i:int=0;i<20000;i++){
                var r:int=Math.random()*4>>0;
                now[0]=(now[0]+points[r][0])/2;
                now[1]=(now[1]+points[r][1])/2;
                now[2]=(now[2]+points[r][2])/2;
                var c:Number=vs/(vs+now[2]);
                var x:int=256+(now[0]*c)>>0;
                var y:int=(128*Math.SQRT2+(now[1]*c))>>0;
                color.h=now[2]+120;
                bmd.setPixel32(x,y,color.value);
            }
            var n:int=1;
            for(var j:Number=0;j<2*Math.PI;j+=2*Math.PI/3){
                points[n][0]=Math.cos(j+t)*128;
                points[n][1]=128*Math.SQRT2;
                points[n][2]=Math.sin(j+t)*128;
                n++;
            }
            t+=Math.PI/60;
            if(t>2*Math.PI)t-=2*Math.PI;
        }
    }
}