Canvas element
The HTML canvas element is a scriptable bitmap drawing surface in a web document, with an API for rendering graphics.
Web Components in Action
- How it is used
- Serves as the drawing surface for component-based 3D scenes and processed video frames.
- How deep it goes
- Shows canvas placement, engine setup, refresh timing, and pixel filtering, but leaves low-level drawing largely to libraries and components.
- Examples
- Uses a Babylon.js 3D scene and live-camera black-and-white and “snow” filters.
- What you can do after
- Apply it via Babylon.js or video components to render a scene or alter displayed camera frames.
D3.js in Action, Third Edition
The Canvas API is the browser scripting interface for drawing on and reading from an HTML canvas bitmap.
- How it is used
- Replaces numerous SVG marks with pixel drawing when dense visualizations, animations, or gradients make Canvas a useful performance choice.
- How deep it goes
- Works through element sizing, pixel density, 2D context setup, and pixel-based interaction; defers WebGL.
- Examples
- Uses a shape gallery for setup and a dense painting visualization for mixed rendering and hover detection.
- What you can do after
- Build it from scratch: size a canvas, obtain its 2D context, and plan interaction for drawings without individual DOM elements.
Read how D3.js in Action, Third Edition explains canvas element →
HTML5 in Action
The canvas element is an HTML element that provides a drawable region for graphics rendered by scripts.
- How it is used
- Uses a script-drawn region for interactive graphics and for combining or manipulating video imagery.
- How deep it goes
- Explains 2D drawing methods and a staged video-rendering workflow, including image processing and captured drawings.
- Examples
- Uses an interactive game and a video telestrator with image overlays, grayscale, and mouse-drawn annotations.
- What you can do after
- Build it from scratch by drawing interactive graphics or combining video frames with images and user drawings.
Get Programming: Learn to code with Python
- How it is used
- Provides a drawing area for placing game shapes in a Tkinter window.
- How deep it goes
- Defines the canvas as a rectangular widget and demonstrates colored rectangles, but stops short of detailing its full drawing API.
- Examples
- Uses two randomly positioned, differently sized player rectangles in a tag game.
- What you can do after
- Build it from scratch by adding a canvas to a Tkinter window and placing shapes on it.
Read how Get Programming: Learn to code with Python explains canvas element →
Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond
An HTML element that provides a scriptable bitmap drawing surface for web graphics.
- How it is used
- Uses a canvas and its 2D context to paint images for a web gallery.
- How deep it goes
- Explains context setup, image drawing and alpha-based fading, without detailing canvas internals.
- Examples
- Draws an image across a gallery canvas, then fades it in by increasing alpha over animation frames.
- What you can do after
- Apply the Canvas 2D context to draw images and create a fade-in effect.
Related concepts
- WebGLused by · WebGL is a JavaScript API standard for rendering interactive two-dimensional and three-dimensional graphics in web browsers, typically with hardware acceleration.
- JavaScriptuses · JavaScript is a high-level, dynamically typed programming language standardized as ECMAScript and used for web and general-purpose programming.
- Document Object Modelcontrasts with · The Document Object Model is a platform-independent programming interface that represents a document as a structured tree of nodes and provides ways to access and modify its content and structure.
- SVGalternative to · SVG (Scalable Vector Graphics) is an XML-based standard and markup language for describing scalable two-dimensional vector graphics.
- beginPath()used by · The Canvas 2D beginPath() method starts a new path by clearing the context’s list of subpaths for subsequent drawing operations.
- bitmap imageproduces · A bitmap image is a raster representation of visual content as a grid of individually encoded pixels.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




