Edit in JSFiddle

(function() {
  var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
                              window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
  window.requestAnimationFrame = requestAnimationFrame;
})();

var canvas = document.getElementById('canvas');
if (canvas.getContext) {
    
    ctx = canvas.getContext("2d");

    var draw = function () {
        ctx.beginPath()
        ctx.moveTo(20, 20);
        ctx.lineTo(40, 250);
        ctx.lineTo(100, 5);
        ctx.lineTo(150, 50);
        ctx.lineTo(321,123);
        ctx.closePath();
        ctx.strokeStyle = "#FFFFFF";
        ctx.stroke();
        
        requestAnimationFrame(draw);
    };
    requestAnimationFrame(draw);
}
<body>
    <canvas id="canvas" width="400" height="300"></canvas>
</body>
#canvas {
    background-color:black
}