<canvas id="canvas" width="200px" height="200px"> </canvas>
Once you’ve made your canvas, you need to find it and make a drawing object.
// Find canvas var canvas = document.getElementById("canvas"); // Make drawing object var drawOnCanvas = canvas.getContext("2d"); // Draw a rectangle on the canvas! drawOnCanvas.fillRect(50, 50, 150, 100);
Now you can use this drawing object to draw on your canvas. There are several methods and attributes you can use for your drawing, including
fillStyle, and many more.