for(i = 0; i < 100000; i=i+1) { pen.beginPath() var red = Math.floor(Math.random() * 256); var green = Math.floor(Math.random() * 256); var blue = Math.floor(Math.random() * 256); pen.strokeStyle = "rgb(" + red + "," + green + "," + blue + ")"; pen.lineWidth=5; //alert(pen.fillStyle); var canvas = document.getElementById("canvas"); var pen = canvas.getContext("2d"); var x = Math.random()*1200; var y = Math.random()*500; var x1 = Math.random()*1200; var y1 = Math.random()*500; pen.moveTo(x,y); pen.lineTo(x1,y1); pen.stroke(); pen.closePath(); }