Daily Creative Coding

元「30 min. Processing」。毎日、Creative Codingします。

斜めタイル

/**
* skew tiling
*
* @author aa_debdeb
* @date 2016/06/22
*/

float e = 20;
float theta = PI / 4;
float margin = 50;

void setup(){
  size(500, 500); 
  mousePressed();
}

void draw(){

}

void mousePressed(){
  fill(random(255), random(255), random(255));
  stroke(random(255), random(255), random(255));
  strokeWeight(5);
  
  for(float h = -margin; h < height + margin; h += e * 2 / sqrt(2)){
    for(float w = -margin; w < width + margin; w += e * 2 / sqrt(2)){
      pushMatrix();
      translate(w, h);
      rotate(theta);
      rect(0, 0, 2 * e, e);      
      popMatrix();
    }
  }
}