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

7. Bringing Out Your Inner Artist: The C... > A quick test drive and then LAUNCH!

A quick test drive and then LAUNCH!

We hope you’re seeing what we’re seeing! Nice huh? Give the interface a real bit of quality assurance testing: try all the combinations of colors and shapes, or swap out the username for another you like.

image with no caption

Feel like you’re ready to launch this for real? Let’s do it!

image with no caption
image with no caption
image with no caption
  1. The first thing we need is an image. We’ve put an image named twitterBird.png in the TweetShirt folder. To get that into the canvas we first need a JavaScript image object. Here’s how we get one:

    image with no caption
  2. The next part should feel pretty natural by now; we need to draw the image on the canvas using a context method named, you guessed it, drawImage.

    image with no caption
  3. There’s one other thing to know about images: they don’t always load immediately, so you need to make sure that the image has fully loaded beford you draw it. How do we wait until something is loaded before we take action? We implement an onload handler:


  

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


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint