黄金角

by gaziya
♥0 | Line 32 | Modified 2011-11-07 14:46:42 | MIT License
play

ActionScript3 source code

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

// forked from gaziya's frocessing用スケルトン
package {
    import frocessing.display.F5MovieClip2DBmp
    import net.hires.debug.Stats
    [SWF(width=465,height=465,frameRate=30)]

    public class Main extends F5MovieClip2DBmp {
        private var gold_angle:Number = 
            Math.PI * 2 / (1 + 2*Math.cos(Math.PI / 5))
        private var count:int = 100
           
        public function setup():void {
            background(0)
            fill(0xF0F000)
            addChild(new Stats())
        }
        
        public function draw():void {
            var theta:Number
            var x:Number,y:Number,r:Number
            
            translate(width/2, height/2)
            for ( var i:int = 100; i < count; i++ ) {
              theta = gold_angle*i
              r = Math.exp(0.003 * theta) *5
              x = r*Math.cos(theta)
              y = r*Math.sin(theta)
              circle(x, y, r / 10)
            }
            count++
            if (count > 550) {
              count = 100;
              background(0)
            }      
        }
    }
}