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

Daily Creative Coding

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

金の板

f:id:aa_debdeb:20160715085630j:plain
/**
* golden plate
*
* @author aa_debdeb
* @date 2016/07/20
*/

color gold1, gold2;
PVector[] noiseOffsets;

void setup(){
  size(500, 500, P3D);
  noStroke();
  colorMode(HSB, 360, 100, 100);
  gold1 = color(43, 100, 85);
  gold2 = color(43, 20, 85);
  noiseOffsets = new PVector[3];
  for(int i = 0; i < 3; i++){
    noiseOffsets[i] = new PVector(random(10000), random(10000));
  }
}

void draw(){
  background(60);
  translate(width / 2, height / 2);
  rotateY(map(mouseX, 0, width, -PI / 6, PI / 6));
  rotateX(map(mouseY, 0, height, PI / 6, -PI / 6));
  for(int x = - 150; x <= 150; x += 2){
    for(int y = -150; y <= 150; y += 2){
      pushMatrix();
      translate(x, y);
      float h = map(noise(x * 0.003 + noiseOffsets[0].x, y * 0.01 + noiseOffsets[0].y, mouseX * 0.001 + mouseY * 0.001), 0, 1, hue(gold1), hue(gold2));
      float s = map(noise(x * 0.003 + noiseOffsets[1].x, y * 0.01 + noiseOffsets[1].y, mouseX * 0.001 + mouseY * 0.001), 0, 1, saturation(gold1), saturation(gold2));
      float b = map(noise(x * 0.003 + noiseOffsets[2].x, y * 0.01 + noiseOffsets[2].y, mouseX * 0.001 + mouseY * 0.001), 0, 1, brightness(gold1), brightness(gold2));
      fill(h, s, b);
      rect(0, 0, 2, 2);
      popMatrix();
    }
  }
}