O'Reilly logo

Learn HTML5 and JavaScript for iOS by Scott Preston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required