Shape generator help (Armin Hofmann's 'rubber band' shape generator)

abk
Sun, 31 Oct 2021 14:15:16 +0000
Coding Questions

Hi

I’m trying to create a Hofmann’esque shape generator based on a grid of circles:

I have the basic structure of the grid done, but I’m totally stuck on where to go from here? How do I make this into a combined shape? Here’s my code so far:

color bg = #FFFFFF;
color fc = #000000;

void setup() {
  size(800, 800);
  frameRate(2);
}

void draw() {
  background(bg);
  noStroke();

  float tilesX = 4;
  float tilesY = tilesX;
  float gap = 16;

  float tileW = width / tilesX;
  float tileH = height / tilesY;

  for (int x = 0; x < tilesX; x++) {
    for (int y = 0; y < tilesY; y++) {

    float posX = tileW * x - gap;
    float posY = tileH * y - gap;
    int randomSquare = floor(random(2));

    pushMatrix();

    translate(posX +(tileW/2), posY+ (tileH/2));

    if (randomSquare == 0) {
      fill(fc);
    } else {
      noFill();
    }

    ellipse(gap, gap, tileW - gap, tileH - gap);

    popMatrix();

    }
  }

  //noLoop();

}

Hope that someone can help me out and point me in the right direction

40 posts - 13 participants