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 vertices = [];
    var i;
    for (i = 0; i < 7; i++) {
        var dir = Math.random() * Math.PI * 2;
        vertices.push({
            "x": Math.random() * canvas.width,
            "y": Math.random() * canvas.height,
            "dirx": Math.sin(dir),
            "diry": Math.cos(dir)
        });
    }

    var draw = function () {
        ctx.strokeStyle = "#FFFFFF";
        ctx.beginPath();
        ctx.moveTo(vertices[0].x, vertices[0].y)
        for (i = 1; i < vertices.length; i++) {
            ctx.lineTo(vertices[i].x, vertices[i].y);
        }
        ctx.closePath();
        ctx.stroke();

        requestAnimationFrame(draw);
    };
    requestAnimationFrame(draw);
}
<body>
    <canvas id="canvas" width="400" height="300"></canvas>
</body>
#canvas {
    background-color:black
}