Rotating straight line around point in canvas using javascript
<p>When I run this code it produces the lines "rotating" from 0 degrees to 180, the problem is the previous line does not get cleared (so the ctx.clearRect(0,0,400,200) does not work. In the console log it shows up as running (when I try to debug) but it is not actually clearing it. Does anyone have any idea how to fix this?</p>

<pre><code>var canvas = document.getElementById("radarImage");
var ctx = canvas.getContext("2d");

var angle = 0
function incrementAngle(){

    angle++;
    if(angle&gt;180){
        angle=0;

        }


}

function rotateRadar(){

    incrementAngle();
    ctx.clearRect(0,0,400,200);
    ctx.save();
    ctx..translate(-200,-200);
    ctx.rotate((Math.PI/180)*angle);
    ctx.translate(-200,-200);
    ctx.moveTo(200,200);
    ctx.lineTo(0,200);
    ctx.stroke();
    ctx.restore;
}
setInterval(rotateRadar,200);
</code></pre>