Created
December 18, 2010 05:36
-
-
Save nasser/746200 to your computer and use it in GitHub Desktop.
Brownian motion sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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