つよくなりたいなあ

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

複合モジュール #01

/*
 * 2018/09/10
 */

float tileX = 12;
float tileY = 12;
float tileWidth, tileHeight;

int count = 0;
int colorStep = 15;
int circleCount;
float endSize, endOffset;

int actRandomSeed;


void setup() {
  size(800, 800);
  tileWidth = width/tileX;
  tileHeight = height/tileY;
}

void draw() {
  noFill();
  stroke(125, 0, 170,86);
  background(255);
  randomSeed(actRandomSeed);

  translate((width/tileX)/2, (height/tileY)/2);

  circleCount = mouseX/20 * 4;
  endSize = map(mouseX, 0, width, tileWidth/2, 2);
  endOffset = map(mouseY, 0, height, 0, (tileWidth-endSize)/2);

  for (int gridY = 0; gridY <= tileY; gridY++) {
    for (int gridX = 0; gridX <= tileX; gridX++) {
      pushMatrix();
      translate(tileWidth * gridX, tileHeight * gridY);
      scale(0.8, tileHeight/tileWidth);

      int toggle = (int)random(0,4);
      if (toggle == 0) rotate(-HALF_PI);
      if (toggle == 1) rotate(0);
      if (toggle == 2) rotate(HALF_PI);
      if (toggle == 3) rotate(PI);

      for (int i = 0; i < circleCount; i++) {
        float diameter = map(i, 0, circleCount-1, tileWidth, endSize);
        float offset = map(i, 0, circleCount - 1, 0, endOffset);
        ellipse(offset+1, 2, diameter, diameter);
      }
      popMatrix();
    }
  }
}

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

f:id:heyassy:20180911011042p:plain