C H A P T E R 9
Canvas
Think of canvas as an image you can write on with shapes, lines, text, or other images. But not only can you write on it, but you can position, transform, manipulate, rotate, and do many other kinds of things, all with JavaScript. The <canvas>
tag itself is only a container for graphics, the way a <div>
or <header>
is a container for text for structural or textual elements on a web page.
The <canvas>
HTML element supports all the global attributes including ID and class, but adds two other attributes: width and height. These attributes take pixels as the type so a tag <canvas id="can" width="300" height="300"></canvas>
, will produce a canvas of 300 × 300 pixels.
In this chapter I talk about how to do the following.
Get Learn HTML5 and JavaScript for iOS 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.