It's definitely not perfect, but hopefully someone else will improve it. Just to show the idea so that others can start on it. Also, I labelled what each part does. Will label in more detail later. It's not the worst, but it's not good enough.
Problems so far: ------------------------------------------------------------- Flickers (easy to fix, just add smoothing).