Image distortion

Next we will add a more advanced effect. We will take the image and distort it with waves to make it look like a reflection in the water. We can do this using the Math.sin() method to offset the pixel positions from their original positions in a wavy pattern. So instead of changing color channels, this time we will be moving pixels around.

Get HTML5 Web Application Development By Example Beginner's guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.