html canvas black square code example
Example 1: canvas fillrect
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(20, 20, 150, 100);
Example 2: js draw square to canvas
// canvas context.fillRect(x, y, height, width);
ctx.fillRect(20, 20, 150, 100);