CHAPTER 9

image

Canvas Reference

This chapter will provide a detailed reference for the canvas element and the 2D drawing context API. For detailed discussions about these features and more examples, see Chapter 4.

The canvas Element

The HTML5 canvas element enables you to draw bitmaps on web pages by providing a blank “canvas” to work on. The canvas element itself is a block-level DOM element. To use a canvas element for drawing, you have to fetch a drawing context reference from the element. The context exposes an extensive API for drawing that you can use in your scripts.

The API definition for the canvas element itself is:

Interface HTMLCanvasElement ...

Get HTML5 Programmer’s Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.