fractalkitty looking for math? fractalkitty.com

borbs

budgie

#random#color#interactive#animals

color1color2beaknostrilnostril2cheeksquiltModesetColorsbudgie

let color1 = [209, 255, 125];
let color2 = [246, 250, 125];
let beak = [255, 225, 133];
let nostril = [250, 232, 247];
let nostril2 = [150, 113, 144];
let cheeks = [101, 68, 150];
let quiltMode = false;
let bg;
let n = 6;

function setup() {
  cnv = createCanvas(500, 500);
  setColors();
  background(255);
  noStroke();
  rectMode(CENTER);
  n = int(random(2, 10));
  noLoop();
}
function draw() {
  translate(width / 2, width / 2);
  background(bg);

  if (quiltMode) {
    push();

    scale(0.95);
    for (let i = 0; i < n; i++) {
      for (let j = 0; j < n; j++) {
        setColors();
        push();

        translate(
          ((i - 0.5 * (n - 1)) * width) / n,
          ((j - 0.5 * (n - 1)) * height) / n
        );
        scale(1 / n, 1 / n);
        fill(bg);
        rect(0, 0, width, height);
        noFill();

        strokeWeight(3);
        stroke(border);
        for (let i = 0; i < lines.length; i++) {
          rect(0, 0, width - lines[i], height - lines[i]);
        }
        push();
        scale(random(0.8, 1.1));
        budgie();
        pop();
        pop();
      }
    }
    pop();
  } else {
    noFill();
    strokeWeight(3);
    stroke(border);
    for (let i = 0; i < lines.length; i++) {
      rect(0, 0, width - lines[i], height - lines[i]);
    }
    push();
    scale(random(0.8, 1.1));
    budgie();
    pop();
  }
}

function setColors() {
  color1 = [random(140, 250), random(160, 255), random(120, 220)];
  color2 = [random(120, 255), random(120, 255), random(120, 255)];
  beak = [random(150, 205), random(130, 205), random(130, 205)];
  a = [random(220, 255), random(210, 255), random(220, 250)];
  b = [random(60, 130), random(180, 255), random(220, 250)];
  if (random(-1, 1) >= 0) {
    nostril = a;
  } else {
    nostril = b;
  }
  nostril2 = [nostril[0] - 70, nostril[1] - 70, nostril[2] - 70];
  feet = a;
  cheeks = [random(80, 130), random(60, 125), random(80, 200)];
  bg = [cheeks[0] - random(50), cheeks[1] - random(50), cheeks[2] - random(50)];
  border = [beak[0] - random(50), beak[1] - random(50), beak[2] - random(50)];
  lines = [random(0, 150), random(0, 150), random(0, 150)];
}

function budgie() {
  noStroke();
  push();
  strokeWeight(3);
  stroke(feet);
  line(-30, 144, -50, 160);
  line(-30, 144, -10, 160);
  line(-30, 144, -30, 160);

  line(30, 144, 50, 160);
  line(30, 144, 10, 160);
  line(30, 144, 30, 160);
  pop();
  fill(color1);
  circle(0, 0, 300);
  fill(color2);

  arc(0, 0, 300, 300, (2 * PI) / 3, PI + PI / 3);
  arc(0, 0, 300, 300, -PI / 3, PI / 3);
  fill(color1);
  ellipse(0, 0, 270, 300);
  fill(color2);
  rect(0, -80, 140, 180, 90, 90, 70, 70);
  push();
  strokeWeight(1.5);
  for (let i = 3; i < 35; i += 1) {
    noFill();

    if (i % 3 === 0) {
      c = color(cheeks);
      c.setAlpha(10);
      stroke(c);
      rect(0, -80, 140 - i * 4, 180 - i * 4, 90, 90, 70, 70);
    }
  }
  pop();

  fill(beak);
  triangle(-20, -80, 20, -80, 0, -20);
  fill(nostril);
  ellipse(-10, -80, 30, 20);
  ellipse(10, -80, 30, 20);
  fill(nostril2);
  ellipse(-10, -80, 8, 5);
  ellipse(10, -80, 8, 5);
  fill(0);
  ellipse(-40, -100, 10, 20);
  ellipse(-40, -100, 10, 20);
  ellipse(40, -100, 10, 20);
  ellipse(40, -100, 10, 20);
  fill(255);
  ellipse(-38, -105, 3, 5);
  ellipse(-42, -102, 2, 3);
  ellipse(38, -105, 3, 5);
  ellipse(42, -102, 2, 3);
  fill(cheeks);
  push();
  translate(-40, -50);
  rotate(PI / 4);
  ellipse(0, 0, 10, 25);
  pop();
  push();
  translate(40, -50);
  rotate(-PI / 4);
  ellipse(0, 0, 10, 25);
  pop();
}
function mousePressed() {
  setup();
  draw();
}

function keyPressed() {
  if (key === "s") {
    save(cnv, "budgie", "png");
  }
  if (key === "q") {
    quiltMode = !quiltMode;
    setup();
    draw();
  }
}