つよくなりたいなあ

地に足をつけず世界を生きぬくブログです

マウスの位置で円の動きを変える

/*
 * 2018/09/09
 */

float tileCount = 40;
int circleAlpha = 80;
int actRandomSeed = 0;

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

void draw() {
  translate(width/tileCount/4, height/tileCount/4);
  background(0);
  smooth();
  noFill();

  randomSeed(actRandomSeed);

  stroke(250, 125, circleAlpha);
  strokeWeight(mouseY/60);

  for (int gridY = 0; gridY < tileCount; gridY++) {
    for (int gridX = 0; gridX < tileCount; gridX++) {
      float posX = width/tileCount * gridX;
      float posY = height/tileCount * gridY;

      float shiftX = random(-mouseX, mouseX)/35;
      float shiftY = random(-mouseX, mouseX)/40;

      ellipse(posX+shiftX, posY+shiftY, mouseX/15, mouseY/15);
      if(mousePressed){
      rect(posX+shiftX, posY+shiftY, mouseX/15, mouseY/15);
      fill(250,200,200);
      
      }
    }
  }
}

void mousePressed() {
  actRandomSeed = (int) random(100000);
}