Advertisement
Guest User

Mondrian Art

a guest
Feb 11th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. void setup() {
  2. size(400, 400);
  3. art(1, 1, 400, 400, N);
  4. }
  5. void draw() {
  6. }
  7. int N = 2;
  8. void art(int x0, int y0, int x1, int y1, int N) {
  9. if (N == 0) {
  10. int sw = 3;
  11. color c[] = { #ff0000, #00ff00, #0000ff, #ffff00, #ffffff}; //Mondarian color palatte
  12. fill(c[int(random(c.length))]);
  13. strokeWeight(sw);
  14. rect (x0, y0, x1-x0-sw, y1-y0-sw);
  15. } else {
  16. int i = int(random(x0, x1));
  17. int j = int(random(y0, y1));
  18. art(x0, y0, i, j, N-1);
  19. art(i, y0, x1, j, N-1);
  20. art(x0, j, i, y1, N-1);
  21. art(i, j, x1, y1, N-1);
  22. }
  23. }
  24. void keyPressed() {
  25. art(1, 1, 400, 400, N );
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement