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

30 min. Processing

毎日30分、Processingで何かを作る

彩度と明度

/**
* brightness & saturation
* 
* @author aa_debdeb
* @date 2016/03/31
*/

float step = 2;

void setup(){
  size(500, 500);
  colorMode(HSB, 360, 100, 100);
  noStroke();
}

void draw(){
  float rad = atan2(mouseY - height / 2, mouseX - width / 2);
  float hue = rad > 0 ? degrees(rad): degrees(TWO_PI + rad);
  for(int h = 0; h < height; h += step){
    for(int w = 0; w < width; w += step){
      float bri = map(h, 0, height, 0, 100);
      float sat = map(w, 0, width, 0, 100);
      fill(hue, sat, bri);
      rect(w, h, step, step);
    }
  }
  
}