fractalkitty looking for math? fractalkitty.com

weekly creative coding

Community

#random#color#interactive#tool#wcc

let c1 = [
  "#dbe0e1",
  "#a4ccca",
  "#67b8b3",
  "#65bba1",
  "#70c48f",
  "#75cf9a",
  "#72dfc2",
  "#64d5ce",
  "#386b67",
  "#0b1110"
];
let c2 = [
  "#493d56",
  "#54515b",
  "#5e6262",
  "#6a607b",
  "#726988",
  "#73847e",
  "#84908e",
  "#a194af",
  "#a19ca9",
  "#9da59f"
];
let c3 = [
  "#554c62",
  "#60586c",
  "#6b6477",
  "#767081",
  "#817c8c",
  "#8d8997",
  "#9896a2",
  "#a4a3ad",
  "#b0b0b9",
  "#bcbec4"
];

function setup() {
  l = random([2000, 5000, 10000, 15000]);
  cnv = createCanvas(l, 300);
  describe(
    "a row of birdhouses that is an extremely wide and short sketch to horizontally scroll. Colors are mostly purples, greens, and blues"
  );
  background(random(c3));
  strokeCap(SQUARE);
  noStroke();
}
function draw() {
  i = 5;
  while (i < width) {
    noStroke();
    off1 = random(height / 4, height / 2);
    h = random((height - off1) / 3, (height - off1) / 1.5);
    tri = random(0, height - off1 - h - 10);
    w = random(30, 120);
    if (i + w > width) {
      if (width - i < 30) {
        break;
      } else {
        w = width - i - 5;
      }
    }
    fill(random(c1));
    rect(i, height - off1 - h, w, h);

    triangle(
      i,
      1 + height - off1 - h,
      i + w / 2,
      height - off1 - h - tri,
      i + w,
      height - off1 - h + 1
    );
    stroke(random(c2));
    strokeWeight(random(3, 8));
    line(i, 1 + height - off1 - h, i + w / 2, height - off1 - h - tri);
    line(i + w, 1 + height - off1 - h, i + w / 2, height - off1 - h - tri);
    ng = int(random(0, 10)) * 2;
    nb = w / (ng + 1);
    m = tri / (w / 2);
    m2 = -tri / (w / 2);
    strokeWeight(random(0.5, 3));
    for (let k = 1; k <= ng / 2; k++) {
      line(
        i + nb * k,
        height - off1,
        i + nb * k,
        height - off1 - h - m * nb * k
      );
      height - off1;
      line(
        i + w - nb * k,
        height - off1,
        i + w - nb * k,
        height - off1 - h - m * nb * k
      );

      circle(i + w / 2, height - off1 - h - tri, random([0, 5, 10]));
    }

    n = int(random(1, 4));
    noStroke();
    for (let j = 1; j < n + 1; j++) {
      fill(40);
      d = h + tri;
      x = i + w / 2 + pow(-1, j) * random(w / 16, w / 8);
      y = height - off1 - d / 2 - (w / 5) * j + w / 2.5;
      r = w / 5;
      circle(x, y, r);
      fill(random(c1));
      circle(x, y + r / 2 + 5, 5);
    }
    strokeWeight(random(4, 20));
    stroke(random(c1));
    line(i + w / 2, height - off1, i + w / 2, height);

    i += w + random(5, 10);
  }

  noLoop();
}

function mousePressed() {
  setup();
  draw();
}

function keyPressed() {
  if (keyCode === 32) {
    save(cnv, "community", "png");
  }
}