Mathmatically Correct, but logiaclly flawed

Mathematically the circle can't just be described by a line, which is a crude approximation of what the original code was doing.

The central code could be replaced by this:

Code:

`var x, y, r2;`

var radius = 50

var xCenter = 200

var yCenter = 300

var xold = -1

var yold = -1

r2 = radius * radius;

window.onload = function() {

for (var i = 0; i <= 360; i+=(50/radius)) {

x = parseInt(xCenter+(radius*Math.sin(i*(Math.PI/180)))+0.5)

y = parseInt(yCenter+(radius*Math.cos(i*(Math.PI/180)))+0.5)

if(xold!=x || yold!=y)

{

xold = x;

yold = y;

draw(x, y);

}

}

}

It uses the same inputs as before, but follows the path of a circle from the top most point clockwise.

It also has a value added feature.

An 'if' condition to only write new divs to the page. The old code would write a new div even if there was already one there!

Wooo! First post :)