Skip to content

Instantly share code, notes, and snippets.

@yoggy
Created October 12, 2014 06:53
Show Gist options
  • Save yoggy/ccab4fc681a7d64936ae to your computer and use it in GitHub Desktop.
Save yoggy/ccab4fc681a7d64936ae to your computer and use it in GitHub Desktop.
class Walker {
PVector position;
float top, bottom, left, right;
float radian;
Walker() {
reset();
}
void reset() {
position = new PVector();
position.x = width / 2;
position.y = height / 2;
top = random(1.0);
bottom = random(1.0);
left = random(1.0);
right = random(1.0);
radian = random(3.0);
}
void draw() {
radian = random(3.0);
position.x += random(-left, right);
position.y += random(-top, bottom);
ellipse(position.x, position.y, radian, radian);
}
}
Walker [] walkers;
void setup() {
size(600, 600);
walkers = new Walker[10000];
for (int i = 0; i < walkers.length; ++i) {
walkers[i] = new Walker();
}
background(0);
}
void draw() {
noFill();
fill(0, 0, 0, 10);
rect(0, 0, width, height);
tint(255, 255);
noStroke();
fill(255, 10);
for (int i = 0; i < walkers.length; ++i) {
walkers[i].draw();
}
}
void keyReleased() {
if (key == 'c') {
for (int i = 0; i < walkers.length; ++i) {
walkers[i].reset();
}
background(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment