Author: Steve & Jeff Fulton
Publisher: O'Reilly, 2013
Reviewer: Ian Elliot
This is a big book and you can't help but wonder why it has so much to say about Canvas - which is a fairly simple graphics subsystem. The answer is that it covers more than just Canvas and is an introduction to creating games with HTML5.
Chapters 1 and 2 tell you almost all you need to know about how Canvas works. Chapter 1 deals with the very basics and provides a simple guess a letter game. Chapter 2 pushes on into general 2D graphics where you find out about drawing arcs curves and so on.
From this point the book goes into detail about other Canvas aspects and into more general graphics topics.
Chapter 3 explains everything you could possibly want to know about text and Canvas. It also goes into some non-text related ideas about dynamic resizing. Chapter 4 is about using images and goes well beyond the basics to consider animation and creating a tile map of images.
Chapter 4 is really the last chapter that deals with pure Canvas topics. That is, after page 190 we are into general programming and more specifically graphics topics which are being expressed using Canvas. In other words from this point on we have a general course in graphics/games techniques using Canvas as the technology to implement the examples.
Chapter 5 is about Math, Physics and Animation and if you know how to bounce a ball around the screen and use gravity you might not get much from it. Of course if you don't know the basics of sprite animation this is a very valuable chapter. New in this edition is coverage of Box2D for general 2d kinematics. If you have a complex simulation to implement then this is certainly the way to do it.
Chapter 6 shows how to use Canvas and Video in HTML5 but a lot of the information is about how to use video and only later do you discover how to move a video frame to Canvas. New in this edition is coverage of WebRTC. Then the same treatment is given to audio and after we have looked at the general topic of HTML5 audio a player using Canvas and a sample space raiders game is provided to show how audio can be used within and animation.
Chapters 8 and 9 develops the game theme with a two part look at Canvas and games but in fact it is really about HTML5 games. Chapter 8 deals with the basic design details of a game - the animation loop and using sprites. A simple game Geoblaster is used as the example in both chapters. There is also final section new to the second edition on path finding and the A* algorithm. Chapter 9 goes into more detail about adding sound to games and creating a tile based game using scrolling.
It is fair to sum up the bulk of the book, from Chapter 5 to 8 as a "how to create games in HTML5" and
The final two chapters take us beyond Canvas in other ways. Chapter 10 is about using Cordova, aka PhoneGap, to create mobile apps and chapter 11 is about 3D using WebGL and multiplayer using ElectroServer.
If you are looking for a book focused on Canvas and how you use it then you might be disappointed that this book covers more than you would like. In other words, is not a concise introduction to Canvas for programmers who already know graphics techniques.
The example programs are long and often run over many pages without any break for description. The same code is presented repeatedly and there is much wasted space. If you already know a lot of graphics and animation techniques then you probably don't need to have the wider picture explained to you. On the other hand if you are a beginner not only to Canvas but to the sorts of things you might use it for then this might be a good choice of book.
For me the book could have spent longer on describing the available Canvas methods and properties and how these can be used to best effect rather than writing long games that demonstrate how animation and explosions work. If you are looking for serious non-game applications of Canvas you might also be disappointed.
The final verdict is that if you want to find out how to build 2D games using HTML5 this is a reasonable place to start.