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

Daily Creative Coding

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

CMYK網点

静画
/**
* CMYK halftone
*
* @author aa_debdeb
* @date 2017/01/14
*/

float[] sizeScale;

void setup(){
  size(640, 640);
  mousePressed();  
}

void mousePressed(){
  sizeScale = new float[4];
  for(int i = 0; i < 4; i++){
    sizeScale[i] = random(1);
  }
}

void draw(){
  background(255);
  noStroke();
  color[] colors = {color(255, 255, 0, 200),
                    color(0, 255, 255, 200),
                    color(255, 0, 255, 200),
                    color(0, 200)};
  float[] rotAngle = {radians(0), radians(15), radians(45), radians(75)};
  float maxSize = map(mouseX + mouseY, 0, width + height, 50, 2);
  for(int i = 0; i < 4; i++){
    pushMatrix();
    translate(width / 2, height / 2);
    rotate(rotAngle[i]);
    float size = maxSize * sizeScale[i];
    fill(colors[i]);
    for(float w = -width * sqrt(2); w <= width * sqrt(2); w += maxSize){
      for(float h = -height * sqrt(2); h <= height * sqrt(2); h += maxSize){
        ellipse(w, h, size, size);
      }
    }
    popMatrix();
  }
}
f:id:aa_debdeb:20170110210717j:plain