Drawing lines

<html>
<body>
<canvas id="canvas" width="300" height="300"></canvas>
<script type="application/x-javascript">
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.strokeStyle = "rgb(0,0,200)";
var i;
for(i=0;i<300;i++){
 ctx.beginPath();
 ctx.moveTo(300-i,0);
 ctx.lineTo(0,i);
 ctx.stroke();
}
</script>
</body>
</html>