• fullscreen
  • t_hatch_test_001.pde
  • //object constructors:
    
    
    // enviroment setup :
    void setup() {
      size(1000,400);
      background(0);
      stroke(255);
      smooth();
    }
    
    // df variables :
    float s;
    
    // functions :
    void f_center() { // move to center of frame
      translate(width/2,height/2);
    }
    
    void f_tHatch_001a(float d) {
      d *= 0.66f;
      if (d > 2) {
        pushMatrix();
        line(0,0,0,d);
        rotate(radians(random(60,180)));
        line(0,0,0,d/2);
        translate(0,d/2);
        f_tHatch_001a(d);
        //popMatrix(); 
        
        translate(0,d);
        f_tHatch_001a(d);
        popMatrix();
        
        pushMatrix();
        line(0,0,0,-d);
        rotate(radians(random(60,180)));
        line(0,0,0,-d/2);
        translate(0,-d/2);
        f_tHatch_001a(-d);
        //popMatrix();
        
        translate(0,-d);
        f_tHatch_001a(-d);
        popMatrix();
      }
    }
    
    // run :
    void draw() {
      f_center();
      
      if (s < 1) {
        s = width;
        translate(0,0);
      } else if (s >= 1) {
        translate(random(-width/2,width/2),random(-height/2,height/2));
      }
      
      int clr = int(random(0,2.3));
      switch(clr) {
        case 0 : // clr match 0
          stroke(0);
          break;
        case 1 : // clr match 1
          stroke(255);
          break;
        default : // no match
          stroke(255);
          break;
      }
      
      f_tHatch_001a(-s/2);
      f_tHatch_001a(s/2);
      noLoop(); // stop executing
    }
    
    // interactions :
    void mousePressed() {
      if (width > height) {
        s = mouseX*2;
      } else if (width < height) {
        s = mouseY*2;
      } else if (width == height) {
        s = (mouseX-width/2)*(mouseY-height/2);
      }
      redraw();
    }
    
    void keyReleased() { 
      saveFrame("tHatch001a-####.tga");
    }
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement

    Olga Galvanova

    tHatch_001a

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

    very simple script with quite interesting results - just keep clicking on stage

    You need to login/register to comment.