SHARE
TWEET

Recursion

xeromino Oct 15th, 2013 336 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float sz, theta, ns, sw;
  2. color[] palette = {
  3.   #E08E79, #F1D4AF, #ECE5CE, #C5E0DC
  4. };
  5.  
  6. void setup() {
  7.   size(800, 600);
  8.   background(#774F38);
  9.   noFill();
  10.   rectMode(CENTER);
  11.   sw = 20;
  12.   sz = width/3;
  13.   ns = random(10);
  14.   drawRect(width/2, height/2, sz, 4);
  15. }
  16.  
  17. void drawRect(float x, float y, float sz, int num) {
  18.   float nx, ny, nsz, cn;
  19.   int nn;
  20.   strokeWeight(sw);
  21.   println(sw);
  22.   fill(255, 50);
  23.   stroke(palette[int(random(palette.length))], 200);
  24.   //rect(x, y, sz, sz, sz/5 );
  25.   ellipse(x, y, sz, sz);
  26.   sw = 2;
  27.   if (num > 0) {
  28.     nn = num-1;
  29.     nx = x;
  30.     ny = y-sz/2;
  31.     drawRect(nx, ny, sz/2, nn);
  32.     nx = x +sz/2;
  33.     ny = y ;
  34.     drawRect(nx, ny, sz/2, nn);
  35.     nx = x;
  36.     ny = y +sz/2;
  37.     drawRect(nx, ny, sz/2, nn);
  38.     nx = x-sz/2;
  39.     ny = y;
  40.     drawRect(nx, ny, sz/2, nn);
  41.   }
  42. }
  43.  
  44. void draw() {
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top