Documentation000_upload
Transform your PDFs into Flipbooks and boost your revenue!
Leverage SEO-optimized Flipbooks, powerful backlinks, and multimedia content to professionally showcase your products and significantly increase your reach.
// Claus Rytter Bruun de Neergaard
// www.clausclaus.com, March, 2013
// Tested in Processing 2.0b8
// RANDOM WALK, TWO-DIMENSIONAL WORLD, SLOW-GROW
int N = 0, NE = 1, E = 2, SE = 3, S = 4, SW = 5, W = 6, NW= 7;
int step = 1;
int dir;
float x, y;
void setup() {
size(670, 400);
background(255);
smooth();
strokeWeight(0.25);
fill(200, 200);
// start at center
x = width/2;
y = height/2;
}
void draw() {
// for each loop draw 25 pts
for (int i = 0; i < 25; i++) {
dir = int(random(0, 8));
// compare dir to all ‘world’ directions
if (dir == N) {
y -= step;
}
else if (dir == NE) {
x += step;
y -= step;
}
else if (dir == E) {
x += step;
}
else if (dir == SE) {
x += step;
y += step;
}
else if (dir == S) {
y += step;
}
else if (dir == SW) {
x -= step;
y += step;
}
else if (dir == W) {
x -= step;
}
else if (dir == NW) {
x -= step;
y -= step;
}
// screen wrap
if (x > width) x = 0;
if (x < 0) x = width;
if (y < 0) y = height;
if (y > height) y = 0;
// draw point
point(x+step, y+step);
}
}
code studies --- 3 | 29