Visualizing Random Walks with Canvas

August 21, 2016 | |Source Code

I don't use Canvas all that often on the client since SVG-based tools—mainly D3—are better suited for editorial data visualization. But I was thinking about random walks recently, which involve drawing thousands of dots and refreshing them several times a second, and figured it would be an interesting use case for Canvas's capabilities. Here's a little line that start's out with 10,000 points and updates 10 times a second, drawing 100 new random points and shedding the oldest 100. (Green is the newest, red is the oldest.)

Hopefully this didn't crash you're device! The code is here, and you can adjust all the parameters.