🔳<canvas>

browser ⟩ canvas

<canvas> elements have 2 sizes:

  • canvas size: size displayed on the page. (that's what we set with CSS)

  • canvas resolution: number of pixels in the canvas. (like an image)

Most of the Canvas drawing API is defined not on the element itself, but instead on a “drawing context” object obtained with HTMLCanvasElement.getContext().

<canvas> only supports two primitive shapes: rectangle and path.

Last updated