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 5: Canvas > Animating your canvas paintings

Animating your canvas paintings

You’ve seen some basic animations using canvas throughout this chapter, but I wanted to explain some of the concepts in detail here.

Simple animation is mostly about clearing the current canvas state and drawing the whole thing again. This is very quick to do, as the canvas is a native drawing API. I’ll show you a demo that takes Bruce’s bouncy head and bounces it around the canvas area. This example is based on the canvas breakout tutorial by Bill Mill, but I jazzed it up with Bruce’s mug bouncing instead of a solid black ball.


The Processing JavaScript Library

As you’ll find out, it’s a blast to navigate around the canvas with a pen drawing lines and filling shapes, but there are already some libraries available that make working with the canvas much easier. One such library is called processing.js (http://processingjs.org/), written by the author of jQuery, John Resig.


  

You are currently reading a PREVIEW of this book.

                                                                                        

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

  

Start a Free Trial