Introduction to HTML Canvas

1 · Adrian Ancona Novelo · May 26, 2021, 11:25 p.m.
Summary
Canvas is an HTML element that can be used to draw graphics in the browser. The HTML element renders a rectangular area where we can draw using JavaScript. Adding a canvas to a page is as easy as: 1 <canvas></canvas> https://jsfiddle.net/ex8u0rgc/ Drawing context To draw on a canvas, we need to get a reference to the canvas’ drawing context. Here is an example of drawing a rectangle: 1 2 3 const canvas = document.getElementById('canvas'); const context = canvas.getContext('2d'); context.fillRec...