HTML canvas attributes code example
Example 1: javascritp canvas
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();
Example 2: canvas tag html
<canvas id="canv"></canvas>
var canvas = document.getElementById("canv");
canvas.width = canvas.height = 100;
var ctx = canvas.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(10, 10, 80, 80);