Home > Articles > Web Development > HTML/CSS

  • Print
  • + Share This
From the author of Feature #6: Offscreen Canvases

Feature #6: Offscreen Canvases

Canvas-based applications often use offscreen canvases, typically to pre-render all or part of an onscreen canvas; in fact, offscreen canvases are often critical for performance reasons.

Fortunately, because canvas is an HTML element, you can easily create an offscreen canvas like this:

var offscreenCanvas = document.createElement('canvas');

Once you've drawn into an offscreen canvas, you can copy it onscreen with the 2D context's versatile drawImage() method. I discuss that method in the later section "Feature #3: Drawing Images and More with drawImage()."

  • + Share This
  • 🔖 Save To Your Account