O'Reilly logo

Painting the Web by Shelley Powers

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

Chapter 11. Canvassing

While work was underway on SVG, Apple was doing its own thing, and the result was the canvas object.

Rather than an XML-based specification, the canvas object is just that—an object that provides a graphical “canvas” on which to create. Instead of adding separate elements, as was demonstrated with SVG earlier in this book, you create an instance of the canvas object and then manipulate it with script to create the desired effect.

The benefit to the canvas object is you don’t have to work with XML, nor the potentially large amounts of markup this might create in your web page. The disadvantage is that if a person accessing the page has scripting turned off—which many people do for security reasons—the canvas effect won’t show.

The canvas object lacks the sophistication of SVG, especially as we’ll see later in this book. However, it’s also a simple object to learn how to use, as this chapter will demonstrate. In addition, the canvas object is supported for the next generation of HTML, HTML5.

Tip

This chapter uses JavaScript extensively. See http://www.oreilly.com/catalog/9780596515096 for links to good tutorials to get you up to speed on working with this client-side scripting language.

Cross-Browser canvas Support and Microsoft’s Silverlight

There is extensive cross-browser support for the canvas object. Safari, Opera, and Mozilla support canvas out of the box, and Google supplies a JavaScript library, ExplorerCanvas, that can be added to a page and which converts ...

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