// get the canvas element
var canvas = document.getElementById('canvas-1');
// get a context to draw in
var ctx = canvas.getContext('2d');
function tick() {
// clear what was drawn in the previous frame
canvas.width = canvas.width;
// begin a new path: arc is a line instruction like lineTo
ctx.beginPath();
// define the circle: position according to time, 50px radius
ctx.arc((Date.now() / 10) % 500 + 50, 50, 50, 0, 2 * Math.PI);
// draw the circle
ctx.fill();
// request a chance to draw the circle again as soon as possible
requestAnimationFrame(tick);
}
tick();
<canvas width=600 height=100 id='canvas-1'></canvas>