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: flash on 2009-8-1

Get Adobe Flash player
by tsutaya42 09 Aug 2009
/**
 * Copyright tsutaya42 ( http://wonderfl.net/user/tsutaya42 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/xeWG
 */

package {
    import frocessing.display.*;
    [SWF(width=465,heigth=465,backgroundColor=0x0000000, frameRate="60")]
    
    public class FrocessingSample extends F5MovieClip2DBmp
    {
        private var n:uint;
        private var brushes:Vector.<BrushState>;
        
        public function setup():void
        {
            size( 465, 465 );
            background( 0x000000 );
            colorMode( HSV, 1 );
            
            n = 5;
            brushes = new Vector.<BrushState>();
            
            for ( var i:int = 0; i < n; i++ ) {
                var brush:BrushState = new BrushState();
                
                with ( brush ) {
                    vx = vy = 0;
                    xx = mouseX;
                    yy = mouseY;
                    ac = random( 0.1, 0.15 );
                    de = 0.91;
                    wd = random( 0.04, 0.06 );
                    
                    //座標の初期化
                    px0 = [ xx, xx, xx ];
                    py0 = [ yy, yy, yy ];
                    px1 = [ xx, xx, xx ];
                    py1 = [ yy, yy, yy ];
                }
                
                brushes.push( brush );
            }
        }
        
        public function draw():void
        {
            for ( var i:int = 0; i < n; i++ ) {
                var _brush:BrushState = brushes[i];
                
                with ( _brush ) {
                    
                var px:Number = xx;
                var py:Number = yy;
                
                xx += vx += ( mouseX - xx ) * ac;
                yy += vy += ( mouseY - yy ) * ac;
                
                
                var x0:Number = px + vy*wd;
                var y0:Number = py - vx*wd;
                var x1:Number = px - vy*wd;
                var y1:Number = py + vx*wd;
            
                //描写処理
                noStroke();
                fill( random( 0.95, 1 ), random( 0.3, 1 ), random( 0.3, 1 ) );
            
                beginShape();
                curveVertex( px0[0], py0[0] );
                curveVertex( px0[1], py0[1] );
                curveVertex( px0[2], py0[2] );
                curveVertex( x0, y0 );
                vertex( px1[2], py1[2] );
                curveVertex( x1, y1 );
                curveVertex( px1[2], py1[2] );
                curveVertex( px1[1], py1[1] );
                curveVertex( px1[0], py1[0] );
                endShape();
                
                //座標の更新
                px0.shift(); px0.push( x0 );
                py0.shift(); py0.push( y0 );
                px1.shift(); px1.push( x1 );
                py1.shift(); py1.push( y1 );
                
                vx *= de;
                vy *= de;
                }
            }
        }
    }
}

class BrushState
{
    public var xx:Number;
    public var yy:Number;
    public var vx:Number;
    public var vy:Number;
    public var ac:Number;
    public var de:Number;
    public var wd:Number;
    
    public var px0:Array;
    public var py0:Array;
    public var px1:Array;
    public var py1:Array;
    
    public function BrushState() {}
}