Skip to content

Instantly share code, notes, and snippets.

@nasser
Created December 18, 2010 05:36
Show Gist options
  • Save nasser/746200 to your computer and use it in GitHub Desktop.
Save nasser/746200 to your computer and use it in GitHub Desktop.
Brownian motion sketch
num = 2000
range = 6
a = []
setup do
size 420, 500
title "Brownian"
a << Point.new(width/2, height/2)
end
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
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment