Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

CHAPTER 9: Canvas

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.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint