Back to Snippets

Cyberpunk Data Stream Matrix JS

Green characters fall down the screen in columns and leave fading trails behind them, the cyberpunk data stream look that usually sits behind a hero section. It runs full width on a canvas element and resizes with the window.

The trick is that the canvas is never cleared. Every frame paints a black rectangle at 5 percent alpha over the whole thing, dimming what came before a little at a time. That decay is the trail, and there is no per character fade being calculated anywhere.

One array holds the current row for each column. A random character is drawn at that row, the row then advances, and once a drop passes the bottom it gets a small random chance to reset to the top. That randomness is what keeps the columns from marching in step. Font size sets the column width, so raising it thins the rain out.

212
#javascript
#css
#canvas
#cyberpunk
#matrix
#data stream
#animation
#hacker
#futuristic