forked from: Flower

by onedayitwillmake forked from Flower (diff: 8)
write as3 code here..
♥0 | Line 48 | Modified 2009-06-05 05:25:18 | MIT License
play

ActionScript3 source code

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

// forked from onedayitwillmake's Flower
// forked from nutsu's f5 color test 1
// write as3 code here..
// write as3 code here..
package{
    import flash.display.*;
    import flash.events.*;
    
    import frocessing.FC;
    import frocessing.color.FColor;
    import frocessing.core.F5Graphics2D;

    [SWF(frameRate="120", width="465", height="465", backgroundColor="#000000")] 
    
    public class ColorWheel extends Sprite
    {
    	private var numBlocks:int = 250;
    	private var startColor:int = 55;
    	
        public function ColorWheel() 
        {
            stage.quality = 'low';
            stage.scaleMode = 'noScale';
            stage.align = "TL";
            addEventListener(Event.ENTER_FRAME,draw);
        }
        
        private function draw(e:Event):void
        {
        	startColor = (startColor + 1) % 360;
			var n:int;
			
			var c:FColor = new FColor();
            	c.hsv(startColor, 1, 1);
            	
            var fg:F5Graphics2D = new F5Graphics2D(graphics);
            	fg.noStroke();
				fg.rectMode(FC.CENTER); 
				fg.beginDraw();
				fg.translate( stage.stageWidth >> 1, stage.stageHeight >> 1);
				//fg.rotate( -FC.HALF_PI);
           
           
          
          //  if(numBlocks < stage.stageWidth * 0.5)	 
            //	numBlocks++;
             
            n = numBlocks;
            var maxDistance:int = stage.stageWidth >> 1;
           	var change:Number = Math.sqrt((stage.mouseX-maxDistance) * (stage.mouseX - maxDistance)) / maxDistance
            //var percentage = 
            //trace(change)
            for( var i:int=0; i< n; i++ )
            {
                for(var j:int = 0; j < 3; j++)
                {
                    c.h -= 0.1 + (0.1 * change)
                	//c.h -= 0.1;
                    fg.fillColor = c.value;
                   	fg.fillAlpha = 1 
                    //Start locationX, startLocationY, howhigh, how wide
                   	//fg.rect( (i+1) * 2, (i+1) * 2, 16 + (i*0.2), 16 + (i*0.2));
                   	var grow:Number = 0.5;
                   	//fg.circle(i,
                   	fg.rect(i, i, 8 + (i * grow), 8 + (i * grow));
                    //fg.rotate(FC.PI * 56 / n - 0.08);
                    fg.rotate(0.2); 
                }
            }
            
            fg.endDraw();
            
          
            
        }
    }
}