how to draw on canvas js code example
Example 1: javascript create canvas
var canvas = document.createElement("canvas"); //Create canvas
document.body.appendChild(canvas); //Add it as a child of <body>
Example 2: javascritp canvas
//Creates a canvas and draws a circle
var canvas = document.body.appendChild(document.createElement("canvas"));
var ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height / 2, 50, 0, Math.PI * 2);
ctx.fillStyle = "red";
ctx.strokeStyle = "black";
ctx.stroke();
ctx.fill();