function onInit()
{
    totalSides = 6;
	randomizeSides = false;
	
	radius = 20;
	randomizeRadius = false;
	
	valC = 0;
	randC = false;
	
	valM = 0;
	randM = false;
	
	valY = 0;
	randY = false;
	
	valK = 0;
	randK = false;
	
	specificRotate = 0;
	rotateArt = true;
	
	scatter = false;
	scatterOffset = 100;
}

function onOptions()
{
    var values = Dialog.prompt("Art Tests:", [
                                              
        {value:totalSides,description:"Total Sides:",width:100},
		{value:randomizeSides,description:"Random:",width:100},
		
		{value:radius,description:"Radius:",width:100},
		{value:randomizeRadius,description:"Random:",width:100},
		
		{value:valC,description:"Cyan",width:100},
		{value:randC,description:"Randomize",width:100},
		
		{value:valM,description:"Magenta",width:100},
		{value:randM,description:"Randomize",width:100},
		
		{value:valY,description:"Yellow",width:100},
		{value:randY,description:"Randomize",width:100},
		
		{value:valK,description:"Black",width:100},
		{value:randK,description:"Randomize",width:100},
		
		{value:specificRotate,description:"Specific Rotate",width:100},
		{value:rotateArt,description:"Random Rotate",width:100},
		
		{value:scatter,description:"Random Scatter",width:100},
		{value:scatterOffset,description:"Scatter Offset",width:100}
        
    ]);
    
    if(values != null)
    {
        totalSides     	= values[0];    
        randomizeSides 	= values[1];
		radius			= values[2];
		randomizeRadius	= values[3];
	
		valC 			= values[4];
		randC 			= values[5];
	
		valM 			= values[6];
		randM 			= values[7];
		
		valY 			= values[8];
		randY 			= values[9];
		
		valK 			= values[10];
		randK 			= values[11];
		
		specificRotate 	= values[12];
		rotateArt 		= values[13];
		
		scatter 		= values[14];
		scatterOffset 	= values[15];
    }
    
}

function onMouseDown(event)
{
}

function onMouseUp(event)
{
    
    
}

function onMouseDrag(event)
{
	var radiusResetValue = radius;
	var totalSidesResetValue = totalSides;
	
	var areaX;
	var areaY;
	
	var cyan 	= randC ? Math.random() : valC;
	var magenta = randM ? Math.random() : valM;
	var yellow 	= randY ? Math.random() : valY;
	var key 	= randK ? Math.random() : valK;
	
	var clr = new CMYKColor(cyan,magenta,yellow,key);
	var fll = new FillStyle(clr,false);
	
	if(randomizeSides)
	{
		totalSides = Math.max(3,Math.ceil(Math.random()*totalSides));
	}
	
    var mousePoint = new Point(event.point);
    var rads = 360/totalSides*(Math.PI/180);
	
	var segments = new SegmentList();
	
	if(randomizeRadius)
	{
		radius = Math.random()*radius;
	}
	
	if(scatter)
	{
		areaX = Math.random() * scatterOffset;
		areaY = Math.random() * scatterOffset;
	}
	
	for(var i = 1; i <= totalSides; i++)
	{
		if(scatter)
		{
			var	originX = (Math.cos(rads)*radius) + mousePoint.x + areaX;
			var originY = (Math.sin(rads)*radius) + mousePoint.y + areaX;
			var pointX = (Math.cos(rads * i)*radius) + mousePoint.x + areaX;
			var pointY = (Math.sin(rads * i)*radius)+ mousePoint.y + areaX;
		}
		else
		{
			var	originX = (Math.cos(rads)*radius) + mousePoint.x;
			var originY = (Math.sin(rads)*radius) + mousePoint.y;
			var pointX = (Math.cos(rads * i)*radius) + mousePoint.x
			var pointY = (Math.sin(rads * i)*radius)+ mousePoint.y
		}
		
		i == 1 ? segments.moveTo(originX, originY) : segments.lineTo(pointX, pointY);
		
		if(i == totalSides)
		{
			segments.lineTo(originX, originY);
		} 
	}
    
	var path = new Path(segments);
	
	path.style.fill.color = clr;
	
	if(rotateArt)
	{
		path.rotate(Math.random()*360, mousePoint);
	}
	else
	{
		path.rotate(specificRotate, mousePoint);
	}
	
	radius = radiusResetValue;
    totalSides = totalSidesResetValue;
} 




