Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Brownian motion sketch
num = 2000
range = 6
a = []
setup do
size 420, 500
title "Brownian"
a <<, height/2)
draw do
a << a.last.clone + Point.rand(range)
a.last.clamp! 0, width, 0, height
a.shift if a.length > num
for i in 0..(a.length-2)
color i.to_f/a.length * 240 + 32
line a[i].x, a[i].y, a[i+1].x, a[i+1].y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment