Return to Snippet

Revision: 12480
at March 16, 2009 13:29 by allnatural


Initial Code
/
function magicTrigFunctionX (pointRatio){
	return Math.cos(pointRatio*2*Math.PI);
}
function magicTrigFunctionY (pointRatio){
	return Math.sin(pointRatio*2*Math.PI);
}
//
function drawCircle(centerX, centerY, radius, sides){
	//
	// Move the pen to the first point on the circle.
	this.moveTo(centerX + radius,  centerY);
	//
	for(var i=0; i<=sides; i++){
		var pointRatio = i/sides;
		var xSteps = magicTrigFunctionX(pointRatio);
		var ySteps = magicTrigFunctionY(pointRatio);
		var pointX = centerX + xSteps * radius;
		var pointY = centerY + ySteps * radius;
		this.lineTo(pointX, pointY);
	}
}
//
lineStyle(0);
//
drawCircle(250, 250, 200, 100);
//

Initial URL
http://www.pixelwit.com/blog

Initial Description

                                

Initial Title
Dynamically Draw A Circle

Initial Tags

                                

Initial Language
ActionScript 3