Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //int x0
- //int y0
- // int x1
- // int y1
- // int i
- // int j
- // (x0, y0) = top left corner
- // (x1, y0) = top right corner
- // (x0, y1) = bottom left corner
- // (x1, y1) = bottom right corner
- // (i, j) = intersection creating first four rerctangles
- //void mondrian (int x1, int y1, int x2, int y2, int level);
- //rmondrian (x0, y0, i, j, level +1 );
- //rmondrian (x1, y0, i, j, level +1);
- //rmondrian (x0, y1, i, j, level +1);
- //rmondrian (x1, y1, i, j, level +1);
- void setup() {
- size(400, 400);
- rmondrian(0, 0, 400, 400, 0);
- }
- void rmondrian(int x0, int y0, int x1, int y1, int level ) {
- int i= int(random(x0, x1));
- int j = int(random(y0, y1));
- if (level == 2) {
- return;
- } else {
- line(i, y0, i, y1);
- line(x0, j, x1, j);
- fill(random(0, 255), random(0, 255), random(0, 255));
- rect(x0, y0, i, j);
- fill(random(0, 255), random(0, 255), random(0, 255));
- rect(i, y0, x1, j);
- fill(random(0, 255), random(0, 255), random(0, 255));
- rect(x0, j, i, y1);
- fill(random(0, 255), random(0, 255), random(0, 255));
- rect(i, j, x1, y1);
- level=level+1;
- rmondrian (x0, y0, i, j, level);
- rmondrian (i, y0, x1, j, level);
- rmondrian (x0, j, i, y1, level);
- rmondrian (i, j, x1, y1, level );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement