/ Published in: ActionScript 3
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/
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);
//
URL: http://www.pixelwit.com/blog
Comments
 Subscribe to comments
                    Subscribe to comments
                
                