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 ...
Get Painting the Web 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.