Daily Creative Coding

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

白黒の星空

f:id:aa_debdeb:20161018073212j:plain

starry sky in black and white - OpenProcessing

/**
* starry sky in black and white
*
* @author aa_debdeb
* @date 2016/10/27
*/

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

void mousePressed(){
  PVector offset = new PVector(random(10000), random(10000));
  noStroke();
  for(int x = 0; x < width; x++){
    for(int y = 0; y < height; y++){
      fill(map(pow(noise(x * 0.01 + offset.x, y * 0.01 + offset.y), 3), 0, 1, 0, 60));
      rect(x, y, 1, 1);
    }
  }
  stroke(255);
  for(int i = 0; i < 2000; i++){
    float x = random(width);
    float y = random(height);
    float size = map(pow(random(1), 2), 0, 1, 0, 2);
    if(random(1) < noise(x * 0.01 + offset.x, y * 0.01 + offset.y)){
      ellipse(x, y, size, size);
    }
  }
  filter(BLUR, 1);
}

void draw(){

}