Daily Creative Coding

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

並んだドット

/**
* dots
*
* @author aa_debdeb
* @date 2016/05/06
*/


float hStep = 25;
float wStep = 10;
float diameter = 7;
float hueStep = 0.3;
float hue;

void setup(){
  size(600, 400);
  ellipseMode(CENTER);
  noStroke();
  
  colorMode(HSB, 360, 100, 100);
  hue = 0;
  
}

void draw(){
  float sat = map(mouseX, 0, width, 0, 100);
  float bri = map(mouseY, 0, height, 0, 100);
  background(hue, sat, bri);
  fill(hue > 180? hue - 180: hue + 180, sat, bri);
  float h = hStep / 2;
  while(h < height){
    float w = wStep / 2;
    while(w < width){
      ellipse(w, h, diameter, diameter);
      w += wStep;
    }
    h += hStep;
  }
  hue += hueStep;
  if(hue >= 360){
    hue -= 360;
  }
}