A sunset that moves without changing a pixel
The sunset across the top of the home page moves. The glow drifts out from the sun and light runs across the water. Not one pixel of the picture changes while it does.

How it works
It is an old trick. The picture is stored the way an Amiga or a VGA card stored it: every pixel is a number from 0 to 255, and the numbers point into a palette of 256 colours. Change the palette and every pixel pointing into it changes with it. Rotate a run of palette entries round and round, and the light appears to move. Mark Ferrari painted whole scenes this way, and Joseph Huckaby wrote up how to run them in a browser in Old School Color Cycling with HTML5.

Ferrari painted his cycling colours by hand. A photograph has none, so they have to come from somewhere.
The obvious answer is to draw a pattern over the top: rings round the sun, stripes across the sea. It does not work. The pattern is baked into the still picture, and you see the rings even when nothing moves.
So the pattern comes from the photograph instead. The sky is boiled down to 11 colours and the sea to 9. Each of those gets a ramp of 12 shades, reaching halfway to the colours either side. A pixel goes on the shade nearest its real colour. At rest the picture is just finer, with nothing to give the trick away. Turn the ramps and the whole tone scale slides. The sky's tones sit in rings round the sun, so the glow moves outward. The sea's bright tones are scattered up the sun's path, so they flicker.

The rock and the sun's disc keep 8 fixed colours each. Add the sky's 132 and the sea's 108 and that is the 256, every one used.

Every ramp comes back to where it started at the same moment, so the whole thing loops every 24 seconds.
To see it move, go to the home page.
Reply
Replies come to me first. Tick the box and I may put yours under the post, with your name if you give one.
Comments