見出し画像

ProcessingでGenerative art#15


blendMode(ADD)をうまく使いたくて、重なりが欲しかったのでガウス分布を使ってみました。

Code

DotCircle dc[] = new DotCircle[78];

void setup(){
  size(960, 540);
  pixelDensity(2);
  colorMode(HSB, 360, 100, 100, 100);
  noLoop();
  blendMode(SUBTRACT);
}

void draw(){
  background(360);
  for(int i=0;i<dc.length;i++){
    dc[i] = new DotCircle(randomGaussian()*300 + width/2, randomGaussian()*150 + height/2);
  }
  for(int i=0;i<dc.length;i++){
    dc[i].display();
  }
}

void mousePressed(){
  redraw();
}

void keyPressed(){
  if(key == ' '){saveFrame("####.png");}
}

//-----------------------------------------------------------

class DotCircle{
  float x,y;
  float tx, ty;
  float rad;
  float r;
  float theta;
  float alph;
  float inc;
  color col;
  
  DotCircle(float _x, float _y){
    rad = random(10,100);
    r = map(rad, 10, 100, 10, 30);
    tx = _x;
    ty = _y;
    inc = map(rad, 10, 100, 4, 1);
    col = color(random(360), 85, 90);
  }
  
  void display(){ 
    pushMatrix();
    translate(tx, ty);
    for(int i=0;i<r;i+=1){
      alph = map(i, 0, r, 100, 0);
      for(int j=0;j<360;j+= inc){
        theta = radians(j);
        x = (rad + i) * sin(theta);
        y = (rad + i) * cos(theta);
        noFill();
        stroke(col,alph);
        point(x, y);
      }
    }
    popMatrix();
  }
}

Happy coding!

応援してくださる方!いつでもサポート受け付けてます!