Labels

Thursday, 26 April 2012

DSDN 142 - Code


This is my code for exploring the process from structure to noise, this code has produced me many variations with great range, my job now is to continue working on it by adding more variables and creating many more interesting structures.




int xRepeat = 10;
int yRepeat = 10;
int x = 4;  // xpos
int y = 10;  // ypos
int w = 10;  // width of rect 
int h = 10;  // height of rect
int s = 0;   // random stroke size less than this number


void setup() {
  size(500, 500);
  smooth();
  background(255);


  for (int i = -10; i < width/xRepeat; i++) {//loop 1 repeats pattern in the x direction.
    for (int j = -10; j < height/yRepeat; j++) {//loop 2 repeats the entire rows vertically.
      pushMatrix();//saves untransformed co-ordinates
      translate(xRepeat*i, yRepeat*j);// translates the entire coordinate system (is what causes the same thing to be drawn in different places).
      myPattern();
      popMatrix();//reverts to the saved co-ordinate system that we created using pushMatrix()
    }
  }
}




//ignore draw this time. use the "myPattern()" function instead
void draw() {
}




void myPattern() {
 stroke(random(s));
  fill(random(120), random(0), random(0));
  rect(random(x), random(y),w,h);
  
}


void mousePressed() {
  
 save("p2_50.jpeg"); 
  
  
}

No comments:

Post a Comment