ctx.rect js code example Example: js draw square to canvas // canvas context.fillRect(x, y, height, width); ctx.fillRect(20, 20, 150, 100);