Today’s is a tribute to the almighty Matrix. Although they sadly never made any sequels, and the effects have been copied so often they now seem cliché, it was an outstanding film of its time.
So here it is: a Twitter List timeline, shown as a Matrixy matrix:
Initially, I wanted to have the tweets scrolling down the page using CSS animations. Sadly, my machine got completely overwhelmed with only a few streams. I would’ve turned to my friend the canvas, but our display screens are something like 1900×800 and slow, which makes full-screen canvas too jerky. So I just rendered a large set of absolutely positioned divs, one for each character.
Reading the text is a bit tricky. I supposed that in an ideal world, the tweets would stream upwards, but I didn’t want to deviate so far from the original. And so the tweets stream down the screen, and are mostly unreadable. I have tried reversing the text, but that simply makes them harder to read. English is not a language designed for reading bottom to top.
The image in the background is taken from a png. I draw it to a hidden canvas, but draw it scaled to the same dimensions (pixels) as the grid (characters). Then, I work out the visibility (brightness+opacity) of each (now-pixellated) pixel. This is added to the “bg_opacity” property of the grid cell, which is combined with the opacity of the current character to give the effect.
It’s quite easy to swap out the list and the image, and to tune the character size, just by editing variables at the top of the script.
The code is, naturally, on Github:
Have a play, have a tinker. Let me know how I could improve the effect, and improve the performance.
I jiggled the code around a bit. Instead of absolutely positioning each character, and setting their content and opacity each time, I now insert a row of characters at a time. The row has spans for setting each char’s opacity. The bird image is now a translucent canvas overlay.
Performance is significantly better, and you can use Inspector without crashing the browser, but the layering doesn’t seem to work reliably in Chrome. I’m not sure why. So sometimes you just don’t see the bird.
And when you see super-wide Unicode characters, it can upset the grid a bit. I haven’t worried about that.
I took away “-webkit-transform-style: preserve-3d;” from the body tag, and the z-indexed layers now work properly.