• fullscreen
  • recursion.pde
  • //Thanks to Alasdair Turner for recursion reference
    
    float b;
    
    void setup() { 
    
      size(700, 700); 
      smooth(); 
      strokeCap(SQUARE);
    
    } 
    
    void draw() {
    
      background(0);  
      strokeWeight(18); 
      map(mouseX, 0, width, 0, PI/20);
      translate(width/2, height/2); 
      element(0); 
      println(mouseX);
    
    } 
    
    void element(int recursion) {
      
      if (recursion < 12) { 
        stroke(255, random(50, 200));
        b++;
        float a = sin(b);
        rotate(a/2000 * PI);
        line(0 + mouseX, 0, 0 + mouseX, height/3); 
        pushMatrix(); 
        translate(0, height/5); 
        rotate(noise(-PI/4, PI/4) + mouseX); 
        scale(0.7); 
        element(recursion + 1); 
        popMatrix(); 
        pushMatrix(); 
        translate(0, -height/3); 
        rotate(noise(-PI/4, PI/4) + mouseX); 
        scale(0.7); 
        element(recursion + 1); 
        popMatrix(); 
      }
      
    }
    
    
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Ben Mandeberg

    Recursion + Noise

    Add to Faves Me Likey@! 4
    You must login/register to add this sketch to your favorites.

    Move the mouse along the x-axis to cycle through different recursive structures.

    You need to login/register to comment.