Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/Brownian-tree/Processing/brownian-tree.processing
Normal file
39
Task/Brownian-tree/Processing/brownian-tree.processing
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
boolean SIDESTICK = false;
|
||||
boolean[][] isTaken;
|
||||
|
||||
void setup() {
|
||||
size(512, 512);
|
||||
background(0);
|
||||
isTaken = new boolean[width][height];
|
||||
isTaken[width/2][height/2] = true;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
int x = floor(random(width));
|
||||
int y = floor(random(height));
|
||||
if (isTaken[x][y]) {
|
||||
return;
|
||||
}
|
||||
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, #FFFFFF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (frameCount > width * height) {
|
||||
noLoop();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue