読者です 読者をやめる 読者になる 読者になる

Daily Creative Coding

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

四角形で塗りつぶす

/**
* fill by rect
*
* @author aa_debdeb
* @date 2016/12/22
*/

float RECT_WIDTH = 150;
PVector offset;

void setup(){
  size(500, 500);
  rectMode(CENTER);
  offset = new PVector(random(10000), random(10000));
  background(220);
}

void draw(){
  noStroke();
  translate(width / 2, height / 2);
  float centerX = map(noise(frameCount * 0.01 + offset.x), 0, 1, -RECT_WIDTH / 2, RECT_WIDTH / 2);
  float centerY = map(noise(frameCount * 0.01 + offset.y), 0, 1, -RECT_WIDTH / 2, RECT_WIDTH / 2);
  translate(centerX, centerY);
  rotate(frameCount * 0.02);
  fill(0, 255, 255);
  noStroke();
  rect(-centerX, -centerY, RECT_WIDTH, RECT_WIDTH);
  stroke(0, 206, 209, 50);
  line(-centerX - RECT_WIDTH / 2, -centerY - RECT_WIDTH / 2, -centerX - RECT_WIDTH / 2, -centerY + RECT_WIDTH / 2);
  line(-centerX + RECT_WIDTH / 2, -centerY - RECT_WIDTH / 2, -centerX + RECT_WIDTH / 2, -centerY + RECT_WIDTH / 2);
}
f:id:aa_debdeb:20161220212651j:plain