sketch_210219b

sketch_210219b.pde

import colorblind.ColorBlindness;

final int PAD = 2;

void settings() {
  float f = 4.0;
  size((int)(148*f), (int)(210*f));
}

void setup() {
  noLoop();
  
  // ColorBlindness colorBlindness = new ColorBlindness(this);
  
  // colorBlindness.simulateAchromatopsia();
  // colorBlindness.simulateBlueConeMonochromacy();
  // colorBlindness.simulateDeuteranopia();
  // colorBlindness.simulateProtanopia();
  // colorBlindness.simulateTritanopia();
}

void draw() {
  background(#0CA8C7);
  
  float interval = width / 9.0;
  int w = (int)(width / interval);
  int h = (int)(height / interval);
  
  // fill(#E0CE24);
  fill(240);
  noStroke();
  
  for (int i = 0 - PAD; i <= h + PAD; i++) {
    for (int j = 0 - PAD; j <= w + PAD; j++) {
      if (i % 2 == 0 && j % 2 != 0 || i % 2 != 0 && j % 2 == 0) {
        pushMatrix();
        translate(j * interval, i * interval);
        drawShape(interval / 2.0);
        popMatrix();
      } else {
        pushMatrix();
        translate(j * interval, i * interval);
        rotate(HALF_PI);
        drawShape(interval / 2.0);
        popMatrix();
      }
    }
  }
  
  saveFrame("frames/image.png");
}

void drawShape(float radius) {
  int N = 50;
  beginShape();
  for (int k = 0; k < N; k++) {
    float t = TWO_PI / 4.0 / N * k;
    float r = radius * 2.0;
    float x = r * cos(t) - radius;
    float y = r * sin(t) - radius;
    vertex(x, y);
  }
  for (int k = 0; k < N; k++) {
    float t = TWO_PI / 4.0 / N * k + PI;
    float r = radius * 2.0;
    float x = r * cos(t) + radius;
    float y = r * sin(t) + radius;
    vertex(x, y);
  }
  endShape(CLOSE);
}