2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
37
Task/Brownian-tree/Processing/brownian-tree
Normal file
37
Task/Brownian-tree/Processing/brownian-tree
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
boolean SIDESTICK = false;
|
||||
boolean[][] isTaken;
|
||||
|
||||
void setup() {
|
||||
size(512, 512);
|
||||
isTaken = new boolean[width][height];
|
||||
isTaken[width/2][height/2] = true;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
for (int i = 0; i < width*height; i++) {
|
||||
int x = floor(random(width));
|
||||
int y = floor(random(height));
|
||||
if (isTaken[x][y]) { continue; }
|
||||
while (true) {
|
||||
int xp = x + floor(random(-1, 2));
|
||||
int yp = y + floor(random(-1, 2));
|
||||
boolean iscontained = (
|
||||
0 <= xp && xp < width &&
|
||||
0 <= yp && yp < height
|
||||
);
|
||||
if (iscontained && !isTaken[xp][yp]) {
|
||||
x = xp;
|
||||
y = yp;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (SIDESTICK || (iscontained && isTaken[xp][yp])) {
|
||||
isTaken[x][y] = true;
|
||||
set(x, y, #000000);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
noLoop();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue