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
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 5. Manipulating Images and Video > Creating an image from scratch

5.5. Creating an image from scratch

The last section was pretty dense, but it will be worth it as you can now move onto the really cool stuff, like creating pixels from thin air to make your very own images.

To create pixels you need to call the createImageData method of the 2d rendering context. By passing the method a width and height, you'll get returned an ImageData object with all the usual attributes: width, height, and most important, data. The CanvasPixelArray contained in the data attribute holds your new pixels, which are invisible at the moment as they're all set to a transparent black color.


  

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