Daily Creative Coding

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

多層の正方形

/**
* multi-layered squares
*
* @author aa_debdeb
* @date 2016/09/24
*/

int num = 40;

void setup(){
  size(500, 500);
  rectMode(CENTER);
  strokeWeight(1);
}

void draw(){
  background(240);
  for(int i = 0; i <= num; i++){
    stroke(240);
    fill(30);
    float x = width / 2 + map(mouseX, 0, width, -5, 5) * map(i, 0, num, -num / 2.0, num / 2.0);
    float y = height / 2 + map(mouseY, 0, width, -5, 5) * map(i, 0, num, -num / 2.0, num / 2.0);
    rect(x, y, 250, 250);
  }
}
f:id:aa_debdeb:20160920172605j:plain