computationclub/computationclub.github.io — pull request #22 by mudge (2014-10-18 11:26:10+00:00)
Title: Bouncing automaton

Profiling the existing automaton in Chrome seems to show that most time is spent in `putImageData` because the whole automaton changes on every frame.

Instead of scrolling, draw each new row from the top down (thereby changing only one row per frame) and then draw from the bottom up (again, only changing one row per frame).

This changes the behaviour of the automaton (so it effectively "bounces" up and down) but seems to be a little lighter on my aging laptop's already creaky fans.

Also, instead of forcing a frame rate with `setInterval`, use the [`requestAnimationFrame` API](http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/) to be a little kinder on the browser.

Of course, if we want to stick with the infinite scrolling, we'll need to come up with a different approach altogether.