Daily Creative Coding

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

波模様

/**
* pattern of waves
*
* @author aa_debdeb
* @date 2016/06/30
*/

float margin = 50;
float radious = 15;
float theta = 120;
color bg, sc;

void setup(){
  size(500, 500);
  noFill();
  strokeWeight(3);  
  mousePressed();
}

void mousePressed(){
  bg = color(random(255), random(255), random(255));
  sc = color(random(255), random(255), random(255));

  background(bg);
  stroke(sc);
  boolean isDisplaced = false;
  for(float h = -margin; h < height + margin; h += radious){
    for(float w = -margin; w < width + margin; w += 2 * radious){
      float w_;
      if(isDisplaced){
        w_ = w + radious;
      } else {
        w_ = w;      
      }
        arc(w_, h, (radious * 0.33) * 2, (radious * 0.33) * 2, radians(180 + (180 - theta) / 2.0), radians(360 - (180 - theta) / 2.0));
        arc(w_, h, (radious * 0.66) * 2, (radious * 0.66) * 2, radians(180 + (180 - theta) / 2.0), radians(360 - (180 - theta) / 2.0));
        arc(w_, h, radious * 2, radious * 2, radians(180 + (180 - theta) / 2.0), radians(360 - (180 - theta) / 2.0));
    }
    isDisplaced = !isDisplaced;
  }
}

void draw(){

}