Daily Creative Coding

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

ヘアー

/**
* Hair
*
* @author aa_debdeb
* @date 2016/02/06
*/

void setup(){
  size(500, 500);
  noLoop();
  background(255, 239, 213);
  stroke(139, 69, 19, 100);
  noFill();
  for(int i = 0; i < 1000; i++){
     beginShape();
     boolean isFirst = true;
     float x = random(width);
     float y = random(height);
     while(true){
       if(isFirst){
         curveVertex(x, y);
         curveVertex(x, y);
         isFirst = false;
       } else {
         curveVertex(x, y);
         if(random(1) < 0.1){
           curveVertex(x, y);
           break;
         } else {
           x += map(random(1), 0, 1, -30, 30);
           y += map(random(1), 0, 1, -30, 30);       
         }
       }
     }
     endShape();
   } 
}