Skip to content

@nasser /brownian.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.