flash on 2009-12-30

by _ryotaros
♥0 | Line 38 | Modified 2009-12-30 12:18:41 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import frocessing.core.F5Graphics2D;
    import frocessing.core.F5C;
    
    [SWF(width=465, height=465, backgroundColor=0)]
    public class FlashTest extends Sprite {
        
        private var fg:F5Graphics2D;
        
        public function FlashTest() {
        		fg = new F5Graphics2D( this.graphics );
        		fg.strokeCap( "none" );    
            fg.colorMode ( "hsv", 465, 1, 465 );
            for (var i:int = 0; i < 400; i++ ){
            		var cx:Number = Math.random()*465;
            		var cy:Number = Math.random()*465;
            		if( Math.random() > 0.5 ){
            			fg.noStroke();
            			fg.fill( cx, 1, cy, 0.25 );	
            		} else {
            			fg.noFill();
            			fg.strokeWeight( Math.random()*4 );
            			fg.stroke( cx, 1, cy );	
            		}
            		
            		fg.pushMatrix();//状態を保存
           		//translate⇒rotate⇒scaleの順でかける
            		fg.translate( cx, cy );
            		fg.rotate( Math.random()*2*Math.PI );
            		fg.scale( Math.random()*20 );
            		drawFig();
            		//fg.resetMatrix();
            		fg.popMatrix();
            }   
        }
        
        private function drawFig():void {
        		fg.circle( 0, 0, 0.6 );//ただ円を描画するだけ。
        		fg.arc( 0, 0, 2.0, 2.0, 0.1, 2*Math.PI-0.1 );//円弧の描画
        		fg.moveTo( -0.6, 0 );//描画開始位置へ移動
        		fg.bezierTo( -0.15, 0.6, 0.15, -0.6, 0.6, 0 );//ベジェ曲線を描画開始
        }
    }
}