Parallax Effect HTML5 Canvas Parallax The Demo

Press the LEFT or RIGHT keys to move around.

Code Drawing The Layers

This function will calculate the offset x and y position of the layer depending on the cx, cy values and a factor f that determines how fast each layer should move. It will also make sure the offset remains positive and an integer.

All layers will repeat themselves if either the repeat_x or repeat_y properties are set to true.