Iteration

 

Iteration

I first wanted to create an mirror ball like background iteration but I couldn’t get the hang of it. I tried with rectangles but then it didn’t look as how I wanted it to look like. So instead I made a triangles that will go over and over again but since it looked too simple I added random colours to it mainly something of pink. It did turn out how I wanted it to be and I tried to do it with other shapes too but then the math was too complicated for me to figure out how to put it together into a shape so I just did the one with the triangle.

 

void setup(){
  size(800, 800);
  frameRate(3);
  noStroke();
}

void randomFill(){
  fill(color(random(165, 230), random(70, 185), random(160, 220)));
}

void drawTriangle( int dimension, int x1CoOrd, int y1CoOrd, 
                    int x2CoOrd, int y2CoOrd, int x3CoOrd, 
                    int y3CoOrd){
  int x1 = dimension * x1CoOrd;
  int y1 = dimension * y1CoOrd;
  int x2 = dimension * x2CoOrd;
  int y2 = dimension * y2CoOrd;
  int x3 = dimension * x3CoOrd;
  int y3 = dimension * y3CoOrd;
  randomFill();
  triangle(x1, y1, x2, y2, x3, y3);
}


void pattern(int x, int y, int dimension){
  pushMatrix();
  translate(x, y);
  drawTriangle(dimension, 0, 0, 0, 1, 1, 0);
  drawTriangle(dimension, 0, 1, 1, 0, 1, 1);
  drawTriangle(dimension, 1, 0, 1, 1, 2, 1);
  drawTriangle(dimension, 1, 0, 2, 1, 2, 0);
  drawTriangle(dimension, 0, 1, 0, 2, 1, 2);
  drawTriangle(dimension, 0, 1, 1, 1, 1, 2);
  drawTriangle(dimension, 1, 1, 1, 2, 2, 1);
  drawTriangle(dimension, 1, 2, 2, 1, 2, 2);
  popMatrix();
}

void draw(){
  background(100);
  fill( 0, 121, 184 );
  int dimension = 100;
  for (int i = 0; i < 800; i = i+200) {
    pattern(0, i, dimension);
    pattern(200, i, dimension);
    pattern(400, i, dimension);
    pattern(600, i, dimension);
  }
}

Comments are closed.