The best part about the programming HTML5 Canvas is that the barrier to entry is very low. All you need is a modern web browser and a text editor.
As far as compatible browsers go, we suggest that you download and use the latest version of the following web browsers. The browsers are listed in the order that we suggest you test them:
Every example in this book was tested with Google Chrome, Safari, and Firefox. While we made every attempt to ensure that these examples worked across as many browsers as possible, we suggest that you use Google Chrome or Safari for the best results.
What You Need to Know
It would be good if you knew your way around programming in some kind of modern language like C, C++, C#, ActionScript 2, ActionScript 3, Java, or JavaScript. However, we will introduce the Canvas in the first chapter in a way that should ease you into web programming at the same time.
For Flash developers
JavaScript and ActionScript 1 are essentially the same language. While Adobe took some liberties with ActionScript 2, you should be very comfortable with JavaScript. If you have experience with only ActionScript 3, JavaScript might feel like a step backwards.
For Silverlight/C# developers
Take a deep breath, and think about a time before ASP.NET/C# when you might have had to develop web apps in VBScript. Keep your mind there, because that is just about the same space you are about to enter.
How This Book Is Organized
This book is organized into 11 chapters. All the chapters in the second edition have been updated, revised, and expanded. The first four chapters step you through the HTML Canvas API by example. The topics covered include text, images, and drawing. These chapters contain a few finished apps, but for the most part consist of demos designed to show you the facets of the Canvas API. The next six chapters build upon the Canvas API by expanding the scope of the examples to application length. In these chapters, we discuss math and physics applications, video, audio and games, and mobile. The final chapters introduce a few experimental areas: 3D, multiplayer, Windows 8, and a Canvas object model.
What you wont get in this book is a simple run-down and retelling of the published W3C Canvas API. While we cover portions of the API in detail, some of it is not applicable to games. However, if you want to explore the API further, you can find it at this site.
Instead, we want to bring to light the ways the Canvas can be used to create animation, games, and entertainment applications for the Web and mobile web.
Conventions Used in This Book
The following typographical conventions are used in this book:
ItalicIndicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.