O'Reilly logo

HTML5 Web Application Development By Example Beginner's guide by J.M. Gustafson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – the imageEffects object

We will now create a new object called imageEffects to encapsulate all of the code for our image effects and put it in a new file, imageEffects.js. The imageEffects object will be a global static object defined using the revealing module pattern.

Note

With the revealing module pattern, you define a set of functions in a private scope and then return an anonymous object that reveals which of those methods you want to be public. This works well for defining static objects.

Let's start by defining the imageEffects object and adding two helper functions which will remain private. They are used to get and set the image data for the entire canvas:

var imageEffects = function() { function getImageData(canvas) { return ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required